@remnic/core 9.3.750 → 9.3.752

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 (318) hide show
  1. package/dist/access-boundary.d.ts +5 -5
  2. package/dist/access-boundary.js +29 -29
  3. package/dist/access-cli.js +88 -88
  4. package/dist/access-http.d.ts +5 -5
  5. package/dist/access-http.js +35 -35
  6. package/dist/access-mcp.d.ts +5 -5
  7. package/dist/access-mcp.js +34 -34
  8. package/dist/access-operations-batch.js +31 -31
  9. package/dist/access-operations.d.ts +5 -5
  10. package/dist/access-operations.js +33 -33
  11. package/dist/access-recall-surface.d.ts +363 -0
  12. package/dist/access-recall-surface.js +128 -0
  13. package/dist/access-schema.js +7 -7
  14. package/dist/{access-service-DmAEOJdJ.d.ts → access-service-C2cOHQvg.d.ts} +7 -26
  15. package/dist/access-service.d.ts +5 -5
  16. package/dist/access-service.js +28 -28
  17. package/dist/access-surface-catalog.d.ts +5 -5
  18. package/dist/action-confidence.d.ts +1 -1
  19. package/dist/active-memory-bridge.d.ts +1 -1
  20. package/dist/active-recall.d.ts +1 -1
  21. package/dist/active-recall.js +1 -1
  22. package/dist/behavior-learner.d.ts +1 -1
  23. package/dist/behavior-signals.d.ts +1 -1
  24. package/dist/bootstrap.d.ts +4 -4
  25. package/dist/briefing.d.ts +1 -1
  26. package/dist/briefing.js +4 -4
  27. package/dist/buffer-surprise-report.d.ts +1 -1
  28. package/dist/buffer.d.ts +1 -1
  29. package/dist/buffer.js +2 -2
  30. package/dist/calibration.d.ts +1 -1
  31. package/dist/capabilities.d.ts +1 -1
  32. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-CZJSLEFG.js} +3 -3
  33. package/dist/{catalog-BpOcwHdE.d.ts → catalog-D_FvzTM0.d.ts} +1 -1
  34. package/dist/causal-behavior.d.ts +1 -1
  35. package/dist/causal-behavior.js +2 -2
  36. package/dist/causal-chain.js +2 -2
  37. package/dist/causal-consolidation.d.ts +1 -1
  38. package/dist/causal-consolidation.js +9 -9
  39. package/dist/causal-retrieval.js +2 -2
  40. package/dist/causal-trajectory-graph.d.ts +1 -1
  41. package/dist/causal-trajectory.js +1 -1
  42. package/dist/{chunk-2NLLXCJG.js → chunk-2BFLDH5F.js} +2 -2
  43. package/dist/{chunk-UU32EAIY.js → chunk-2DPCAW2T.js} +5 -5
  44. package/dist/{chunk-5PZCDUJ6.js → chunk-2U4E34Y3.js} +4 -4
  45. package/dist/{chunk-JRZV3767.js → chunk-33NX5BLR.js} +4 -4
  46. package/dist/{chunk-X7Y7WX73.js → chunk-437S3G37.js} +2 -2
  47. package/dist/{chunk-HAZVVOYT.js → chunk-5DXUE7GB.js} +2 -2
  48. package/dist/{chunk-4DLFJJOQ.js → chunk-5JAT4ZJD.js} +4 -4
  49. package/dist/{chunk-RS25QOKZ.js → chunk-64SE4X5G.js} +2 -2
  50. package/dist/{chunk-QRRBXD24.js → chunk-67JRXV6Z.js} +7 -7
  51. package/dist/{chunk-WA7FECSG.js → chunk-6ROCH5JV.js} +7 -7
  52. package/dist/{chunk-5QANTTY2.js → chunk-BIAMJUUJ.js} +4 -4
  53. package/dist/{chunk-IKHKHADN.js → chunk-C4LNKQ3M.js} +5 -5
  54. package/dist/{chunk-B35L45HZ.js → chunk-DC5OBZS3.js} +2 -2
  55. package/dist/{chunk-ORAK3LNZ.js → chunk-ER3CCWK2.js} +2 -2
  56. package/dist/{chunk-SD34EK4Z.js → chunk-FEELYTRT.js} +5 -5
  57. package/dist/{chunk-KQAFEZQX.js → chunk-FLVL4L3L.js} +2 -2
  58. package/dist/{chunk-WIWPSQYU.js → chunk-FXRFFYWD.js} +4 -4
  59. package/dist/{chunk-W3M34XT4.js → chunk-GECEETQ3.js} +4 -4
  60. package/dist/{chunk-WWSXVOGY.js → chunk-GFGYHLON.js} +2 -2
  61. package/dist/{chunk-BJMBJZ2Y.js → chunk-GWTFLF2P.js} +59 -59
  62. package/dist/chunk-GWTFLF2P.js.map +1 -0
  63. package/dist/{chunk-WOX2UW4K.js → chunk-IBPEVGP5.js} +2 -2
  64. package/dist/{chunk-JZ7P26GF.js → chunk-IQWFWSCP.js} +4 -4
  65. package/dist/{chunk-6SXNQFHB.js → chunk-J2JB6BHT.js} +8 -8
  66. package/dist/{chunk-K2JM4DZZ.js → chunk-JHZ3LEM7.js} +2 -2
  67. package/dist/{chunk-YGGXUNS4.js → chunk-JNKSFIAY.js} +45 -45
  68. package/dist/{chunk-CGZWGVQF.js → chunk-K5CWCJKJ.js} +6 -6
  69. package/dist/{chunk-TPLE6SNY.js → chunk-KFNG72W7.js} +7 -7
  70. package/dist/{chunk-4NWIGAIC.js → chunk-KT2VQLP7.js} +8 -8
  71. package/dist/{chunk-6FNZ3NMS.js → chunk-L3VSTJ2V.js} +2 -2
  72. package/dist/{chunk-ARV3AUOM.js → chunk-M5QKGHCR.js} +2 -2
  73. package/dist/{chunk-E4PFDD3N.js → chunk-MEPWWSTD.js} +4 -4
  74. package/dist/{chunk-V5RVMULT.js → chunk-MLDAD27I.js} +7 -7
  75. package/dist/{chunk-K2R3DEEH.js → chunk-MTN2G4DT.js} +2 -2
  76. package/dist/{chunk-DBSMLRTO.js → chunk-MW7UUXTA.js} +5 -5
  77. package/dist/{chunk-OSMBC3JU.js → chunk-OKOF7ITI.js} +6 -6
  78. package/dist/{chunk-DBRVU5PR.js → chunk-OVMLS7TN.js} +3 -3
  79. package/dist/{chunk-NNL4LJAD.js → chunk-QMMCMV2L.js} +5 -5
  80. package/dist/{chunk-RNWWAS5V.js → chunk-QRM3K3XT.js} +5 -5
  81. package/dist/{chunk-HM6UJPPO.js → chunk-R7TGDLV3.js} +4 -4
  82. package/dist/{chunk-EEKDRAWX.js → chunk-RBYV3WSB.js} +4 -4
  83. package/dist/{chunk-LOPZ2DWR.js → chunk-RRRZ3CLN.js} +4 -4
  84. package/dist/{chunk-7TWA7DKP.js → chunk-S5UYWK3O.js} +6 -6
  85. package/dist/{chunk-QOGXUNWL.js → chunk-SC5AEZLU.js} +9 -9
  86. package/dist/{chunk-SNEXVX3U.js → chunk-UFNQKZV7.js} +15 -15
  87. package/dist/{chunk-W3BFT5OJ.js → chunk-V4ZPLQLC.js} +2 -2
  88. package/dist/{chunk-SQNED75R.js → chunk-V5UV7BOA.js} +1 -1
  89. package/dist/{chunk-CKLCFBA3.js → chunk-VQL22SHO.js} +921 -1472
  90. package/dist/chunk-VQL22SHO.js.map +1 -0
  91. package/dist/{chunk-UETBEHBA.js → chunk-VX2RYM2K.js} +2232 -1942
  92. package/dist/chunk-VX2RYM2K.js.map +1 -0
  93. package/dist/{chunk-K5LLP4CY.js → chunk-XKAOT4ZB.js} +4 -4
  94. package/dist/{chunk-ZBVQ4ZM4.js → chunk-YGNQG4Q6.js} +8 -8
  95. package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
  96. package/dist/{chunk-HYI2GP3F.js → chunk-ZGGI3COG.js} +9 -9
  97. package/dist/{cli-lmf5RGyQ.d.ts → cli-DFUU9WYu.d.ts} +3 -3
  98. package/dist/cli.d.ts +6 -6
  99. package/dist/cli.js +60 -60
  100. package/dist/compounding/engine.d.ts +1 -1
  101. package/dist/compounding/engine.js +6 -6
  102. package/dist/compounding/preference-consolidator.d.ts +1 -1
  103. package/dist/compression-optimizer.d.ts +1 -1
  104. package/dist/config.d.ts +1 -1
  105. package/dist/config.js +1 -1
  106. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  107. package/dist/connectors/codex-materialize-runner.js +5 -5
  108. package/dist/connectors/codex-materialize.d.ts +1 -1
  109. package/dist/connectors/index.d.ts +1 -1
  110. package/dist/connectors/index.js +7 -7
  111. package/dist/consolidation-provenance-check.d.ts +1 -1
  112. package/dist/consolidation-undo.d.ts +1 -1
  113. package/dist/contradiction/index.d.ts +1 -1
  114. package/dist/contradiction/index.js +2 -2
  115. package/dist/{contradiction-scan-3FJYWS3G.js → contradiction-scan-KO4WWCS4.js} +3 -3
  116. package/dist/contradiction-scan-KO4WWCS4.js.map +1 -0
  117. package/dist/conversation-index/backend.d.ts +1 -1
  118. package/dist/conversation-index/chunker.d.ts +1 -1
  119. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  120. package/dist/conversation-index/indexer.d.ts +1 -1
  121. package/dist/conversation-index/search.d.ts +1 -1
  122. package/dist/dashboard-runtime.js +2 -2
  123. package/dist/day-summary.d.ts +1 -1
  124. package/dist/day-summary.js +2 -2
  125. package/dist/delinearize.d.ts +1 -1
  126. package/dist/direct-answer-wiring.d.ts +1 -1
  127. package/dist/direct-answer.d.ts +1 -1
  128. package/dist/embedding-fallback.d.ts +1 -1
  129. package/dist/embedding-fallback.js +2 -2
  130. package/dist/enrichment/index.d.ts +1 -1
  131. package/dist/entity-retrieval.d.ts +1 -1
  132. package/dist/entity-retrieval.js +5 -5
  133. package/dist/entity-schema.d.ts +1 -1
  134. package/dist/explicit-capture.d.ts +4 -4
  135. package/dist/explicit-capture.js +2 -2
  136. package/dist/extraction-faithfulness.d.ts +1 -1
  137. package/dist/extraction-judge-telemetry.d.ts +1 -1
  138. package/dist/extraction-judge-training.d.ts +1 -1
  139. package/dist/extraction-judge.d.ts +1 -1
  140. package/dist/extraction.d.ts +1 -1
  141. package/dist/extraction.js +4 -4
  142. package/dist/fallback-llm.d.ts +1 -1
  143. package/dist/graph-dashboard-diff.d.ts +1 -1
  144. package/dist/graph-dashboard-key.d.ts +1 -1
  145. package/dist/graph-dashboard-parser.d.ts +1 -1
  146. package/dist/graph-edge-reinforcement.d.ts +1 -1
  147. package/dist/graph-snapshot.d.ts +1 -1
  148. package/dist/graph.d.ts +1 -1
  149. package/dist/identity-continuity.d.ts +1 -1
  150. package/dist/importance.d.ts +1 -1
  151. package/dist/index.d.ts +9 -9
  152. package/dist/index.js +142 -142
  153. package/dist/intent.d.ts +1 -1
  154. package/dist/lcm/engine.d.ts +1 -1
  155. package/dist/lcm/engine.js +3 -3
  156. package/dist/lcm/index.d.ts +1 -1
  157. package/dist/lcm/index.js +8 -8
  158. package/dist/lcm/tools.d.ts +1 -1
  159. package/dist/lifecycle.d.ts +1 -1
  160. package/dist/live-connectors-runner.d.ts +1 -1
  161. package/dist/local-llm.d.ts +1 -1
  162. package/dist/local-llm.js +2 -2
  163. package/dist/local-model-endpoint.d.ts +1 -1
  164. package/dist/maintenance/memory-governance.d.ts +1 -1
  165. package/dist/maintenance/memory-governance.js +4 -4
  166. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
  167. package/dist/maintenance/rebuild-memory-projection.js +5 -5
  168. package/dist/mcp-memory-inspector-app.d.ts +5 -5
  169. package/dist/memory-action-policy.d.ts +1 -1
  170. package/dist/memory-cache.d.ts +1 -1
  171. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  172. package/dist/memory-projection-store.d.ts +1 -1
  173. package/dist/memory-provenance.d.ts +1 -1
  174. package/dist/memory-worth-outcomes.d.ts +1 -1
  175. package/dist/models-json.d.ts +1 -1
  176. package/dist/namespaces/migrate.d.ts +2 -2
  177. package/dist/namespaces/migrate.js +10 -10
  178. package/dist/namespaces/principal.d.ts +1 -1
  179. package/dist/namespaces/search.d.ts +1 -1
  180. package/dist/namespaces/search.js +4 -4
  181. package/dist/namespaces/storage.d.ts +2 -2
  182. package/dist/namespaces/storage.js +6 -6
  183. package/dist/native-knowledge.d.ts +1 -1
  184. package/dist/operator-toolkit.d.ts +1 -1
  185. package/dist/operator-toolkit.js +17 -17
  186. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  187. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  188. package/dist/orchestration/maintenance.d.ts +2 -2
  189. package/dist/orchestration/maintenance.js +10 -10
  190. package/dist/{orchestrator-D7bb8ZGp.d.ts → orchestrator-BhxMxtQJ.d.ts} +27 -106
  191. package/dist/orchestrator.d.ts +4 -4
  192. package/dist/orchestrator.js +86 -86
  193. package/dist/patterns-cli.d.ts +1 -1
  194. package/dist/policy-runtime.d.ts +1 -1
  195. package/dist/provenance.d.ts +1 -1
  196. package/dist/qmd-recall-cache.d.ts +1 -1
  197. package/dist/qmd.d.ts +1 -1
  198. package/dist/recall-disclosure-escalation.d.ts +1 -1
  199. package/dist/recall-explain-renderer.d.ts +1 -1
  200. package/dist/recall-planner-llm.d.ts +1 -1
  201. package/dist/recall-state.d.ts +1 -1
  202. package/dist/recall-tag-filter.d.ts +1 -1
  203. package/dist/recall-xray-cli.d.ts +1 -1
  204. package/dist/recall-xray-renderer.d.ts +1 -1
  205. package/dist/recall-xray.d.ts +1 -1
  206. package/dist/resolve-auth-token.d.ts +1 -1
  207. package/dist/resume-bundles.js +1 -1
  208. package/dist/retrieval-agents.d.ts +1 -1
  209. package/dist/retrieval-tiers.d.ts +1 -1
  210. package/dist/routing/engine.d.ts +1 -1
  211. package/dist/routing/store.d.ts +1 -1
  212. package/dist/routing/store.js +2 -2
  213. package/dist/search/embed-helper.d.ts +1 -1
  214. package/dist/search/embed-helper.js +2 -2
  215. package/dist/search/factory.d.ts +1 -1
  216. package/dist/search/factory.js +3 -3
  217. package/dist/search/index.d.ts +1 -1
  218. package/dist/search/index.js +3 -3
  219. package/dist/search/lancedb-backend.d.ts +1 -1
  220. package/dist/search/meilisearch-backend.d.ts +1 -1
  221. package/dist/search/noop-backend.d.ts +1 -1
  222. package/dist/search/orama-backend.d.ts +1 -1
  223. package/dist/search/port.d.ts +1 -1
  224. package/dist/search/remote-backend.d.ts +1 -1
  225. package/dist/secure-store/index.js +2 -2
  226. package/dist/{semantic-consolidation-CTfbVwCA.d.ts → semantic-consolidation-BrsoFeMP.d.ts} +1 -1
  227. package/dist/semantic-consolidation.d.ts +2 -2
  228. package/dist/semantic-consolidation.js +7 -7
  229. package/dist/semantic-rule-promotion.js +4 -4
  230. package/dist/semantic-rule-verifier.d.ts +1 -1
  231. package/dist/semantic-rule-verifier.js +4 -4
  232. package/dist/session-observer-bands.d.ts +1 -1
  233. package/dist/session-observer-state.d.ts +1 -1
  234. package/dist/shared-context/manager.d.ts +1 -1
  235. package/dist/shared-context/manager.js +2 -2
  236. package/dist/signal.d.ts +1 -1
  237. package/dist/storage.d.ts +1 -1
  238. package/dist/storage.js +3 -3
  239. package/dist/summarizer.d.ts +1 -1
  240. package/dist/summarizer.js +3 -3
  241. package/dist/summary-snapshot.d.ts +1 -1
  242. package/dist/temporal-supersession.d.ts +1 -1
  243. package/dist/temporal-validity.d.ts +1 -1
  244. package/dist/threading.d.ts +1 -1
  245. package/dist/tier-migration.d.ts +1 -1
  246. package/dist/tier-routing.d.ts +1 -1
  247. package/dist/topics.d.ts +1 -1
  248. package/dist/transcript.d.ts +1 -1
  249. package/dist/transfer/backup.js +3 -3
  250. package/dist/transfer/capsule-export.js +3 -3
  251. package/dist/transfer/capsule-import.js +3 -3
  252. package/dist/trust-score-stage.d.ts +1 -1
  253. package/dist/trust-score.d.ts +1 -1
  254. package/dist/{types-D4NYDtXI.d.ts → types-BfI4uJeb.d.ts} +1 -1
  255. package/dist/types.d.ts +1 -1
  256. package/dist/utility-runtime.d.ts +1 -1
  257. package/dist/verified-recall.js +4 -4
  258. package/package.json +2 -2
  259. package/src/access-recall-surface.ts +1552 -0
  260. package/src/access-service.ts +29 -1219
  261. package/src/orchestration/recall-entry.ts +290 -0
  262. package/src/orchestration/self-deps.ts +50 -0
  263. package/src/orchestration/session-context.ts +407 -0
  264. package/src/orchestrator.ts +150 -725
  265. package/dist/chunk-BJMBJZ2Y.js.map +0 -1
  266. package/dist/chunk-CKLCFBA3.js.map +0 -1
  267. package/dist/chunk-UETBEHBA.js.map +0 -1
  268. /package/dist/{capsule-crypto-7FJQINUR.js.map → access-recall-surface.js.map} +0 -0
  269. /package/dist/{contradiction-scan-3FJYWS3G.js.map → capsule-crypto-CZJSLEFG.js.map} +0 -0
  270. /package/dist/{chunk-2NLLXCJG.js.map → chunk-2BFLDH5F.js.map} +0 -0
  271. /package/dist/{chunk-UU32EAIY.js.map → chunk-2DPCAW2T.js.map} +0 -0
  272. /package/dist/{chunk-5PZCDUJ6.js.map → chunk-2U4E34Y3.js.map} +0 -0
  273. /package/dist/{chunk-JRZV3767.js.map → chunk-33NX5BLR.js.map} +0 -0
  274. /package/dist/{chunk-X7Y7WX73.js.map → chunk-437S3G37.js.map} +0 -0
  275. /package/dist/{chunk-HAZVVOYT.js.map → chunk-5DXUE7GB.js.map} +0 -0
  276. /package/dist/{chunk-4DLFJJOQ.js.map → chunk-5JAT4ZJD.js.map} +0 -0
  277. /package/dist/{chunk-RS25QOKZ.js.map → chunk-64SE4X5G.js.map} +0 -0
  278. /package/dist/{chunk-QRRBXD24.js.map → chunk-67JRXV6Z.js.map} +0 -0
  279. /package/dist/{chunk-WA7FECSG.js.map → chunk-6ROCH5JV.js.map} +0 -0
  280. /package/dist/{chunk-5QANTTY2.js.map → chunk-BIAMJUUJ.js.map} +0 -0
  281. /package/dist/{chunk-IKHKHADN.js.map → chunk-C4LNKQ3M.js.map} +0 -0
  282. /package/dist/{chunk-B35L45HZ.js.map → chunk-DC5OBZS3.js.map} +0 -0
  283. /package/dist/{chunk-ORAK3LNZ.js.map → chunk-ER3CCWK2.js.map} +0 -0
  284. /package/dist/{chunk-SD34EK4Z.js.map → chunk-FEELYTRT.js.map} +0 -0
  285. /package/dist/{chunk-KQAFEZQX.js.map → chunk-FLVL4L3L.js.map} +0 -0
  286. /package/dist/{chunk-WIWPSQYU.js.map → chunk-FXRFFYWD.js.map} +0 -0
  287. /package/dist/{chunk-W3M34XT4.js.map → chunk-GECEETQ3.js.map} +0 -0
  288. /package/dist/{chunk-WWSXVOGY.js.map → chunk-GFGYHLON.js.map} +0 -0
  289. /package/dist/{chunk-WOX2UW4K.js.map → chunk-IBPEVGP5.js.map} +0 -0
  290. /package/dist/{chunk-JZ7P26GF.js.map → chunk-IQWFWSCP.js.map} +0 -0
  291. /package/dist/{chunk-6SXNQFHB.js.map → chunk-J2JB6BHT.js.map} +0 -0
  292. /package/dist/{chunk-K2JM4DZZ.js.map → chunk-JHZ3LEM7.js.map} +0 -0
  293. /package/dist/{chunk-YGGXUNS4.js.map → chunk-JNKSFIAY.js.map} +0 -0
  294. /package/dist/{chunk-CGZWGVQF.js.map → chunk-K5CWCJKJ.js.map} +0 -0
  295. /package/dist/{chunk-TPLE6SNY.js.map → chunk-KFNG72W7.js.map} +0 -0
  296. /package/dist/{chunk-4NWIGAIC.js.map → chunk-KT2VQLP7.js.map} +0 -0
  297. /package/dist/{chunk-6FNZ3NMS.js.map → chunk-L3VSTJ2V.js.map} +0 -0
  298. /package/dist/{chunk-ARV3AUOM.js.map → chunk-M5QKGHCR.js.map} +0 -0
  299. /package/dist/{chunk-E4PFDD3N.js.map → chunk-MEPWWSTD.js.map} +0 -0
  300. /package/dist/{chunk-V5RVMULT.js.map → chunk-MLDAD27I.js.map} +0 -0
  301. /package/dist/{chunk-K2R3DEEH.js.map → chunk-MTN2G4DT.js.map} +0 -0
  302. /package/dist/{chunk-DBSMLRTO.js.map → chunk-MW7UUXTA.js.map} +0 -0
  303. /package/dist/{chunk-OSMBC3JU.js.map → chunk-OKOF7ITI.js.map} +0 -0
  304. /package/dist/{chunk-DBRVU5PR.js.map → chunk-OVMLS7TN.js.map} +0 -0
  305. /package/dist/{chunk-NNL4LJAD.js.map → chunk-QMMCMV2L.js.map} +0 -0
  306. /package/dist/{chunk-RNWWAS5V.js.map → chunk-QRM3K3XT.js.map} +0 -0
  307. /package/dist/{chunk-HM6UJPPO.js.map → chunk-R7TGDLV3.js.map} +0 -0
  308. /package/dist/{chunk-EEKDRAWX.js.map → chunk-RBYV3WSB.js.map} +0 -0
  309. /package/dist/{chunk-LOPZ2DWR.js.map → chunk-RRRZ3CLN.js.map} +0 -0
  310. /package/dist/{chunk-7TWA7DKP.js.map → chunk-S5UYWK3O.js.map} +0 -0
  311. /package/dist/{chunk-QOGXUNWL.js.map → chunk-SC5AEZLU.js.map} +0 -0
  312. /package/dist/{chunk-SNEXVX3U.js.map → chunk-UFNQKZV7.js.map} +0 -0
  313. /package/dist/{chunk-W3BFT5OJ.js.map → chunk-V4ZPLQLC.js.map} +0 -0
  314. /package/dist/{chunk-SQNED75R.js.map → chunk-V5UV7BOA.js.map} +0 -0
  315. /package/dist/{chunk-K5LLP4CY.js.map → chunk-XKAOT4ZB.js.map} +0 -0
  316. /package/dist/{chunk-ZBVQ4ZM4.js.map → chunk-YGNQG4Q6.js.map} +0 -0
  317. /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
  318. /package/dist/{chunk-HYI2GP3F.js.map → chunk-ZGGI3COG.js.map} +0 -0
@@ -117,6 +117,9 @@ import { OrchestratorInitCoordinator } from "./orchestration/orchestrator-init.j
117
117
  import { PersistenceIndexCoordinator } from "./orchestration/persistence-index.js";
118
118
  import { WorkspaceOpsCoordinator } from "./orchestration/workspace-ops.js";
119
119
  import { NamespaceReadFanoutCoordinator } from "./orchestration/namespace-read-fanout.js";
120
+ import { selfDeps } from "./orchestration/self-deps.js";
121
+ import { RecallEntryCoordinator } from "./orchestration/recall-entry.js";
122
+ import { SessionContextCoordinator } from "./orchestration/session-context.js";
120
123
  import {
121
124
  abortRecallError,
122
125
  buildCompressionGuidelinesMarkdown,
@@ -662,7 +665,7 @@ export class Orchestrator {
662
665
  * project/branch scope a session is operating in (rule 42 — read + write
663
666
  * through the same namespace layer).
664
667
  */
665
- private readonly _codingContextBySession = new Map<string, CodingContext>();
668
+ private _codingContextBySession = new Map<string, CodingContext>();
666
669
  /**
667
670
  * Per-session peer ID registry (issue #679 PR 3/5).
668
671
  * Set by connectors / hooks via `setPeerIdForSession` so `recallInternal`
@@ -671,7 +674,19 @@ export class Orchestrator {
671
674
  * Keyed by sessionKey so concurrent sessions don't clobber each other
672
675
  * (rule 11 — scope globals per plugin ID / session).
673
676
  */
674
- private readonly _peerIdBySession = new Map<string, string>();
677
+ private _peerIdBySession = new Map<string, string>();
678
+ /**
679
+ * Defensive init for the session-binding maps (issue #1526 seam 28
680
+ * review). `Object.create(Orchestrator.prototype)` stubs in legacy
681
+ * tests skip class-field initializers, so the maps may be undefined on
682
+ * fakes; SessionContextCoordinator calls this before writing so the
683
+ * maps are created ON THE ORCHESTRATOR (or fake), never on the
684
+ * coordinator.
685
+ */
686
+ ensureSessionBindingMaps(): void {
687
+ this._codingContextBySession ??= new Map<string, CodingContext>();
688
+ this._peerIdBySession ??= new Map<string, string>();
689
+ }
675
690
  private routingRulesStore: RoutingRulesStore | null = null;
676
691
  private contentHashIndex: ContentHashIndex | null = null;
677
692
  private readonly contentHashIndexesByStorageDir = new Map<string, ContentHashIndex>();
@@ -968,188 +983,59 @@ export class Orchestrator {
968
983
  return this.applyCodingNamespaceOverlay(sessionKey, base);
969
984
  }
970
985
 
971
- /**
972
- * Effective namespace a same-session LCM/structured-history READER must use
973
- * to find what the access `observe` surface WROTE (#1495 thread 2).
974
- *
975
- * This MUST mirror the `observe` scope plan's write-namespace resolution, NOT
976
- * `resolveSelfNamespace`: when no coding overlay applies, `observe` archives
977
- * under `config.defaultNamespace` (an unqualified observed turn is NOT moved
978
- * to the principal self namespace — identical to
979
- * `resolveCodingScopedWriteNamespace`/`memory_store`, rule 39). Only when a
980
- * coding overlay actually changes the namespace does the writer (and so the
981
- * reader) use the overlaid `project-*` namespace. Returning the self base for
982
- * the no-overlay case would prefix the read key with a namespace the writer
983
- * never used, so the reader would miss its own evidence.
984
- *
985
- * Honours the access-surface `principalOverride` (#1505 thread 2, codex): when
986
- * a recall supplies an authenticated principal NOT encoded in the raw
987
- * `sessionKey`, `observe` archived LCM under THAT principal's base namespace.
988
- * Deriving the base from `resolvePrincipal(sessionKey)` alone could fall back
989
- * to `default`, so principal `alice` observing `sess-1` would write under
990
- * `alice` but READ under `default`. Threading the override here keeps the read
991
- * base identical to the write base.
992
- *
993
- * READ-AUTHORIZATION gate (#1505 round 3, codex P2 "Gate LCM recall keys by
994
- * readable namespaces"): the overlay LCM read key is a `<principal>-project-*`
995
- * sub-namespace of the principal SELF base. The normal recall namespace set
996
- * below only substitutes the coding overlay when the principal SELF base is
997
- * actually in the readable recall set (`recallNamespacesForPrincipal` — gated
998
- * by `defaultRecallNamespaces.includes("self")` AND `canReadNamespace`). If a
999
- * principal can WRITE but not READ its self namespace (or `defaultRecall-
1000
- * Namespaces` omits `self`), QMD/file recall never touches those overlay rows,
1001
- * so neither may the LCM read key. When the self base is NOT readable, fall
1002
- * back to the default store — exactly what an unqualified, unauthorized recall
1003
- * resolves to — rather than injecting overlay rows the rest of recall excludes
1004
- * (rule 42 read/write parity; rule 48 least-privilege).
1005
- */
1006
986
  private lcmReadNamespaceForSession(
1007
987
  sessionKey?: string,
1008
988
  principalOverride?: string,
1009
989
  ): string {
1010
- const principal =
1011
- typeof principalOverride === "string" && principalOverride.length > 0
1012
- ? principalOverride
1013
- : this.resolvePrincipal(sessionKey);
1014
- const base = defaultNamespaceForPrincipal(principal, this.config);
1015
- const overlaid = this.applyCodingNamespaceOverlay(sessionKey, base);
1016
- // No overlay → collapse to the default store so the LCM key is the raw
1017
- // sessionKey, exactly what an unqualified observe archived under.
1018
- if (overlaid === base) return this.config.defaultNamespace;
1019
- // Overlay applied. Only honour it when the principal SELF base is in the
1020
- // readable recall set (same gate the recall namespace set uses to
1021
- // substitute the overlay). Otherwise the overlay rows are unauthorized for
1022
- // this reader — fall back to the default store so the LCM read matches
1023
- // what QMD/file recall would surface.
1024
- const selfReadableInRecall = recallNamespacesForPrincipal(
1025
- principal,
1026
- this.config,
1027
- ).includes(base);
1028
- return selfReadableInRecall ? overlaid : this.config.defaultNamespace;
990
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
991
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
992
+ )).lcmReadNamespaceForSession(
993
+ sessionKey,
994
+ principalOverride,
995
+ );
1029
996
  }
1030
997
 
1031
- /**
1032
- * Attach a coding-agent context to a session (issue #569). Called by the
1033
- * Claude Code / Codex / Cursor connectors at session start after
1034
- * `resolveGitContext(cwd)`. The context is consulted by the recall path
1035
- * and the write path so that memories route to a project- (and optionally
1036
- * branch-) scoped namespace.
1037
- *
1038
- * Pass `null` to clear.
1039
- */
1040
998
  setCodingContextForSession(sessionKey: string, codingContext: CodingContext | null): void {
1041
- if (typeof sessionKey !== "string" || sessionKey.length === 0) return;
1042
- // Defensive init — `Object.create(Orchestrator.prototype)` stubs in
1043
- // legacy tests skip class-field initializers (rule 16 applies to test
1044
- // teardown; we apply the same defensiveness on construction here so
1045
- // PR 2 doesn't break those tests).
1046
- if (!this._codingContextBySession) {
1047
- (this as unknown as { _codingContextBySession: Map<string, CodingContext> })._codingContextBySession = new Map();
1048
- }
1049
- if (codingContext === null) {
1050
- this._codingContextBySession.delete(sessionKey);
1051
- return;
1052
- }
1053
- this._codingContextBySession.set(sessionKey, codingContext);
999
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
1000
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
1001
+ )).setCodingContextForSession(
1002
+ sessionKey,
1003
+ codingContext,
1004
+ );
1054
1005
  }
1055
1006
 
1056
- /**
1057
- * Read-only accessor for the coding context attached to a session. Returns
1058
- * `null` when none is set. Used by `remnic doctor` and by tests.
1059
- *
1060
- * Defensive `_codingContextBySession` lookup — legacy orchestrator-flush
1061
- * tests use `Object.create(Orchestrator.prototype)` which does not run
1062
- * class-field initializers, so the Map may be undefined on stubs.
1063
- */
1064
1007
  getCodingContextForSession(sessionKey: string | undefined): CodingContext | null {
1065
- if (typeof sessionKey !== "string" || sessionKey.length === 0) return null;
1066
- return this._codingContextBySession?.get(sessionKey) ?? null;
1008
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
1009
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
1010
+ )).getCodingContextForSession(
1011
+ sessionKey,
1012
+ );
1067
1013
  }
1068
1014
 
1069
- /**
1070
- * Shared helper used by both the recall path and the write path (rule 42).
1071
- *
1072
- * Given a base namespace computed from the principal, returns the overlaid
1073
- * coding namespace when the session has a coding context AND
1074
- * `codingMode.projectScope` is true AND `namespacesEnabled` is true.
1075
- * Otherwise returns `baseNamespace` unchanged — CLAUDE.md #30 escape hatch.
1076
- *
1077
- * Principal isolation (CLAUDE.md rule 42): the overlay is COMBINED with
1078
- * the principal-derived `baseNamespace` rather than replacing it, so two
1079
- * principals working in the same repository do not share memories through
1080
- * a common `project-*` namespace.
1081
- *
1082
- * Namespaces-disabled gate: when `namespacesEnabled` is false, the
1083
- * storage router maps every namespace to the same `memoryDir`. Returning
1084
- * `project-*` in that mode would create apparent route separation with
1085
- * no actual storage isolation — a false-isolation trap. In that mode we
1086
- * return `baseNamespace` unchanged so coding mode degrades to the existing
1087
- * unscoped behavior.
1088
- *
1089
- * @internal
1090
- */
1091
1015
  applyCodingNamespaceOverlay(sessionKey: string | undefined, baseNamespace: string): string {
1092
- if (!resolveNamespaceCapabilities(this.config).namespaces) return baseNamespace;
1093
- const codingContext = this.getCodingContextForSession(sessionKey);
1094
- const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode, this.config.defaultNamespace);
1095
- if (!overlay) return baseNamespace;
1096
- return combineNamespaces(baseNamespace, overlay.namespace);
1016
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
1017
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
1018
+ )).applyCodingNamespaceOverlay(
1019
+ sessionKey,
1020
+ baseNamespace,
1021
+ );
1097
1022
  }
1098
1023
 
1099
- /**
1100
- * Register a peer ID for a session so recall can inject the peer's
1101
- * profile into context (issue #679 PR 3/5). Pass `null` to clear.
1102
- *
1103
- * Connectors and the `before_agent_start` hook call this when the
1104
- * session's counter-party is known. The ID is validated against
1105
- * `PEER_ID_PATTERN` before storing.
1106
- *
1107
- * Fail-closed (Codex P1 review): an invalid peerId clears any
1108
- * previously registered mapping for the session rather than silently
1109
- * keeping stale data. This prevents a malformed metadata update from
1110
- * mixing one peer's profile context into another session.
1111
- *
1112
- * Defensive init (Cursor review + rule 16): `Object.create(
1113
- * Orchestrator.prototype)` stubs in legacy tests skip class-field
1114
- * initializers, so `_peerIdBySession` may be undefined. Mirror the
1115
- * same guard used by `setCodingContextForSession`.
1116
- */
1117
1024
  setPeerIdForSession(sessionKey: string, peerId: string | null): void {
1118
- if (typeof sessionKey !== "string" || sessionKey.length === 0) return;
1119
- // Defensive init — mirrors setCodingContextForSession (rule 16).
1120
- if (!this._peerIdBySession) {
1121
- (this as unknown as { _peerIdBySession: Map<string, string> })._peerIdBySession = new Map();
1122
- }
1123
- if (peerId === null) {
1124
- this._peerIdBySession.delete(sessionKey);
1125
- return;
1126
- }
1127
- // Basic pattern guard — full validation lives in peers/storage.ts.
1128
- // Invalid input is fail-closed: clear the existing mapping so stale
1129
- // peer context can't bleed in after a bad metadata update (Codex P1).
1130
- if (
1131
- typeof peerId !== "string" ||
1132
- peerId.length === 0 ||
1133
- peerId.length > 64 ||
1134
- !/^[A-Za-z0-9]+(?:[._-][A-Za-z0-9]+)*$/.test(peerId)
1135
- ) {
1136
- log.warn(`setPeerIdForSession: invalid peerId — clearing session mapping`);
1137
- this._peerIdBySession.delete(sessionKey);
1138
- return;
1139
- }
1140
- this._peerIdBySession.set(sessionKey, peerId);
1025
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
1026
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
1027
+ )).setPeerIdForSession(
1028
+ sessionKey,
1029
+ peerId,
1030
+ );
1141
1031
  }
1142
1032
 
1143
- /**
1144
- * Return the peer ID registered for a session, or `null` when none
1145
- * is set. Used by `recallInternal` to inject the peer profile section.
1146
- * Defensive `_peerIdBySession` lookup — legacy orchestrator-flush tests
1147
- * use `Object.create(Orchestrator.prototype)` which skips class-field
1148
- * initializers, so the Map may be undefined on stubs.
1149
- */
1150
1033
  getPeerIdForSession(sessionKey: string | undefined): string | null {
1151
- if (typeof sessionKey !== "string" || sessionKey.length === 0) return null;
1152
- return this._peerIdBySession?.get(sessionKey) ?? null;
1034
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
1035
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
1036
+ )).getPeerIdForSession(
1037
+ sessionKey,
1038
+ );
1153
1039
  }
1154
1040
 
1155
1041
  /**
@@ -2160,24 +2046,11 @@ export class Orchestrator {
2160
2046
  dryRun?: boolean;
2161
2047
  storage?: StorageManager;
2162
2048
  }): Promise<{ scannedMemories: number; appliedActionCount: number; notes?: string }> {
2163
- const targetStorage = options?.storage ?? this.storage;
2164
- const { runMemoryGovernance } = await import("./maintenance/memory-governance.js");
2165
- const { summarizeGovernanceResultForDreams } = await import("./maintenance/dreams-ledger.js");
2166
- const govResult = await runMemoryGovernance({
2167
- memoryDir: targetStorage.dir,
2168
- mode: options?.dryRun === true ? "shadow" : "apply",
2169
- });
2170
- if (options?.dryRun !== true) {
2171
- try {
2172
- await this.processEntitySynthesisQueue(
2173
- this.storageDirNamespace(targetStorage.dir),
2174
- 5,
2175
- );
2176
- } catch (error) {
2177
- log.debug(`deep-sleep governance: entity synthesis refresh failed after apply: ${error}`);
2178
- }
2179
- }
2180
- return summarizeGovernanceResultForDreams(govResult, options?.dryRun === true);
2049
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
2050
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
2051
+ )).runDeepSleepGovernanceNow(
2052
+ options,
2053
+ );
2181
2054
  }
2182
2055
 
2183
2056
  // Issue #1526 (seam 5): semantic consolidation moved to
@@ -2231,23 +2104,11 @@ export class Orchestrator {
2231
2104
  async generateDaySummary(
2232
2105
  memories: string | MemoryFile[],
2233
2106
  ): Promise<DaySummaryResult | null> {
2234
- if (this.initPromise) {
2235
- let initGateTimeoutHandle: ReturnType<typeof setTimeout> | undefined;
2236
- try {
2237
- await Promise.race([
2238
- this.initPromise.catch(() => undefined),
2239
- new Promise((resolve) => {
2240
- initGateTimeoutHandle = setTimeout(
2241
- resolve,
2242
- this.config.initGateTimeoutMs,
2243
- );
2244
- }),
2245
- ]);
2246
- } finally {
2247
- if (initGateTimeoutHandle) clearTimeout(initGateTimeoutHandle);
2248
- }
2249
- }
2250
- return this.extraction.generateDaySummary(memories);
2107
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
2108
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
2109
+ )).generateDaySummary(
2110
+ memories,
2111
+ );
2251
2112
  }
2252
2113
 
2253
2114
  /**
@@ -2452,136 +2313,13 @@ export class Orchestrator {
2452
2313
  sessionKey?: string,
2453
2314
  options: RecallInvocationOptions = {},
2454
2315
  ): Promise<string> {
2455
- // Resolve the recall-operation capability gates ONCE, at the operation
2456
- // entry, and thread the frozen set down (issue #1523). Never re-read the
2457
- // migrated flags off `this.config` mid-operation.
2458
- const caps = resolveCapabilities(this.config);
2459
- const graphCaps = resolveGraphConstructionCapabilities(this.config); // #1566 Cluster A
2460
- const abortController = new AbortController();
2461
- const onAbort = () => {
2462
- abortController.abort();
2463
- };
2464
- if (options.abortSignal?.aborted) {
2465
- abortController.abort();
2466
- } else {
2467
- options.abortSignal?.addEventListener("abort", onAbort, { once: true });
2468
- }
2469
-
2470
- const principal =
2471
- typeof options.principalOverride === "string" &&
2472
- options.principalOverride.length > 0
2473
- ? options.principalOverride
2474
- : resolvePrincipal(sessionKey, this.config);
2475
- const namespacesEnabled = resolveNamespaceCapabilities(this.config).namespaces;
2476
- if (namespacesEnabled && !principal) {
2477
- throw new Error("authentication required: namespaces are enabled and no principal was supplied");
2478
- }
2479
-
2480
- // Wait for initialization to complete before attempting recall. The timeout
2481
- // is configurable so OpenClaw's per-hook budget and Remnic's internal init
2482
- // gate can stay aligned during cold starts.
2483
- let initGateTimeoutHandle: NodeJS.Timeout | null = null;
2484
- let onInitGateAbort: (() => void) | null = null;
2485
- if (this.initPromise) {
2486
- const gateResult = await Promise.race([
2487
- this.initPromise.then(() => "ok" as const),
2488
- new Promise<"timeout">((resolve) => {
2489
- initGateTimeoutHandle = setTimeout(
2490
- () => resolve("timeout"),
2491
- this.config.initGateTimeoutMs,
2492
- );
2493
- }),
2494
- abortController.signal.aborted
2495
- ? Promise.resolve("aborted" as const)
2496
- : new Promise<"aborted">((resolve) => {
2497
- onInitGateAbort = () => resolve("aborted");
2498
- abortController.signal.addEventListener(
2499
- "abort",
2500
- onInitGateAbort,
2501
- { once: true },
2502
- );
2503
- }),
2504
- ]);
2505
- if (initGateTimeoutHandle) clearTimeout(initGateTimeoutHandle);
2506
- if (onInitGateAbort)
2507
- abortController.signal.removeEventListener("abort", onInitGateAbort);
2508
- if (gateResult === "aborted") {
2509
- this.logRecallFailure(abortRecallError("recall aborted before init"));
2510
- return "";
2511
- }
2512
- if (gateResult === "timeout") {
2513
- log.warn("recall: init gate timed out — proceeding without full init");
2514
- }
2515
- }
2516
-
2517
- // Secure-store lock gate (issue #690 PR 3/4).
2518
- // If secure-store is enabled but the keyring holds no key for this
2519
- // memory directory, reject recall with a clear human-readable error
2520
- // rather than surfacing a cryptic SecureStoreLockedError from deep
2521
- // inside the storage layer.
2522
- if (resolveRecallAuxiliaryCapabilities(this.config).secureStore && !this.storage.isSecureStoreUnlocked()) {
2523
- const lockedMsg =
2524
- "[secure-store locked] Memory store is encrypted and locked. " +
2525
- "Unlock the secure-store inside this daemon process, or restart the daemon through a secure-store aware launcher that installs the key.";
2526
- log.warn("recall blocked: secure-store is locked");
2527
- return lockedMsg;
2528
- }
2529
-
2530
- // Keep outer recall timeout above worst-case serialized hybrid search:
2531
- // QMD subprocess BM25 (30s) + vector (30s) can consume ~60s under contention.
2532
- try {
2533
- const recallPromise = this.recallInternal(prompt, sessionKey, {
2534
- ...options,
2535
- abortSignal: abortController.signal,
2536
- }, caps, graphCaps);
2537
- const RECALL_TIMEOUT_MS = this.config.recallOuterTimeoutMs ?? 75_000;
2538
- if (RECALL_TIMEOUT_MS <= 0) {
2539
- return await recallPromise;
2540
- }
2541
-
2542
- let timeoutHandle: NodeJS.Timeout | null = null;
2543
- const timeoutPromise = new Promise<string>((_, reject) => {
2544
- timeoutHandle = setTimeout(() => {
2545
- abortController.abort();
2546
- reject(new Error("recall timeout"));
2547
- }, RECALL_TIMEOUT_MS);
2548
- });
2549
-
2550
- let recallResult: string;
2551
- try {
2552
- recallResult = await Promise.race([recallPromise, timeoutPromise]);
2553
- } finally {
2554
- if (timeoutHandle) clearTimeout(timeoutHandle);
2555
- }
2556
-
2557
- // Observation-mode direct-answer tier (issue #518 slice 3c).
2558
- // Runs after the user's recall already succeeded, fire-and-forget,
2559
- // so annotation latency can never delay the caller's response.
2560
- if (caps.recallDirectAnswer && sessionKey) {
2561
- try {
2562
- this.enqueueDirectAnswerObservation(
2563
- prompt,
2564
- sessionKey,
2565
- options.namespace?.trim() || undefined,
2566
- options.principalOverride,
2567
- caps,
2568
- namespacesEnabled,
2569
- );
2570
- } catch (err) {
2571
- log.debug(`direct-answer observation setup failed: ${err}`);
2572
- }
2573
- }
2574
-
2575
- return recallResult;
2576
- } catch (err) {
2577
- this.logRecallFailure(err);
2578
- // endTrace() is safe here: if no trace is active (disabled or already
2579
- // closed by recallInternal's try/finally), it returns null immediately.
2580
- this.profiler.endTrace();
2581
- return ""; // Return empty context on timeout/error
2582
- } finally {
2583
- options.abortSignal?.removeEventListener("abort", onAbort);
2584
- }
2316
+ return (this.recallEntryCoordinator ?? new RecallEntryCoordinator(
2317
+ selfDeps<ConstructorParameters<typeof RecallEntryCoordinator>[0]>(this),
2318
+ )).recall(
2319
+ prompt,
2320
+ sessionKey,
2321
+ options,
2322
+ );
2585
2323
  }
2586
2324
 
2587
2325
  /**
@@ -2648,28 +2386,11 @@ export class Orchestrator {
2648
2386
  }
2649
2387
 
2650
2388
  private logRecallFailure(err: unknown): void {
2651
- const now = Date.now();
2652
- const errorMsg = err instanceof Error ? err.message : String(err);
2653
- const LOG_WINDOW_MS = 60_000;
2654
- const idleSinceLastFailureMs = now - this.lastRecallFailureAtMs;
2655
- this.lastRecallFailureAtMs = now;
2656
- if (idleSinceLastFailureMs >= LOG_WINDOW_MS) {
2657
- this.suppressedRecallFailures = 0;
2658
- }
2659
-
2660
- if (now - this.lastRecallFailureLogAtMs >= LOG_WINDOW_MS) {
2661
- const suffix =
2662
- this.suppressedRecallFailures > 0
2663
- ? ` (suppressed ${this.suppressedRecallFailures} similar failures in last minute)`
2664
- : "";
2665
- log.warn(`recall timed out or failed: ${errorMsg}${suffix}`);
2666
- this.lastRecallFailureLogAtMs = now;
2667
- this.suppressedRecallFailures = 0;
2668
- return;
2669
- }
2670
-
2671
- this.suppressedRecallFailures += 1;
2672
- log.debug(`recall timed out or failed (suppressed): ${errorMsg}`);
2389
+ return (this.recallEntryCoordinator ?? new RecallEntryCoordinator(
2390
+ selfDeps<ConstructorParameters<typeof RecallEntryCoordinator>[0]>(this),
2391
+ )).logRecallFailure(
2392
+ err,
2393
+ );
2673
2394
  }
2674
2395
 
2675
2396
  private artifactTypeForCategory(
@@ -2979,84 +2700,9 @@ export class Orchestrator {
2979
2700
 
2980
2701
  private get recallInternalCoordinator(): RecallInternalCoordinator {
2981
2702
  if (!this._recallInternalCoordinator) {
2982
- // eslint-disable-next-line @typescript-eslint/no-this-alias
2983
- const self = this;
2984
- this._recallInternalCoordinator = new RecallInternalCoordinator({
2985
- get _recallWorkspaceOverrides() { return self._recallWorkspaceOverrides; },
2986
- appendRecallSection: (sectionBuckets, sectionId, content) => self.appendRecallSection(sectionBuckets, sectionId, content),
2987
- applyColdFallbackPipeline: (options) => self.applyColdFallbackPipeline(options),
2988
- applyTrustScoreToBranch: (results, namespaces, caps, label) => self.applyTrustScoreToBranch(results, namespaces, caps, label),
2989
- assembleRecallSections: (sectionBuckets, budgetOverride) => self.assembleRecallSections(sectionBuckets, budgetOverride),
2990
- boostSearchResults: (results, _recallNamespaces, prompt, preloadedMemoryMap, options) => self.boostSearchResults(results, _recallNamespaces, prompt, preloadedMemoryMap, options),
2991
- boxBuilderFor: (storage) => self.boxBuilderFor(storage),
2992
- buildCompressionGuidelineRecallSection: () => self.buildCompressionGuidelineRecallSection(),
2993
- buildConfiguredQmdSearchOptions: (queryText) => self.buildConfiguredQmdSearchOptions(queryText),
2994
- buildGraphRecallRankedResults: (results, sourceLabelResolver, limit) => self.buildGraphRecallRankedResults(results, sourceLabelResolver, limit),
2995
- buildIdentityContinuitySection: (options) => self.buildIdentityContinuitySection(options),
2996
- buildLastRecallBudgetSummary: (options) => self.buildLastRecallBudgetSummary(options),
2997
- buildQueryAwarePrefilter: (prompt, recallNamespaces) => self.buildQueryAwarePrefilter(prompt, recallNamespaces),
2998
- collectLastRecallSources: (sectionBuckets, recallSource) => self.collectLastRecallSources(sectionBuckets, recallSource),
2999
- get compounding() { return self.compounding; },
3000
- get config() { return self.config; },
3001
- currentPolicyVersion: () => self.currentPolicyVersion(),
3002
- diversifyAndLimitRecallResults: (sectionId, results, limit, retrievalQuery, caps) => self.diversifyAndLimitRecallResults(sectionId, results, limit, retrievalQuery, caps),
3003
- effectiveCronRecallInstructionHeavyTokenCap: () => self.effectiveCronRecallInstructionHeavyTokenCap(),
3004
- emitTrace: (event) => self.emitTrace(event),
3005
- expandResultsViaGraph: (options) => self.expandResultsViaGraph(options),
3006
- extractMemoryIdsFromResults: (results) => self.extractMemoryIdsFromResults(results),
3007
- get fastLlmForRerank() { return self.fastLlmForRerank; },
3008
- fetchQmdMemoryResultsWithArtifactTopUp: (prompt, qmdFetchLimit, qmdHybridFetchLimit, options) => self.fetchQmdMemoryResultsWithArtifactTopUp(prompt, qmdFetchLimit, qmdHybridFetchLimit, options),
3009
- filterSearchResultsForRecall: (results, preloadedMemoryMap, options) => self.filterSearchResultsForRecall(results, preloadedMemoryMap, options),
3010
- formatCausalTrajectoryResults: (results) => self.formatCausalTrajectoryResults(results),
3011
- formatConversationRecallSection: (results, maxChars) => self.formatConversationRecallSection(results, maxChars),
3012
- formatHarmonicRetrievalResults: (results) => self.formatHarmonicRetrievalResults(results),
3013
- formatObjectiveStateResults: (results) => self.formatObjectiveStateResults(results),
3014
- formatQmdResults: (title, results, sessionKey, trustByPath) => self.formatQmdResults(title, results, sessionKey, trustByPath),
3015
- formatTrustZoneResults: (results) => self.formatTrustZoneResults(results),
3016
- formatVerifiedEpisodeResults: (results) => self.formatVerifiedEpisodeResults(results),
3017
- formatVerifiedSemanticRuleResults: (results) => self.formatVerifiedSemanticRuleResults(results),
3018
- formatWorkProductResults: (results) => self.formatWorkProductResults(results),
3019
- getCodingContextForSession: (sessionKey) => self.getCodingContextForSession(sessionKey),
3020
- getPeerIdForSession: (sessionKey) => self.getPeerIdForSession(sessionKey),
3021
- getRecallBudgetChars: (override) => self.getRecallBudgetChars(override),
3022
- getRecallSectionEntry: (sectionId) => self.getRecallSectionEntry(sectionId),
3023
- getRecallSectionMaxChars: (sectionId) => self.getRecallSectionMaxChars(sectionId),
3024
- getRecallSectionNumber: (sectionId, key) => self.getRecallSectionNumber(sectionId, key),
3025
- getStorage: (namespace) => self.getStorage(namespace),
3026
- get handleHistory() { return self.handleHistory; },
3027
- isRecallSectionEnabled: (sectionId, defaultEnabled) => self.isRecallSectionEnabled(sectionId, defaultEnabled),
3028
- isSpecializedRecallSectionEnabled: (sectionId, topLevelEnabled) => self.isSpecializedRecallSectionEnabled(sectionId, topLevelEnabled),
3029
- get lastQmdReprobeAtMs() { return self.lastQmdReprobeAtMs; },
3030
- set lastQmdReprobeAtMs(value) { self.lastQmdReprobeAtMs = value; },
3031
- get lastRecall() { return self.lastRecall; },
3032
- get lastXraySnapshot() { return self.lastXraySnapshot; },
3033
- set lastXraySnapshot(value) { self.lastXraySnapshot = value; },
3034
- get lcmEngine() { return self.lcmEngine; },
3035
- get namespaceCatalog() { return self.namespaceCatalog; },
3036
- namespaceFromPath: (p) => self.namespaceFromPath(p),
3037
- get profiler() { return self.profiler; },
3038
- publishRecallResults: (options) => self.publishRecallResults(options),
3039
- get qmd() { return self.qmd; },
3040
- queueEvalShadowRecall: (record) => self.queueEvalShadowRecall(record),
3041
- readAllMemoriesForNamespaces: (namespaces) => self.readAllMemoriesForNamespaces(namespaces),
3042
- recallArtifactsAcrossNamespaces: (prompt, recallNamespaces, targetCount) => self.recallArtifactsAcrossNamespaces(prompt, recallNamespaces, targetCount),
3043
- recallAssemblyClockMs: () => self.recallAssemblyClockMs(),
3044
- recordLastGraphRecallSnapshot: (options) => self.recordLastGraphRecallSnapshot(options),
3045
- recordLastIntentSnapshot: (options) => self.recordLastIntentSnapshot(options),
3046
- recordLastIntentSnapshotForNamespace: (options) => self.recordLastIntentSnapshotForNamespace(options),
3047
- recordLastQmdRecallSnapshot: (options) => self.recordLastQmdRecallSnapshot(options),
3048
- get rerankCache() { return self.rerankCache; },
3049
- searchConversationRecallResults: (retrievalQuery, topK) => self.searchConversationRecallResults(retrievalQuery, topK),
3050
- searchEmbeddingFallback: (query, limit) => self.searchEmbeddingFallback(query, limit),
3051
- get sharedContext() { return self.sharedContext; },
3052
- get storage() { return self.storage; },
3053
- get storageRouter() { return self.storageRouter; },
3054
- get summarizer() { return self.summarizer; },
3055
- get tmtBuilder() { return self.tmtBuilder; },
3056
- get transcript() { return self.transcript; },
3057
- truncateArtifactForRecall: (text, maxChars) => self.truncateArtifactForRecall(text, maxChars),
3058
- truncateRecallSectionToBudget: (content, maxChars) => self.truncateRecallSectionToBudget(content, maxChars),
3059
- });
2703
+ this._recallInternalCoordinator = new RecallInternalCoordinator(
2704
+ selfDeps<ConstructorParameters<typeof RecallInternalCoordinator>[0]>(this),
2705
+ );
3060
2706
  }
3061
2707
  return this._recallInternalCoordinator;
3062
2708
  }
@@ -3071,41 +2717,9 @@ export class Orchestrator {
3071
2717
 
3072
2718
  private get recallSearchPipelineCoordinator(): RecallSearchPipelineCoordinator {
3073
2719
  if (!this._recallSearchPipelineCoordinator) {
3074
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3075
- const self = this;
3076
- this._recallSearchPipelineCoordinator = new RecallSearchPipelineCoordinator({
3077
- applyMemoryWorthRerank: (results, namespaces) => self.applyMemoryWorthRerank(results, namespaces),
3078
- applyTrustScoreRerank: (results, namespaces) => self.applyTrustScoreRerank(results, namespaces),
3079
- boostSearchResults: (results, _recallNamespaces, prompt, preloadedMemoryMap, options) => self.boostSearchResults(results, _recallNamespaces, prompt, preloadedMemoryMap, options),
3080
- buildConfiguredQmdSearchOptions: (queryText) => self.buildConfiguredQmdSearchOptions(queryText),
3081
- buildQueryAwarePrefilter: (prompt, recallNamespaces) => self.buildQueryAwarePrefilter(prompt, recallNamespaces),
3082
- get config() { return self.config; },
3083
- diversifyAndLimitRecallResults: (sectionId, results, limit, retrievalQuery, caps) => self.diversifyAndLimitRecallResults(sectionId, results, limit, retrievalQuery, caps),
3084
- effectiveRecencyWeight: () => self.effectiveRecencyWeight(),
3085
- get embeddingFallback() { return self.embeddingFallback; },
3086
- expandResultsViaGraph: (options) => self.expandResultsViaGraph(options),
3087
- get fastLlmForRerank() { return self.fastLlmForRerank; },
3088
- fetchQmdMemoryResultsWithArtifactTopUp: (prompt, qmdFetchLimit, qmdHybridFetchLimit, options) => self.fetchQmdMemoryResultsWithArtifactTopUp(prompt, qmdFetchLimit, qmdHybridFetchLimit, options),
3089
- filterSearchResultsByRecallSafety: (results, memoryByPath, options) => self.filterSearchResultsByRecallSafety(results, memoryByPath, options),
3090
- filterSearchResultsForRecall: (results, preloadedMemoryMap, options) => self.filterSearchResultsForRecall(results, preloadedMemoryMap, options),
3091
- loadSearchResultMemoryMap: (results, preloadedMemoryMap, options) => self.loadSearchResultMemoryMap(results, preloadedMemoryMap, options),
3092
- namespaceFromPath: (p) => self.namespaceFromPath(p),
3093
- get negatives() { return self.negatives; },
3094
- get qmd() { return self.qmd; },
3095
- readArchivedMemoriesForNamespaces: (namespaces) => self.readArchivedMemoriesForNamespaces(namespaces),
3096
- readQmdResultMemory: (resultPath, fallbackStorage, recallNamespaces) => self.readQmdResultMemory(resultPath, fallbackStorage, recallNamespaces),
3097
- get relevance() { return self.relevance; },
3098
- get rerankCache() { return self.rerankCache; },
3099
- resolveArtifactSourceStatuses: (storage, sourceIds) => self.resolveArtifactSourceStatuses(storage, sourceIds),
3100
- resolveColdQmdResultForRecall: (result, fallbackStorage, recallNamespaces) => self.resolveColdQmdResultForRecall(result, fallbackStorage, recallNamespaces),
3101
- scopeQueryAwarePaths: (paths, recallNamespaces) => self.scopeQueryAwarePaths(paths, recallNamespaces),
3102
- searchAcrossNamespaces: (options) => self.searchAcrossNamespaces(options),
3103
- searchLongTermArchiveFallback: (prompt, recallNamespaces, limit, queryAwarePrefilter, abortSignal) => self.searchLongTermArchiveFallback(prompt, recallNamespaces, limit, queryAwarePrefilter, abortSignal),
3104
- searchScopedMemoryCandidates: (candidatePaths, query, limit, options) => self.searchScopedMemoryCandidates(candidatePaths, query, limit, options),
3105
- get storage() { return self.storage; },
3106
- get storageRouter() { return self.storageRouter; },
3107
- get utilityRuntimeValues() { return self.utilityRuntimeValues; },
3108
- });
2720
+ this._recallSearchPipelineCoordinator = new RecallSearchPipelineCoordinator(
2721
+ selfDeps<ConstructorParameters<typeof RecallSearchPipelineCoordinator>[0]>(this),
2722
+ );
3109
2723
  }
3110
2724
  return this._recallSearchPipelineCoordinator;
3111
2725
  }
@@ -3119,26 +2733,9 @@ export class Orchestrator {
3119
2733
 
3120
2734
  private get turnIngestionCoordinator(): TurnIngestionCoordinator {
3121
2735
  if (!this._turnIngestionCoordinator) {
3122
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3123
- const self = this;
3124
- this._turnIngestionCoordinator = new TurnIngestionCoordinator({
3125
- get buffer() { return self.buffer; },
3126
- bulkImportWriteNamespace: () => self.bulkImportWriteNamespace(),
3127
- get config() { return self.config; },
3128
- get extractionQueueCoordinator() { return self.extractionQueueCoordinator; },
3129
- getStorage: (namespace) => self.getStorage(namespace),
3130
- get heartbeatObserverChains() { return self.heartbeatObserverChains; },
3131
- get lcmEngine() { return self.lcmEngine; },
3132
- get passiveCorrectionDedup() { return self.passiveCorrectionDedup; },
3133
- passiveCorrectionService: () => self.passiveCorrectionService(),
3134
- get passiveCorrectionTelemetry() { return self.passiveCorrectionTelemetry; },
3135
- queueBufferedExtraction: (turnsToExtract, reason, options) => self.queueBufferedExtraction(turnsToExtract, reason, options),
3136
- resolveMemoryIdOrHandle: (ref, sessionKey) => self.resolveMemoryIdOrHandle(ref, sessionKey),
3137
- runExtraction: (...args) => self.runExtraction(...args),
3138
- get sessionObserver() { return self.sessionObserver; },
3139
- shouldQueueExtraction: (turns, options) => self.shouldQueueExtraction(turns, options),
3140
- get transcript() { return self.transcript; },
3141
- });
2736
+ this._turnIngestionCoordinator = new TurnIngestionCoordinator(
2737
+ selfDeps<ConstructorParameters<typeof TurnIngestionCoordinator>[0]>(this),
2738
+ );
3142
2739
  }
3143
2740
  return this._turnIngestionCoordinator;
3144
2741
  }
@@ -3152,25 +2749,9 @@ export class Orchestrator {
3152
2749
 
3153
2750
  private get recallIntrospectionCoordinator(): RecallIntrospectionCoordinator {
3154
2751
  if (!this._recallIntrospectionCoordinator) {
3155
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3156
- const self = this;
3157
- this._recallIntrospectionCoordinator = new RecallIntrospectionCoordinator({
3158
- annotateDirectAnswerTier: (prompt, sessionKey, namespaces, expectedIdentity, caps, _parentAbortSignal) => self.annotateDirectAnswerTier(prompt, sessionKey, namespaces, expectedIdentity, caps, _parentAbortSignal),
3159
- get config() { return self.config; },
3160
- get directAnswerObservationChain() { return self.directAnswerObservationChain; },
3161
- set directAnswerObservationChain(value) { self.directAnswerObservationChain = value; },
3162
- effectiveCronRecallInstructionHeavyTokenCap: () => self.effectiveCronRecallInstructionHeavyTokenCap(),
3163
- get faithfulnessCounters() { return self.faithfulnessCounters; },
3164
- getCodingContextForSession: (sessionKey) => self.getCodingContextForSession(sessionKey),
3165
- getLastGraphRecallSnapshot: (namespace) => self.getLastGraphRecallSnapshot(namespace),
3166
- getLastIntentSnapshot: (namespace) => self.getLastIntentSnapshot(namespace),
3167
- getLastQmdRecallSnapshot: (namespace) => self.getLastQmdRecallSnapshot(namespace),
3168
- getStorage: (namespace) => self.getStorage(namespace),
3169
- get graphRecallCoordinator() { return self.graphRecallCoordinator; },
3170
- get lastRecall() { return self.lastRecall; },
3171
- resolveStateDirForNamespace: (namespace) => self.resolveStateDirForNamespace(namespace),
3172
- get storageRouter() { return self.storageRouter; },
3173
- });
2752
+ this._recallIntrospectionCoordinator = new RecallIntrospectionCoordinator(
2753
+ selfDeps<ConstructorParameters<typeof RecallIntrospectionCoordinator>[0]>(this),
2754
+ );
3174
2755
  }
3175
2756
  return this._recallIntrospectionCoordinator;
3176
2757
  }
@@ -3185,57 +2766,9 @@ export class Orchestrator {
3185
2766
 
3186
2767
  private get orchestratorInitCoordinator(): OrchestratorInitCoordinator {
3187
2768
  if (!this._orchestratorInitCoordinator) {
3188
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3189
- const self = this;
3190
- this._orchestratorInitCoordinator = new OrchestratorInitCoordinator({
3191
- get buffer() { return self.buffer; },
3192
- get compounding() { return self.compounding; },
3193
- get config() { return self.config; },
3194
- configuredNamespaceList: () => self.configuredNamespaceList(),
3195
- get contentHashIndex() { return self.contentHashIndex; },
3196
- set contentHashIndex(value) { self.contentHashIndex = value; },
3197
- get conversationIndexBackend() { return self.conversationIndexBackend; },
3198
- get deferredInitAbort() { return self.deferredInitAbort; },
3199
- set deferredInitAbort(value) { self.deferredInitAbort = value; },
3200
- deferredInitialize: (signal) => self.deferredInitialize(signal),
3201
- get deferredReady() { return self.deferredReady; },
3202
- set deferredReady(value) { self.deferredReady = value; },
3203
- get deferredSyncSucceeded() { return self.deferredSyncSucceeded; },
3204
- set deferredSyncSucceeded(value) { self.deferredSyncSucceeded = value; },
3205
- disposeSearchBackendIfNeeded: () => self.disposeSearchBackendIfNeeded(),
3206
- get embeddingFallback() { return self.embeddingFallback; },
3207
- getWearablesService: () => self.getWearablesService(),
3208
- get handleHistory() { return self.handleHistory; },
3209
- get lastRecall() { return self.lastRecall; },
3210
- maintenanceNamespaces: (jobName, budgetMode) => self.maintenanceNamespaces(jobName, budgetMode),
3211
- get maintenanceScheduler() { return self.maintenanceScheduler; },
3212
- get namespaceCatalog() { return self.namespaceCatalog; },
3213
- get namespaceSearchRouter() { return self.namespaceSearchRouter; },
3214
- get negatives() { return self.negatives; },
3215
- passiveCorrectionService: () => self.passiveCorrectionService(),
3216
- get policyRuntime() { return self.policyRuntime; },
3217
- get qmd() { return self.qmd; },
3218
- set qmd(value) { self.qmd = value; },
3219
- get relevance() { return self.relevance; },
3220
- get resolveDeferredReady() { return self.resolveDeferredReady; },
3221
- set resolveDeferredReady(value) { self.resolveDeferredReady = value; },
3222
- get resolveInit() { return self.resolveInit; },
3223
- set resolveInit(value) { self.resolveInit = value; },
3224
- get runtimePolicyValues() { return self.runtimePolicyValues; },
3225
- set runtimePolicyValues(value) { self.runtimePolicyValues = value; },
3226
- get sessionObserver() { return self.sessionObserver; },
3227
- get sharedContext() { return self.sharedContext; },
3228
- get storage() { return self.storage; },
3229
- get storageRouter() { return self.storageRouter; },
3230
- get summarizer() { return self.summarizer; },
3231
- get tierMigrationStatus() { return self.tierMigrationStatus; },
3232
- get transcript() { return self.transcript; },
3233
- get utilityRuntimeValues() { return self.utilityRuntimeValues; },
3234
- set utilityRuntimeValues(value) { self.utilityRuntimeValues = value; },
3235
- validateLocalLlmModel: () => self.validateLocalLlmModel(),
3236
- get wearablesAutoSyncHandle() { return self.wearablesAutoSyncHandle; },
3237
- set wearablesAutoSyncHandle(value) { self.wearablesAutoSyncHandle = value; },
3238
- });
2769
+ this._orchestratorInitCoordinator = new OrchestratorInitCoordinator(
2770
+ selfDeps<ConstructorParameters<typeof OrchestratorInitCoordinator>[0]>(this),
2771
+ );
3239
2772
  }
3240
2773
  return this._orchestratorInitCoordinator;
3241
2774
  }
@@ -3249,18 +2782,9 @@ export class Orchestrator {
3249
2782
 
3250
2783
  private get persistenceIndexCoordinator(): PersistenceIndexCoordinator {
3251
2784
  if (!this._persistenceIndexCoordinator) {
3252
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3253
- const self = this;
3254
- this._persistenceIndexCoordinator = new PersistenceIndexCoordinator({
3255
- get config() { return self.config; },
3256
- get contentHashIndex() { return self.contentHashIndex; },
3257
- contentHashIndexForStorage: (targetStorage) => self.contentHashIndexForStorage(targetStorage),
3258
- get contentHashIndexesByStorageDir() { return self.contentHashIndexesByStorageDir; },
3259
- get embeddingFallback() { return self.embeddingFallback; },
3260
- graphIndexFor: (storage) => self.graphIndexFor(storage),
3261
- readAllMemoriesForNamespaces: (namespaces) => self.readAllMemoriesForNamespaces(namespaces),
3262
- semanticDedupScopeFor: (targetStorage) => self.semanticDedupScopeFor(targetStorage),
3263
- });
2785
+ this._persistenceIndexCoordinator = new PersistenceIndexCoordinator(
2786
+ selfDeps<ConstructorParameters<typeof PersistenceIndexCoordinator>[0]>(this),
2787
+ );
3264
2788
  }
3265
2789
  return this._persistenceIndexCoordinator;
3266
2790
  }
@@ -3274,32 +2798,9 @@ export class Orchestrator {
3274
2798
 
3275
2799
  private get workspaceOpsCoordinator(): WorkspaceOpsCoordinator {
3276
2800
  if (!this._workspaceOpsCoordinator) {
3277
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3278
- const self = this;
3279
- this._workspaceOpsCoordinator = new WorkspaceOpsCoordinator({
3280
- get accessTrackingBuffer() { return self.accessTrackingBuffer; },
3281
- bulkImportWriteNamespace: () => self.bulkImportWriteNamespace(),
3282
- get config() { return self.config; },
3283
- get extraction() { return self.extraction; },
3284
- getStorage: (namespace) => self.getStorage(namespace),
3285
- getStorageForNamespace: (namespace) => self.getStorageForNamespace(namespace),
3286
- get judgeDeferCounts() { return self.judgeDeferCounts; },
3287
- get judgeVerdictCache() { return self.judgeVerdictCache; },
3288
- get lastFileHygieneRunAtMs() { return self.lastFileHygieneRunAtMs; },
3289
- set lastFileHygieneRunAtMs(value) { self.lastFileHygieneRunAtMs = value; },
3290
- get lastPatternReinforcementAtByNs() { return self.lastPatternReinforcementAtByNs; },
3291
- get localLlm() { return self.localLlm; },
3292
- maintenanceNamespaces: (jobName, budgetMode) => self.maintenanceNamespaces(jobName, budgetMode),
3293
- namespaceFromPath: (p) => self.namespaceFromPath(p),
3294
- get qmd() { return self.qmd; },
3295
- readAllMemoriesForNamespaces: (namespaces) => self.readAllMemoriesForNamespaces(namespaces),
3296
- runNamespaceMaintenanceFanoutForJob: (jobName, runner, options) => self.runNamespaceMaintenanceFanoutForJob(jobName, runner, options),
3297
- runPatternReinforcement: (options) => self.runPatternReinforcement(options),
3298
- get storage() { return self.storage; },
3299
- get storageRouter() { return self.storageRouter; },
3300
- get wearablesServiceInstance() { return self.wearablesServiceInstance; },
3301
- set wearablesServiceInstance(value) { self.wearablesServiceInstance = value; },
3302
- });
2801
+ this._workspaceOpsCoordinator = new WorkspaceOpsCoordinator(
2802
+ selfDeps<ConstructorParameters<typeof WorkspaceOpsCoordinator>[0]>(this),
2803
+ );
3303
2804
  }
3304
2805
  return this._workspaceOpsCoordinator;
3305
2806
  }
@@ -3313,32 +2814,47 @@ export class Orchestrator {
3313
2814
 
3314
2815
  private get namespaceReadFanoutCoordinator(): NamespaceReadFanoutCoordinator {
3315
2816
  if (!this._namespaceReadFanoutCoordinator) {
3316
- // eslint-disable-next-line @typescript-eslint/no-this-alias
3317
- const self = this;
3318
- this._namespaceReadFanoutCoordinator = new NamespaceReadFanoutCoordinator({
3319
- get artifactSourceStatusCache() { return self.artifactSourceStatusCache; },
3320
- get config() { return self.config; },
3321
- configuredNamespaceList: () => self.configuredNamespaceList(),
3322
- fetchActiveArtifactsForNamespace: (namespace, prompt, targetCount) => self.fetchActiveArtifactsForNamespace(namespace, prompt, targetCount),
3323
- loadNamespaceStorageDirHintsFromCatalog: () => self.loadNamespaceStorageDirHintsFromCatalog(),
3324
- get namespaceCatalog() { return self.namespaceCatalog; },
3325
- namespaceFromPath: (p) => self.namespaceFromPath(p),
3326
- get namespaceSearchRouter() { return self.namespaceSearchRouter; },
3327
- namespaceStorageDirHintOwnershipRank: (record, resolvedStorageDir, configured) => self.namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured),
3328
- get namespaceStorageDirHints() { return self.namespaceStorageDirHints; },
3329
- get namespaceStorageDirHintsLoaded() { return self.namespaceStorageDirHintsLoaded; },
3330
- set namespaceStorageDirHintsLoaded(value) { self.namespaceStorageDirHintsLoaded = value; },
3331
- preferNamespaceStorageDirHintOwner: (current, candidate, resolvedStorageDir, configured) => self.preferNamespaceStorageDirHintOwner(current, candidate, resolvedStorageDir, configured),
3332
- get qmd() { return self.qmd; },
3333
- qmdCollectionNamespaceFromPrefix: (collectionPrefix) => self.qmdCollectionNamespaceFromPrefix(collectionPrefix),
3334
- rememberNamespaceStorageDirHint: (namespace, storageDir) => self.rememberNamespaceStorageDirHint(namespace, storageDir),
3335
- storageDirMatchesNamespaceHint: (namespace, storageDir) => self.storageDirMatchesNamespaceHint(namespace, storageDir),
3336
- get storageRouter() { return self.storageRouter; },
3337
- });
2817
+ this._namespaceReadFanoutCoordinator = new NamespaceReadFanoutCoordinator(
2818
+ selfDeps<ConstructorParameters<typeof NamespaceReadFanoutCoordinator>[0]>(this),
2819
+ );
3338
2820
  }
3339
2821
  return this._namespaceReadFanoutCoordinator;
3340
2822
  }
3341
2823
 
2824
+ /** RecallEntryCoordinator (issue #1526 seam 28). Lazy; selfDeps live wiring. */
2825
+ private _recallEntryCoordinator: RecallEntryCoordinator | undefined;
2826
+
2827
+ private get recallEntryCoordinator(): RecallEntryCoordinator {
2828
+ if (!this._recallEntryCoordinator) {
2829
+ this._recallEntryCoordinator = new RecallEntryCoordinator(
2830
+ selfDeps<ConstructorParameters<typeof RecallEntryCoordinator>[0]>(this),
2831
+ );
2832
+ }
2833
+ return this._recallEntryCoordinator;
2834
+ }
2835
+
2836
+ /** SessionContextCoordinator (issue #1526 seam 28). Lazy; selfDeps live wiring. */
2837
+ private _sessionContextCoordinator: SessionContextCoordinator | undefined;
2838
+
2839
+ /**
2840
+ * Self-handle read through the selfDeps proxy (seam 28): coordinators
2841
+ * that construct services against the orchestrator instance (e.g. the
2842
+ * passive-correction CorrectionService) receive it via deps instead of
2843
+ * capturing the coordinator's own `this`.
2844
+ */
2845
+ get orchestratorSelf(): Orchestrator {
2846
+ return this;
2847
+ }
2848
+
2849
+ private get sessionContextCoordinator(): SessionContextCoordinator {
2850
+ if (!this._sessionContextCoordinator) {
2851
+ this._sessionContextCoordinator = new SessionContextCoordinator(
2852
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
2853
+ );
2854
+ }
2855
+ return this._sessionContextCoordinator;
2856
+ }
2857
+
3342
2858
  private async recallInternal(
3343
2859
  prompt: string,
3344
2860
  sessionKey?: string,
@@ -3385,39 +2901,12 @@ export class Orchestrator {
3385
2901
  bufferKey?: string;
3386
2902
  },
3387
2903
  ): Promise<void> {
3388
- const explicitBufferKey =
3389
- typeof options.bufferKey === "string" && options.bufferKey.length > 0
3390
- ? options.bufferKey
3391
- : null;
3392
- const discoveredBufferKeys =
3393
- explicitBufferKey ||
3394
- typeof sessionKey !== "string" ||
3395
- sessionKey.length === 0 ||
3396
- typeof this.buffer.findBufferKeysForSession !== "function"
3397
- ? []
3398
- : await this.buffer.findBufferKeysForSession(sessionKey);
3399
- const bufferKeys = explicitBufferKey
3400
- ? [explicitBufferKey]
3401
- : discoveredBufferKeys.length > 0
3402
- ? discoveredBufferKeys
3403
- : typeof sessionKey === "string" && sessionKey.length > 0
3404
- ? [sessionKey]
3405
- : ["default"];
3406
- for (const bufferKey of bufferKeys) {
3407
- const turns = this.buffer.getTurns(bufferKey);
3408
- if (turns.length === 0) continue;
3409
- await new Promise<void>((resolve, reject) => {
3410
- void this
3411
- .queueBufferedExtraction(turns, "trigger_mode", {
3412
- bufferKey,
3413
- clearBufferAfterExtraction: true,
3414
- skipDedupeCheck: true,
3415
- abortSignal: options.abortSignal,
3416
- onTaskSettled: (error) => (error ? reject(error) : resolve()),
3417
- })
3418
- .catch(reject);
3419
- });
3420
- }
2904
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
2905
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
2906
+ )).flushSession(
2907
+ sessionKey,
2908
+ options,
2909
+ );
3421
2910
  }
3422
2911
 
3423
2912
  async ingestReplayBatch(
@@ -3572,52 +3061,11 @@ export class Orchestrator {
3572
3061
  );
3573
3062
  }
3574
3063
 
3575
- /** Lazily construct the CorrectionService for passive capture. Stateless
3576
- * across requests (per #1580 design); cached for the orchestrator's life. */
3577
3064
  private passiveCorrectionService(): CorrectionService {
3578
- if (this._passiveCorrectionService) return this._passiveCorrectionService;
3579
- this._passiveCorrectionService = createCorrectionService({
3580
- orchestrator: this,
3581
- // Session-scoped write ACL (review: "passive capture bypasses write
3582
- // ACL"). A correction detected in session S plans only against S readable
3583
- // namespaces and applies only to writable ones (rule 42) — passive
3584
- // capture never becomes a cross-tenant mutation vector. Mirrors the
3585
- // access-service createCorrectionService wiring rather than bypassing it.
3586
- resolveAuthorizedNamespace: async (req) => {
3587
- const principal = req.principal || resolvePrincipal(req.sessionKey, this.config);
3588
- const ns = req.namespace ?? defaultNamespaceForPrincipal(principal, this.config);
3589
- if (!canWriteNamespace(principal, ns, this.config)) {
3590
- throw new Error(
3591
- `passive correction: namespace "${ns}" is not writable for principal ${principal ?? "(none)"}`,
3592
- );
3593
- }
3594
- return ns;
3595
- },
3596
- resolveReadableNamespaces: (req) => {
3597
- const principal = req.principal || resolvePrincipal(req.sessionKey, this.config);
3598
- return recallNamespacesForPrincipal(principal, this.config);
3599
- },
3600
- canWriteNamespace: async (req) => {
3601
- const principal = req.principal || resolvePrincipal(req.sessionKey, this.config);
3602
- return canWriteNamespace(principal, req.namespace, this.config);
3603
- },
3604
- llmComplete: async ({ system, user }) => {
3605
- const llmResult = await this.localLlm.chatCompletion(
3606
- [
3607
- { role: "system", content: system },
3608
- { role: "user", content: user },
3609
- ],
3610
- { operation: "correction-classify", priority: "background" },
3611
- );
3612
- if (!llmResult) {
3613
- throw new Error(
3614
- "passive correction classify+draft: local LLM unavailable (disabled or in cooldown)",
3615
- );
3616
- }
3617
- return llmResult.content;
3618
- },
3619
- });
3620
- return this._passiveCorrectionService;
3065
+ return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
3066
+ selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
3067
+ )).passiveCorrectionService(
3068
+ );
3621
3069
  }
3622
3070
 
3623
3071
  async runExtraction(
@@ -3944,24 +3392,11 @@ export class Orchestrator {
3944
3392
  private queueEvalShadowRecall(
3945
3393
  record: Omit<EvalShadowRecallRecord, "schemaVersion">,
3946
3394
  ): void {
3947
- if (!resolveEvalCapabilities(this.config).evalHarness || !resolveEvalCapabilities(this.config).evalShadowMode)
3948
- return;
3949
- this.evalShadowWriteChain = this.evalShadowWriteChain
3950
- .catch(() => undefined)
3951
- .then(async () => {
3952
- try {
3953
- await recordEvalShadowRecall({
3954
- memoryDir: this.config.memoryDir,
3955
- evalStoreDir: this.config.evalStoreDir,
3956
- record: {
3957
- schemaVersion: 1,
3958
- ...record,
3959
- },
3960
- });
3961
- } catch (err) {
3962
- log.debug(`eval shadow recall write failed: ${err}`);
3963
- }
3964
- });
3395
+ return (this.recallEntryCoordinator ?? new RecallEntryCoordinator(
3396
+ selfDeps<ConstructorParameters<typeof RecallEntryCoordinator>[0]>(this),
3397
+ )).queueEvalShadowRecall(
3398
+ record,
3399
+ );
3965
3400
  }
3966
3401
 
3967
3402
  private publishRecallResults(options: {
@@ -3985,20 +3420,10 @@ export class Orchestrator {
3985
3420
  */
3986
3421
  trustByPath?: Map<string, TrustStageResultItem> | null;
3987
3422
  }): void {
3988
- const sectionId = "memories";
3989
- // Filter quarantined items from ALL recall paths so no branch can inject
3990
- // a hard-negative memory that trust scoring excluded on another path.
3991
- const trustByPath = options.trustByPath ?? null;
3992
- const injectable = trustByPath
3993
- ? options.results.filter((r) => !trustByPath.get(r.path)?.quarantined)
3994
- : options.results;
3995
- const memoryIds = this.extractMemoryIdsFromResults(injectable);
3996
- this.trackMemoryAccess(memoryIds);
3997
-
3998
- this.appendRecallSection(
3999
- options.sectionBuckets,
4000
- sectionId,
4001
- this.formatQmdResults(options.title, injectable, options.sessionKey, trustByPath),
3423
+ return (this.recallEntryCoordinator ?? new RecallEntryCoordinator(
3424
+ selfDeps<ConstructorParameters<typeof RecallEntryCoordinator>[0]>(this),
3425
+ )).publishRecallResults(
3426
+ options,
4002
3427
  );
4003
3428
  }
4004
3429