@remnic/core 9.65.5 → 9.65.7

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 (500) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -11
  2. package/dist/access-admin-ops-surface.js +26 -26
  3. package/dist/access-authorization-probe.d.ts +11 -11
  4. package/dist/access-authorization-probe.js +27 -27
  5. package/dist/access-boundary.d.ts +11 -11
  6. package/dist/access-boundary.js +26 -26
  7. package/dist/access-cli.js +110 -104
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +1 -1
  10. package/dist/access-extraction-force-flush.d.ts +11 -11
  11. package/dist/access-extraction-force-flush.js +26 -26
  12. package/dist/access-health-types.d.ts +1 -1
  13. package/dist/access-http-lcm-compaction.d.ts +11 -11
  14. package/dist/access-http-lifecycle-flush.d.ts +11 -11
  15. package/dist/access-http-offline-stream.d.ts +11 -11
  16. package/dist/access-http-query.d.ts +2 -2
  17. package/dist/access-http-query.js +28 -28
  18. package/dist/access-http.d.ts +13 -18
  19. package/dist/access-http.js +46 -44
  20. package/dist/access-identity-continuity-surface.d.ts +9 -9
  21. package/dist/access-identity-continuity-surface.js +26 -26
  22. package/dist/access-lcm-surface.d.ts +11 -11
  23. package/dist/access-lcm-surface.js +26 -26
  24. package/dist/access-mcp-output-schemas.js +1 -1
  25. package/dist/access-mcp.d.ts +11 -11
  26. package/dist/access-mcp.js +37 -35
  27. package/dist/access-memory-search-fanout.d.ts +2 -2
  28. package/dist/{access-namespace-preflight-D_6mo8ms.d.ts → access-namespace-preflight-8VYKmRX0.d.ts} +1 -1
  29. package/dist/access-namespace-preflight.d.ts +3 -3
  30. package/dist/access-namespace-preflight.js +26 -26
  31. package/dist/access-observe-write-surface.d.ts +11 -11
  32. package/dist/access-observe-write-surface.js +26 -26
  33. package/dist/access-offline-manifest.d.ts +9 -9
  34. package/dist/access-operations-batch.js +29 -29
  35. package/dist/access-operations.d.ts +12 -12
  36. package/dist/access-operations.js +34 -32
  37. package/dist/access-recall-concurrency.d.ts +11 -11
  38. package/dist/access-recall-concurrency.js +26 -26
  39. package/dist/access-recall-response.d.ts +11 -11
  40. package/dist/access-recall-response.js +26 -26
  41. package/dist/access-recall-surface.d.ts +11 -11
  42. package/dist/access-recall-surface.js +26 -26
  43. package/dist/access-schema.js +3 -3
  44. package/dist/{access-service-sbiNS5UB.d.ts → access-service-Crk__Git.d.ts} +8 -8
  45. package/dist/access-service-helpers.d.ts +11 -11
  46. package/dist/access-service.d.ts +11 -11
  47. package/dist/access-service.js +26 -26
  48. package/dist/access-surface-catalog.d.ts +11 -11
  49. package/dist/access-surface-catalog.js +38 -28
  50. package/dist/access-surface-catalog.js.map +1 -1
  51. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  52. package/dist/action-confidence.d.ts +1 -1
  53. package/dist/active-memory-bridge.d.ts +1 -1
  54. package/dist/active-recall.d.ts +1 -1
  55. package/dist/active-recall.js +4 -4
  56. package/dist/adapters/index.js +4 -4
  57. package/dist/adapters/registry.js +2 -2
  58. package/dist/ambient-provenance.d.ts +1 -1
  59. package/dist/artifact-search.d.ts +1 -1
  60. package/dist/behavior-learner.d.ts +1 -1
  61. package/dist/behavior-signals.d.ts +1 -1
  62. package/dist/bootstrap.d.ts +9 -9
  63. package/dist/briefing-window.d.ts +2 -2
  64. package/dist/briefing.d.ts +2 -2
  65. package/dist/briefing.js +8 -8
  66. package/dist/buffer-surprise-report.d.ts +1 -1
  67. package/dist/buffer-turn-helpers.d.ts +1 -1
  68. package/dist/buffer.d.ts +2 -2
  69. package/dist/bulk-import/index.d.ts +3 -3
  70. package/dist/calibration.d.ts +1 -1
  71. package/dist/capabilities.d.ts +1 -1
  72. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-7FJQINUR.js} +2 -2
  73. package/dist/{catalog-DO_7zfkv.d.ts → catalog-DybwVNW3.d.ts} +1 -1
  74. package/dist/causal-behavior.d.ts +1 -1
  75. package/dist/causal-behavior.js +2 -2
  76. package/dist/causal-chain.js +2 -2
  77. package/dist/causal-consolidation.d.ts +1 -1
  78. package/dist/causal-consolidation.js +11 -11
  79. package/dist/causal-retrieval.js +2 -2
  80. package/dist/causal-trajectory-graph.d.ts +1 -1
  81. package/dist/causal-trajectory-graph.js +2 -2
  82. package/dist/causal-trajectory.js +1 -1
  83. package/dist/{chunk-BXLOS5AJ.js → chunk-2NLLXCJG.js} +2 -2
  84. package/dist/{chunk-NZPFCP5A.js → chunk-2PSX5BJU.js} +2 -2
  85. package/dist/chunk-3BCULS4U.js +1093 -0
  86. package/dist/chunk-3BCULS4U.js.map +1 -0
  87. package/dist/{chunk-IIRCHGWD.js → chunk-3RI5Y7KU.js} +2 -2
  88. package/dist/{chunk-H7BZBSP6.js → chunk-52II7PB6.js} +4 -4
  89. package/dist/{chunk-J3ATBB7M.js → chunk-5DH6PG4B.js} +2 -2
  90. package/dist/{chunk-M4AHBM72.js → chunk-5HERQ5FX.js} +10 -10
  91. package/dist/{chunk-W675UJCZ.js → chunk-5HK3CJAR.js} +2 -2
  92. package/dist/{chunk-2MVTAIL3.js → chunk-5S4LQOPE.js} +2 -2
  93. package/dist/{chunk-OZDFB22S.js → chunk-5VPQSRQO.js} +3 -3
  94. package/dist/{chunk-YZJM6CLF.js → chunk-6CPUQ5D6.js} +10 -10
  95. package/dist/{chunk-2IXQSGCU.js → chunk-7F27PCSN.js} +2 -2
  96. package/dist/{chunk-OWQNJJY2.js → chunk-7TCGNUVP.js} +2 -2
  97. package/dist/{chunk-3NH3VP3U.js → chunk-7WR462EM.js} +2 -2
  98. package/dist/{chunk-NH6LC57D.js → chunk-A32YEQAM.js} +2 -2
  99. package/dist/{chunk-HF5BUTI6.js → chunk-ACOC27BB.js} +2 -2
  100. package/dist/{chunk-N56GVOWR.js → chunk-AFR6AIM4.js} +144 -78
  101. package/dist/chunk-AFR6AIM4.js.map +1 -0
  102. package/dist/{chunk-LYBIHM4N.js → chunk-ANJXPFRS.js} +47 -26
  103. package/dist/chunk-ANJXPFRS.js.map +1 -0
  104. package/dist/{chunk-FC7TIRFS.js → chunk-AX7UXCHJ.js} +6 -1
  105. package/dist/chunk-AX7UXCHJ.js.map +1 -0
  106. package/dist/{chunk-THVI4Y7X.js → chunk-BJTHRFFC.js} +6 -6
  107. package/dist/chunk-BWGCOLEL.js +61 -0
  108. package/dist/chunk-BWGCOLEL.js.map +1 -0
  109. package/dist/{chunk-BW4GAF57.js → chunk-CFGU52XJ.js} +2 -2
  110. package/dist/{chunk-DPNXADEI.js → chunk-D4QVPP3G.js} +2 -2
  111. package/dist/{chunk-BK5G2MHO.js → chunk-EOHKUWXW.js} +2 -2
  112. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  113. package/dist/{chunk-ZK4BFABK.js → chunk-F635GAL7.js} +4 -4
  114. package/dist/{chunk-IURMJBGP.js → chunk-F6QHHRWP.js} +2 -2
  115. package/dist/{chunk-BA2GLSIP.js → chunk-FMQ4MOQO.js} +91 -28
  116. package/dist/chunk-FMQ4MOQO.js.map +1 -0
  117. package/dist/{chunk-LDBFXD4F.js → chunk-FP7YTTVO.js} +3 -1
  118. package/dist/chunk-FP7YTTVO.js.map +1 -0
  119. package/dist/{chunk-TJFI3K2O.js → chunk-GEPACVWN.js} +2 -2
  120. package/dist/{chunk-PP7R754B.js → chunk-GPFZFCRN.js} +1 -1
  121. package/dist/{chunk-UCKG36HO.js → chunk-GTSVEEP3.js} +2 -2
  122. package/dist/{chunk-KTPXXVDQ.js → chunk-I4343FIA.js} +79 -6
  123. package/dist/chunk-I4343FIA.js.map +1 -0
  124. package/dist/{chunk-DPGH6LHQ.js → chunk-I7EX6KSH.js} +57 -57
  125. package/dist/{chunk-JPAKBNTM.js → chunk-IP4ZNT4U.js} +2 -2
  126. package/dist/{chunk-AXGFOFNY.js → chunk-IY7UXD3J.js} +2 -2
  127. package/dist/{chunk-YHCBJULX.js → chunk-JAQXUGLN.js} +2 -2
  128. package/dist/{chunk-RKNJBZ55.js → chunk-JBPKEARU.js} +4 -4
  129. package/dist/chunk-JCCWJHOP.js +240 -0
  130. package/dist/chunk-JCCWJHOP.js.map +1 -0
  131. package/dist/{chunk-VDX2J7OX.js → chunk-KQAFEZQX.js} +2 -2
  132. package/dist/{chunk-D2YNNDML.js → chunk-KWIGDKM2.js} +2 -2
  133. package/dist/{chunk-YB4GBWBU.js → chunk-LLQCM2U2.js} +81 -81
  134. package/dist/{chunk-OLBZ2WGG.js → chunk-LTBKKSCX.js} +2 -2
  135. package/dist/{chunk-DORFF5N5.js → chunk-NG3MBQV4.js} +2 -2
  136. package/dist/{chunk-DUEDOYZD.js → chunk-OPGL46PX.js} +2 -2
  137. package/dist/{chunk-OUKBMQ2O.js → chunk-PD66CVSD.js} +2 -2
  138. package/dist/{chunk-CQBIN77D.js → chunk-PDDSFELN.js} +2 -2
  139. package/dist/{chunk-6433HV72.js → chunk-PMVPCZJZ.js} +2 -2
  140. package/dist/{chunk-DJZWNKFO.js → chunk-RGCF4XNH.js} +7 -7
  141. package/dist/{chunk-CV3GNPOE.js → chunk-RQE4TITU.js} +29 -24
  142. package/dist/chunk-RQE4TITU.js.map +1 -0
  143. package/dist/{chunk-4JSF7UUP.js → chunk-S3K2CIK5.js} +2 -2
  144. package/dist/chunk-SDEPLF7V.js +325 -0
  145. package/dist/chunk-SDEPLF7V.js.map +1 -0
  146. package/dist/{chunk-OCCHUEZB.js → chunk-SEA6M7SS.js} +2 -2
  147. package/dist/{chunk-KOO37E4Y.js → chunk-SVVIASVX.js} +2 -2
  148. package/dist/{chunk-4K7IW3F7.js → chunk-UD7UNYRD.js} +34 -3
  149. package/dist/chunk-UD7UNYRD.js.map +1 -0
  150. package/dist/chunk-ULM7JCDH.js +154 -0
  151. package/dist/chunk-ULM7JCDH.js.map +1 -0
  152. package/dist/{chunk-FBR7PIL4.js → chunk-VKCAHCBI.js} +2 -2
  153. package/dist/{chunk-WDXD6ITO.js → chunk-VXVZ2GM3.js} +2 -2
  154. package/dist/chunk-W2UOAATB.js +521 -0
  155. package/dist/chunk-W2UOAATB.js.map +1 -0
  156. package/dist/{chunk-DUZARALI.js → chunk-WTOZBZNN.js} +3 -3
  157. package/dist/{chunk-DQEMWVMT.js → chunk-X7Y7WX73.js} +1 -1
  158. package/dist/{chunk-2EPOGPKO.js → chunk-YKWFK7XA.js} +5 -5
  159. package/dist/{chunk-BIJAWZYW.js → chunk-YMOPYG3K.js} +6 -6
  160. package/dist/{chunk-UFR6HX7A.js → chunk-YRVAKONL.js} +1 -1
  161. package/dist/{chunk-ECLJ4LA2.js → chunk-YWSQD2IB.js} +2 -2
  162. package/dist/{chunk-NLEH4RTB.js → chunk-Z4U3UN56.js} +2 -2
  163. package/dist/{chunk-YDKF4MSJ.js → chunk-ZAOHJDKH.js} +3 -3
  164. package/dist/{chunk-KFIOPZ25.js → chunk-ZIJDI4CP.js} +2 -2
  165. package/dist/{cli-BqdqPdG_.d.ts → cli-B322UMvB.d.ts} +6 -6
  166. package/dist/cli.d.ts +14 -14
  167. package/dist/cli.js +73 -72
  168. package/dist/coding/pre-action-gate.d.ts +1 -1
  169. package/dist/coding/pre-action-gate.js +2 -2
  170. package/dist/compounding/engine.d.ts +2 -2
  171. package/dist/compounding/engine.js +8 -8
  172. package/dist/compounding/preference-consolidator.d.ts +1 -1
  173. package/dist/compression-optimizer.d.ts +1 -1
  174. package/dist/config.d.ts +1 -1
  175. package/dist/config.js +4 -4
  176. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  177. package/dist/connectors/codex-materialize-runner.js +8 -8
  178. package/dist/connectors/codex-materialize.d.ts +1 -1
  179. package/dist/connectors/index.d.ts +1 -1
  180. package/dist/connectors/index.js +8 -8
  181. package/dist/consolidation-provenance-check.d.ts +2 -2
  182. package/dist/consolidation-undo.d.ts +2 -2
  183. package/dist/contradiction/index.d.ts +3 -3
  184. package/dist/converge-config.d.ts +1 -1
  185. package/dist/convergence-refresh.d.ts +2 -2
  186. package/dist/convergence-refresh.js +10 -10
  187. package/dist/conversation-index/backend.d.ts +1 -1
  188. package/dist/conversation-index/chunker.d.ts +1 -1
  189. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  190. package/dist/conversation-index/indexer.d.ts +1 -1
  191. package/dist/conversation-index/search.d.ts +1 -1
  192. package/dist/corpus-watermark.d.ts +1 -1
  193. package/dist/corpus-watermark.js +10 -10
  194. package/dist/cross-lingual-recall.d.ts +1 -1
  195. package/dist/dashboard-runtime.js +2 -2
  196. package/dist/day-summary.d.ts +1 -1
  197. package/dist/delinearize.d.ts +1 -1
  198. package/dist/dependency-propagation-config.d.ts +1 -1
  199. package/dist/{dependency-propagation-delivery-D23_x-s5.d.ts → dependency-propagation-delivery-BGcNairQ.d.ts} +1 -1
  200. package/dist/direct-answer-wiring.d.ts +1 -1
  201. package/dist/direct-answer.d.ts +1 -1
  202. package/dist/embedding-fallback.d.ts +1 -1
  203. package/dist/enrichment/index.d.ts +1 -1
  204. package/dist/entity-origin-fields.d.ts +1 -1
  205. package/dist/entity-retrieval.d.ts +2 -2
  206. package/dist/entity-retrieval.js +8 -8
  207. package/dist/entity-schema.d.ts +1 -1
  208. package/dist/episodic-context.d.ts +1 -1
  209. package/dist/eval-trajectory-contracts.d.ts +256 -0
  210. package/dist/eval-trajectory-contracts.js +56 -0
  211. package/dist/eval-trajectory-store.d.ts +39 -0
  212. package/dist/eval-trajectory-store.js +19 -0
  213. package/dist/eval-trajectory-store.js.map +1 -0
  214. package/dist/eval-trajectory.d.ts +67 -0
  215. package/dist/eval-trajectory.js +46 -0
  216. package/dist/eval-trajectory.js.map +1 -0
  217. package/dist/event-order-recall.js +2 -2
  218. package/dist/explicit-capture.d.ts +9 -9
  219. package/dist/external-wiki-access.d.ts +11 -11
  220. package/dist/external-wiki-access.js +27 -27
  221. package/dist/external-wiki-collection-registration.d.ts +1 -1
  222. package/dist/external-wiki-collection.d.ts +1 -1
  223. package/dist/external-wiki-mcp-tools.d.ts +11 -11
  224. package/dist/extraction-error-classification.d.ts +1 -1
  225. package/dist/extraction-faithfulness.d.ts +1 -1
  226. package/dist/extraction-judge-telemetry.d.ts +1 -1
  227. package/dist/extraction-judge-training.d.ts +1 -1
  228. package/dist/extraction-judge.d.ts +1 -1
  229. package/dist/extraction-liveness.d.ts +1 -1
  230. package/dist/extraction-normalization.d.ts +1 -1
  231. package/dist/extraction-prompt.d.ts +1 -1
  232. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  233. package/dist/extraction-source-grounding.d.ts +1 -1
  234. package/dist/extraction.d.ts +1 -1
  235. package/dist/extraction.js +10 -10
  236. package/dist/fallback-llm.d.ts +1 -1
  237. package/dist/graph-dashboard-diff.d.ts +1 -1
  238. package/dist/graph-dashboard-key.d.ts +1 -1
  239. package/dist/graph-dashboard-parser.d.ts +1 -1
  240. package/dist/{graph-edge-decay-FXGELBFA.js → graph-edge-decay-A4SDFMMS.js} +4 -4
  241. package/dist/graph-edge-decay-A4SDFMMS.js.map +1 -0
  242. package/dist/graph-edge-reinforcement.d.ts +1 -1
  243. package/dist/graph-path-reconstruction.d.ts +1 -1
  244. package/dist/graph-path-scoring.d.ts +1 -1
  245. package/dist/graph-snapshot.d.ts +1 -1
  246. package/dist/graph-snapshot.js +3 -3
  247. package/dist/graph.d.ts +1 -1
  248. package/dist/graph.js +3 -3
  249. package/dist/harmonic-retrieval.js +1 -1
  250. package/dist/importance.d.ts +1 -1
  251. package/dist/importers/index.d.ts +1 -1
  252. package/dist/in-flight-reads.d.ts +1 -1
  253. package/dist/{index--QhGIXF2.d.ts → index-By2QUAMh.d.ts} +2 -2
  254. package/dist/index.d.ts +27 -23
  255. package/dist/index.js +199 -141
  256. package/dist/intent.d.ts +1 -1
  257. package/dist/lcm/engine.d.ts +1 -1
  258. package/dist/lcm/engine.js +4 -4
  259. package/dist/lcm/index.d.ts +1 -1
  260. package/dist/lcm/index.js +10 -10
  261. package/dist/lcm/tools.d.ts +1 -1
  262. package/dist/lifecycle.d.ts +1 -1
  263. package/dist/live-connectors-runner.d.ts +1 -1
  264. package/dist/local-llm.d.ts +1 -1
  265. package/dist/local-model-endpoint.d.ts +1 -1
  266. package/dist/location/index.d.ts +128 -1
  267. package/dist/location/index.js +60 -750
  268. package/dist/location/index.js.map +1 -1
  269. package/dist/maintenance/memory-governance.d.ts +1 -1
  270. package/dist/maintenance/memory-governance.js +8 -8
  271. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  272. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +8 -8
  273. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  274. package/dist/maintenance/rebuild-memory-projection.js +9 -9
  275. package/dist/{maintenance-PFvY1Pw_.d.ts → maintenance-Dm2McrIx.d.ts} +4 -3
  276. package/dist/mcp-memory-inspector-app.d.ts +11 -11
  277. package/dist/mcp-read-only-tools.js +1 -1
  278. package/dist/memory-action-policy.d.ts +1 -1
  279. package/dist/memory-cache.d.ts +1 -1
  280. package/dist/memory-controller.d.ts +203 -0
  281. package/dist/memory-controller.js +23 -0
  282. package/dist/memory-controller.js.map +1 -0
  283. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  284. package/dist/memory-projection-store.d.ts +1 -1
  285. package/dist/memory-provenance.d.ts +1 -1
  286. package/dist/memory-snapshot.d.ts +1 -1
  287. package/dist/memory-subject-cli.d.ts +11 -11
  288. package/dist/memory-subject.d.ts +11 -11
  289. package/dist/memory-worth-outcomes.d.ts +47 -3
  290. package/dist/memory-worth-outcomes.js +5 -3
  291. package/dist/models-json.d.ts +1 -1
  292. package/dist/namespaces/migrate.d.ts +3 -3
  293. package/dist/namespaces/migrate.js +9 -9
  294. package/dist/namespaces/principal.d.ts +1 -1
  295. package/dist/namespaces/search.d.ts +1 -1
  296. package/dist/namespaces/search.js +5 -5
  297. package/dist/namespaces/storage.d.ts +3 -3
  298. package/dist/namespaces/storage.js +8 -8
  299. package/dist/native-knowledge.d.ts +1 -1
  300. package/dist/offline-sync-impression-drain.d.ts +1 -1
  301. package/dist/operator-doctor-corpus.d.ts +1 -1
  302. package/dist/operator-doctor-corpus.js +11 -11
  303. package/dist/operator-doctor-replica.d.ts +1 -1
  304. package/dist/operator-toolkit.d.ts +3 -3
  305. package/dist/operator-toolkit.js +22 -22
  306. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  307. package/dist/orchestration/maintenance.d.ts +4 -4
  308. package/dist/orchestration/maintenance.js +16 -14
  309. package/dist/{orchestrator-4wzJrPVm.d.ts → orchestrator-Co1DyfuP.d.ts} +8 -8
  310. package/dist/orchestrator.d.ts +9 -9
  311. package/dist/orchestrator.js +110 -104
  312. package/dist/patterns-cli.d.ts +1 -1
  313. package/dist/{pipeline-CgXgdIrF.d.ts → pipeline-DotMnb6y.d.ts} +1 -1
  314. package/dist/policy-runtime.d.ts +1 -1
  315. package/dist/proactive-contention.d.ts +1 -1
  316. package/dist/provenance.d.ts +1 -1
  317. package/dist/{public-http-BP3VQDl5.d.ts → public-http-PJRtnSi-.d.ts} +1 -1
  318. package/dist/{qmd-BppGGxsi.d.ts → qmd-BP0n11fR.d.ts} +1 -1
  319. package/dist/qmd-preflight.d.ts +2 -2
  320. package/dist/qmd-recall-cache.d.ts +1 -1
  321. package/dist/qmd.d.ts +2 -2
  322. package/dist/recall-concurrency-config.d.ts +1 -1
  323. package/dist/recall-disclosure-escalation.d.ts +1 -1
  324. package/dist/recall-explain-renderer.d.ts +1 -1
  325. package/dist/recall-memory-map.d.ts +1 -1
  326. package/dist/recall-planner-llm.d.ts +1 -1
  327. package/dist/recall-state.d.ts +1 -1
  328. package/dist/recall-tag-filter.d.ts +1 -1
  329. package/dist/recall-timings.d.ts +1 -1
  330. package/dist/recall-xray-cli.d.ts +1 -1
  331. package/dist/recall-xray-renderer.d.ts +1 -1
  332. package/dist/recall-xray.d.ts +1 -1
  333. package/dist/reconcile/cursor.d.ts +1 -1
  334. package/dist/reconcile/manifest.d.ts +1 -1
  335. package/dist/reconcile/plan.d.ts +1 -1
  336. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  337. package/dist/replay/normalizers/claude.d.ts +1 -1
  338. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  339. package/dist/replay/normalizers/shared.d.ts +1 -1
  340. package/dist/replay/runner.d.ts +1 -1
  341. package/dist/replay/types.d.ts +1 -1
  342. package/dist/replica-divergence.d.ts +1 -1
  343. package/dist/replica-peers-config.d.ts +1 -1
  344. package/dist/resolve-auth-token.d.ts +1 -1
  345. package/dist/resume-bundles.js +5 -5
  346. package/dist/retrieval-agents.d.ts +2 -2
  347. package/dist/retrieval-tiers.d.ts +1 -1
  348. package/dist/routing/engine.d.ts +1 -1
  349. package/dist/routing/store.d.ts +1 -1
  350. package/dist/salvage-envelope.d.ts +1 -1
  351. package/dist/{scope-profiles-ChZUtxDU.d.ts → scope-profiles-6ChZKTy-.d.ts} +1 -1
  352. package/dist/search/embed-helper.d.ts +1 -1
  353. package/dist/search/factory.d.ts +1 -1
  354. package/dist/search/factory.js +4 -4
  355. package/dist/search/index.d.ts +1 -1
  356. package/dist/search/index.js +10 -10
  357. package/dist/search/lancedb-backend.d.ts +1 -1
  358. package/dist/search/meilisearch-backend.d.ts +1 -1
  359. package/dist/search/noop-backend.d.ts +1 -1
  360. package/dist/search/orama-backend.d.ts +1 -1
  361. package/dist/search/port.d.ts +1 -1
  362. package/dist/search/remote-backend.d.ts +1 -1
  363. package/dist/{semantic-consolidation-mSPwQSmF.d.ts → semantic-consolidation-DziYcW5J.d.ts} +1 -1
  364. package/dist/semantic-consolidation.d.ts +2 -2
  365. package/dist/semantic-consolidation.js +9 -9
  366. package/dist/semantic-rule-promotion.js +8 -8
  367. package/dist/semantic-rule-verifier.d.ts +1 -1
  368. package/dist/semantic-rule-verifier.js +8 -8
  369. package/dist/{service-BICWLwSP.d.ts → service-C7rIBuK_.d.ts} +2 -2
  370. package/dist/session-observer-bands.d.ts +1 -1
  371. package/dist/session-observer-state.d.ts +1 -1
  372. package/dist/shared-context/manager.d.ts +1 -1
  373. package/dist/signal.d.ts +1 -1
  374. package/dist/source-agent-qualifier.d.ts +1 -1
  375. package/dist/source-agent-qualifier.js +8 -8
  376. package/dist/{storage-B7urx1K3.d.ts → storage-B1hEx8Xg.d.ts} +1 -1
  377. package/dist/storage.d.ts +2 -2
  378. package/dist/storage.js +7 -7
  379. package/dist/subject-config.d.ts +1 -1
  380. package/dist/summarizer.d.ts +1 -1
  381. package/dist/summary-snapshot.d.ts +1 -1
  382. package/dist/support-passport/index.d.ts +14 -14
  383. package/dist/support-passport/index.js +29 -29
  384. package/dist/temporal-supersession.d.ts +2 -2
  385. package/dist/temporal-timeline-recall.d.ts +1 -1
  386. package/dist/temporal-validity.d.ts +1 -1
  387. package/dist/threading.d.ts +1 -1
  388. package/dist/tier-migration.d.ts +2 -2
  389. package/dist/tier-routing.d.ts +1 -1
  390. package/dist/topics.d.ts +1 -1
  391. package/dist/transcript.d.ts +1 -1
  392. package/dist/transfer/backup.js +2 -2
  393. package/dist/transfer/capsule-export.js +2 -2
  394. package/dist/transfer/capsule-import.js +2 -2
  395. package/dist/trust-score-stage.d.ts +1 -1
  396. package/dist/trust-score.d.ts +1 -1
  397. package/dist/{types-ETU5N6nB.d.ts → types-BHDNxGTT.d.ts} +1 -1
  398. package/dist/types.d.ts +1 -1
  399. package/dist/utility-runtime.d.ts +1 -1
  400. package/dist/verified-recall.js +8 -8
  401. package/dist/who-knows-cli.d.ts +11 -11
  402. package/dist/who-knows-cli.js +9 -9
  403. package/dist/who-knows.d.ts +11 -11
  404. package/dist/who-knows.js +8 -8
  405. package/dist/write-envelope.d.ts +1 -1
  406. package/package.json +2 -2
  407. package/src/access-boundary.ts +5 -0
  408. package/src/access-http.ts +15 -16
  409. package/src/access-mcp-output-schemas.ts +5 -0
  410. package/src/access-mcp.ts +6 -6
  411. package/src/access-operations.ts +2 -0
  412. package/src/access-surface-catalog.ts +10 -0
  413. package/src/eval-trajectory-contracts.ts +411 -0
  414. package/src/eval-trajectory-store.ts +306 -0
  415. package/src/eval-trajectory.test.ts +534 -0
  416. package/src/eval-trajectory.ts +773 -0
  417. package/src/index.ts +5 -0
  418. package/src/location/access-operations.ts +84 -0
  419. package/src/location/http-glue.test.ts +100 -0
  420. package/src/location/http-glue.ts +85 -0
  421. package/src/location/index.ts +3 -0
  422. package/src/location/mcp-tools.ts +82 -0
  423. package/src/location/provider-setup.test.ts +106 -0
  424. package/src/location/provider-setup.ts +103 -0
  425. package/src/location/scheduler.test.ts +113 -0
  426. package/src/location/scheduler.ts +98 -0
  427. package/src/location/surfaces.test.ts +241 -0
  428. package/src/location/surfaces.ts +329 -0
  429. package/src/maintenance/day-summary-cron.ts +45 -0
  430. package/src/mcp-read-only-tools.ts +2 -0
  431. package/src/memory-controller.test.ts +347 -0
  432. package/src/memory-controller.ts +547 -0
  433. package/src/memory-worth-outcomes.test.ts +53 -18
  434. package/src/memory-worth-outcomes.ts +91 -9
  435. package/src/orchestration/maintenance.ts +22 -30
  436. package/src/wearables/http-glue.ts +28 -0
  437. package/dist/chunk-4K7IW3F7.js.map +0 -1
  438. package/dist/chunk-BA2GLSIP.js.map +0 -1
  439. package/dist/chunk-CV3GNPOE.js.map +0 -1
  440. package/dist/chunk-FC7TIRFS.js.map +0 -1
  441. package/dist/chunk-KTPXXVDQ.js.map +0 -1
  442. package/dist/chunk-LDBFXD4F.js.map +0 -1
  443. package/dist/chunk-LYBIHM4N.js.map +0 -1
  444. package/dist/chunk-N56GVOWR.js.map +0 -1
  445. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → capsule-crypto-7FJQINUR.js.map} +0 -0
  446. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-2NLLXCJG.js.map} +0 -0
  447. /package/dist/{chunk-NZPFCP5A.js.map → chunk-2PSX5BJU.js.map} +0 -0
  448. /package/dist/{chunk-IIRCHGWD.js.map → chunk-3RI5Y7KU.js.map} +0 -0
  449. /package/dist/{chunk-H7BZBSP6.js.map → chunk-52II7PB6.js.map} +0 -0
  450. /package/dist/{chunk-J3ATBB7M.js.map → chunk-5DH6PG4B.js.map} +0 -0
  451. /package/dist/{chunk-M4AHBM72.js.map → chunk-5HERQ5FX.js.map} +0 -0
  452. /package/dist/{chunk-W675UJCZ.js.map → chunk-5HK3CJAR.js.map} +0 -0
  453. /package/dist/{chunk-2MVTAIL3.js.map → chunk-5S4LQOPE.js.map} +0 -0
  454. /package/dist/{chunk-OZDFB22S.js.map → chunk-5VPQSRQO.js.map} +0 -0
  455. /package/dist/{chunk-YZJM6CLF.js.map → chunk-6CPUQ5D6.js.map} +0 -0
  456. /package/dist/{chunk-2IXQSGCU.js.map → chunk-7F27PCSN.js.map} +0 -0
  457. /package/dist/{chunk-OWQNJJY2.js.map → chunk-7TCGNUVP.js.map} +0 -0
  458. /package/dist/{chunk-3NH3VP3U.js.map → chunk-7WR462EM.js.map} +0 -0
  459. /package/dist/{chunk-NH6LC57D.js.map → chunk-A32YEQAM.js.map} +0 -0
  460. /package/dist/{chunk-HF5BUTI6.js.map → chunk-ACOC27BB.js.map} +0 -0
  461. /package/dist/{chunk-THVI4Y7X.js.map → chunk-BJTHRFFC.js.map} +0 -0
  462. /package/dist/{chunk-BW4GAF57.js.map → chunk-CFGU52XJ.js.map} +0 -0
  463. /package/dist/{chunk-DPNXADEI.js.map → chunk-D4QVPP3G.js.map} +0 -0
  464. /package/dist/{chunk-BK5G2MHO.js.map → chunk-EOHKUWXW.js.map} +0 -0
  465. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  466. /package/dist/{chunk-ZK4BFABK.js.map → chunk-F635GAL7.js.map} +0 -0
  467. /package/dist/{chunk-IURMJBGP.js.map → chunk-F6QHHRWP.js.map} +0 -0
  468. /package/dist/{chunk-TJFI3K2O.js.map → chunk-GEPACVWN.js.map} +0 -0
  469. /package/dist/{chunk-PP7R754B.js.map → chunk-GPFZFCRN.js.map} +0 -0
  470. /package/dist/{chunk-UCKG36HO.js.map → chunk-GTSVEEP3.js.map} +0 -0
  471. /package/dist/{chunk-DPGH6LHQ.js.map → chunk-I7EX6KSH.js.map} +0 -0
  472. /package/dist/{chunk-JPAKBNTM.js.map → chunk-IP4ZNT4U.js.map} +0 -0
  473. /package/dist/{chunk-AXGFOFNY.js.map → chunk-IY7UXD3J.js.map} +0 -0
  474. /package/dist/{chunk-YHCBJULX.js.map → chunk-JAQXUGLN.js.map} +0 -0
  475. /package/dist/{chunk-RKNJBZ55.js.map → chunk-JBPKEARU.js.map} +0 -0
  476. /package/dist/{chunk-VDX2J7OX.js.map → chunk-KQAFEZQX.js.map} +0 -0
  477. /package/dist/{chunk-D2YNNDML.js.map → chunk-KWIGDKM2.js.map} +0 -0
  478. /package/dist/{chunk-YB4GBWBU.js.map → chunk-LLQCM2U2.js.map} +0 -0
  479. /package/dist/{chunk-OLBZ2WGG.js.map → chunk-LTBKKSCX.js.map} +0 -0
  480. /package/dist/{chunk-DORFF5N5.js.map → chunk-NG3MBQV4.js.map} +0 -0
  481. /package/dist/{chunk-DUEDOYZD.js.map → chunk-OPGL46PX.js.map} +0 -0
  482. /package/dist/{chunk-OUKBMQ2O.js.map → chunk-PD66CVSD.js.map} +0 -0
  483. /package/dist/{chunk-CQBIN77D.js.map → chunk-PDDSFELN.js.map} +0 -0
  484. /package/dist/{chunk-6433HV72.js.map → chunk-PMVPCZJZ.js.map} +0 -0
  485. /package/dist/{chunk-DJZWNKFO.js.map → chunk-RGCF4XNH.js.map} +0 -0
  486. /package/dist/{chunk-4JSF7UUP.js.map → chunk-S3K2CIK5.js.map} +0 -0
  487. /package/dist/{chunk-OCCHUEZB.js.map → chunk-SEA6M7SS.js.map} +0 -0
  488. /package/dist/{chunk-KOO37E4Y.js.map → chunk-SVVIASVX.js.map} +0 -0
  489. /package/dist/{chunk-FBR7PIL4.js.map → chunk-VKCAHCBI.js.map} +0 -0
  490. /package/dist/{chunk-WDXD6ITO.js.map → chunk-VXVZ2GM3.js.map} +0 -0
  491. /package/dist/{chunk-DUZARALI.js.map → chunk-WTOZBZNN.js.map} +0 -0
  492. /package/dist/{chunk-DQEMWVMT.js.map → chunk-X7Y7WX73.js.map} +0 -0
  493. /package/dist/{chunk-2EPOGPKO.js.map → chunk-YKWFK7XA.js.map} +0 -0
  494. /package/dist/{chunk-BIJAWZYW.js.map → chunk-YMOPYG3K.js.map} +0 -0
  495. /package/dist/{chunk-UFR6HX7A.js.map → chunk-YRVAKONL.js.map} +0 -0
  496. /package/dist/{chunk-ECLJ4LA2.js.map → chunk-YWSQD2IB.js.map} +0 -0
  497. /package/dist/{chunk-NLEH4RTB.js.map → chunk-Z4U3UN56.js.map} +0 -0
  498. /package/dist/{chunk-YDKF4MSJ.js.map → chunk-ZAOHJDKH.js.map} +0 -0
  499. /package/dist/{chunk-KFIOPZ25.js.map → chunk-ZIJDI4CP.js.map} +0 -0
  500. /package/dist/{graph-edge-decay-FXGELBFA.js.map → eval-trajectory-contracts.js.map} +0 -0
@@ -0,0 +1,547 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { planRecallMode } from "./intent.js";
3
+ import { evaluateMemoryActionPolicy } from "./memory-action-policy.js";
4
+ import type { RuntimePolicyValues } from "./policy-runtime.js";
5
+ import type { UtilityRuntimeValues } from "./utility-runtime.js";
6
+ import type { MemoryActionEligibilityContext, MemoryActionType, RecallPlanMode } from "./types.js";
7
+
8
+ /**
9
+ * Gated unified memory controller (#2348).
10
+ *
11
+ * One state enters, one choice leaves. Host-free: every effectful collaborator
12
+ * (adapters, executors, report reader, recorder, telemetry, clock) is injected.
13
+ * The coordinator creates no store and claims no counterfactual lift.
14
+ */
15
+
16
+ export type MemoryControllerMode = "off" | "shadow" | "active";
17
+
18
+ export type MemoryControllerActionFamily = "persistent_memory" | "recall" | "active_context" | "no_op";
19
+
20
+ /** #2347 adapter seam: the host supplies plans, core only picks one. */
21
+ export interface ActiveContextMessage {
22
+ id: string;
23
+ text: string;
24
+ }
25
+
26
+ export interface ActiveContextPlan {
27
+ transform: "SUMMARY" | "FILTER";
28
+ messageIds: string[];
29
+ planId: string;
30
+ }
31
+
32
+ export interface ActiveContextAdapter {
33
+ plan(messages: ActiveContextMessage[]): ActiveContextPlan | null;
34
+ }
35
+
36
+ /** #2345 report + #2346 paired-seed evidence, read through one port. */
37
+ export interface MemoryControllerEvidenceReport {
38
+ status: "pass" | "fail";
39
+ version: string;
40
+ configHash: string;
41
+ generatedAt: string;
42
+ /** sha256 over the canonical report fields; recomputed on verification. */
43
+ reportHash: string;
44
+ }
45
+
46
+ export interface MemoryControllerPairedSeedEvidence {
47
+ status: "pass" | "fail";
48
+ seedCount: number;
49
+ generatedAt: string;
50
+ }
51
+
52
+ export interface MemoryControllerEvidence {
53
+ report: MemoryControllerEvidenceReport;
54
+ pairedSeed: MemoryControllerPairedSeedEvidence;
55
+ }
56
+
57
+ export interface MemoryControllerReportReader {
58
+ read(): Promise<MemoryControllerEvidence | null>;
59
+ }
60
+
61
+ export interface MemoryControllerReceipt {
62
+ decisionId: string;
63
+ ok: boolean;
64
+ detail?: string;
65
+ }
66
+
67
+ export interface MemoryControllerExecutors {
68
+ executePersistentMemory?(input: {
69
+ decisionId: string;
70
+ action: MemoryActionType;
71
+ eligibility: MemoryActionEligibilityContext;
72
+ stateHash: string;
73
+ }): Promise<MemoryControllerReceipt>;
74
+ executeRecall?(input: { decisionId: string; mode: RecallPlanMode }): Promise<MemoryControllerReceipt>;
75
+ executeActiveContext?(input: {
76
+ decisionId: string;
77
+ plan: ActiveContextPlan;
78
+ }): Promise<MemoryControllerReceipt>;
79
+ }
80
+
81
+ export interface MemoryControllerEvent {
82
+ schemaVersion: 1;
83
+ phase: "choice" | "outcome";
84
+ decisionId: string;
85
+ timestamp: string;
86
+ requestedMode: MemoryControllerMode;
87
+ effectiveMode: MemoryControllerMode;
88
+ stateHash: string;
89
+ choice: MemoryControllerChoice;
90
+ scores: Record<MemoryControllerActionFamily, number>;
91
+ executed: boolean;
92
+ reviewOnly?: boolean;
93
+ demotionReasons?: string[];
94
+ failureClass?: "record_failed" | "executor_error" | "bad_receipt" | "no_executor";
95
+ receipt?: MemoryControllerReceipt;
96
+ }
97
+
98
+ export interface MemoryControllerRecorder {
99
+ record(event: MemoryControllerEvent): Promise<void>;
100
+ /** Prior shadow choice records; active promotion requires shadow history. */
101
+ countShadowRecords(): Promise<number>;
102
+ }
103
+
104
+ export interface MemoryControllerConfig {
105
+ mode: MemoryControllerMode;
106
+ /** Expected #2345 report schema version. */
107
+ reportVersion: string;
108
+ /** Evidence older than this is stale and forces shadow. */
109
+ evidenceMaxAgeMs: number;
110
+ /** Paired-seed arms must cover at least this many seeds (#2346). */
111
+ minPairedSeeds: number;
112
+ /** Active promotion requires at least this many prior shadow records. */
113
+ shadowMinRecords: number;
114
+ }
115
+
116
+ export interface MemoryControllerState {
117
+ prompt: string;
118
+ persistentMemoryCandidate?: {
119
+ action: MemoryActionType;
120
+ eligibility: MemoryActionEligibilityContext;
121
+ };
122
+ contextMessages?: ActiveContextMessage[];
123
+ /** 0..1 host-measured context pressure. */
124
+ contextPressure?: number;
125
+ }
126
+
127
+ export type MemoryControllerChoice =
128
+ | { family: "persistent_memory"; action: MemoryActionType; eligibility: MemoryActionEligibilityContext }
129
+ | { family: "recall"; mode: RecallPlanMode }
130
+ | { family: "active_context"; plan: ActiveContextPlan }
131
+ | { family: "no_op" };
132
+
133
+ export interface MemoryControllerRunResult {
134
+ decisionId: string;
135
+ requestedMode: MemoryControllerMode;
136
+ effectiveMode: MemoryControllerMode;
137
+ stateHash: string;
138
+ choice: MemoryControllerChoice;
139
+ scores: Record<MemoryControllerActionFamily, number>;
140
+ executed: boolean;
141
+ reviewOnly: boolean;
142
+ recorded: boolean;
143
+ receipt?: MemoryControllerReceipt;
144
+ demotionReasons: string[];
145
+ }
146
+
147
+ export interface MemoryControllerDeps {
148
+ config: MemoryControllerConfig;
149
+ reportReader?: MemoryControllerReportReader;
150
+ recorder?: MemoryControllerRecorder;
151
+ executors?: MemoryControllerExecutors;
152
+ activeContextAdapter?: ActiveContextAdapter;
153
+ policyRuntime?: { loadRuntimeValues(): Promise<RuntimePolicyValues | null> };
154
+ readUtilityRuntime?: () => Promise<UtilityRuntimeValues | null>;
155
+ telemetry?: (event: MemoryControllerEvent) => void;
156
+ clock?: () => Date;
157
+ }
158
+
159
+ const NO_OP_FLOOR = 0.35;
160
+ /** `discard` (and any destructive change) stays review-only in active mode. */
161
+ const REVIEW_ONLY_ACTIONS: Partial<Record<MemoryActionType, true>> = { discard: true };
162
+
163
+ export function controllerConfigHash(config: MemoryControllerConfig): string {
164
+ return sha256(
165
+ JSON.stringify({
166
+ mode: config.mode,
167
+ reportVersion: config.reportVersion,
168
+ evidenceMaxAgeMs: config.evidenceMaxAgeMs,
169
+ minPairedSeeds: config.minPairedSeeds,
170
+ shadowMinRecords: config.shadowMinRecords,
171
+ })
172
+ );
173
+ }
174
+
175
+ export function hashControllerState(state: MemoryControllerState): string {
176
+ return sha256(
177
+ JSON.stringify({
178
+ prompt: state.prompt,
179
+ persistentMemoryCandidate: state.persistentMemoryCandidate ?? null,
180
+ contextMessages: state.contextMessages ?? null,
181
+ contextPressure: state.contextPressure ?? null,
182
+ })
183
+ );
184
+ }
185
+
186
+ /** Canonical #2345 report hash; producers sign with this, the controller verifies. */
187
+ export function computeEvidenceReportHash(fields: {
188
+ status: MemoryControllerEvidenceReport["status"];
189
+ version: string;
190
+ configHash: string;
191
+ generatedAt: string;
192
+ }): string {
193
+ return sha256(JSON.stringify(fields));
194
+ }
195
+
196
+ /** Verifies the #2345 report hash over its canonical fields. */
197
+ export function verifyEvidenceReport(report: MemoryControllerEvidenceReport): boolean {
198
+ return (
199
+ computeEvidenceReportHash({
200
+ status: report.status,
201
+ version: report.version,
202
+ configHash: report.configHash,
203
+ generatedAt: report.generatedAt,
204
+ }) === report.reportHash
205
+ );
206
+ }
207
+
208
+ function sha256(input: string): string {
209
+ return createHash("sha256").update(input).digest("hex");
210
+ }
211
+
212
+ function clampScore(value: number): number {
213
+ if (!Number.isFinite(value)) return Number.NaN;
214
+ return Math.max(0, Math.min(1, value));
215
+ }
216
+
217
+ /**
218
+ * Bad scores fail closed to `no_op`.
219
+ */
220
+ export function chooseAction(input: {
221
+ state: MemoryControllerState;
222
+ activeContextAdapter?: ActiveContextAdapter;
223
+ runtimeValues?: RuntimePolicyValues | null;
224
+ utilityValues?: UtilityRuntimeValues | null;
225
+ }): { choice: MemoryControllerChoice; scores: Record<MemoryControllerActionFamily, number> } {
226
+ const { state, activeContextAdapter, runtimeValues, utilityValues } = input;
227
+
228
+ // recall: current recall path.
229
+ const recallMode = planRecallMode(state.prompt ?? "");
230
+ const recallScore =
231
+ recallMode === "no_recall" ? 0 : recallMode === "minimal" ? 0.4 : 0.6 + 0.2 * (runtimeValues?.recencyWeight ?? 0);
232
+
233
+ // persistent_memory: current action path + policy.
234
+ let persistentScore = 0;
235
+ const candidate = state.persistentMemoryCandidate;
236
+ if (candidate) {
237
+ const policy = evaluateMemoryActionPolicy({
238
+ action: candidate.action,
239
+ eligibility: candidate.eligibility,
240
+ options: { actionsEnabled: true, maxCompressionTokensPerHour: Number.POSITIVE_INFINITY },
241
+ });
242
+ if (policy.decision === "allow") {
243
+ persistentScore = 0.4 + 0.4 * (candidate.eligibility.confidence ?? 0);
244
+ } else if (policy.decision === "defer") {
245
+ persistentScore = 0.2;
246
+ }
247
+ // Utility runtime may suppress the persistent family.
248
+ if (utilityValues && utilityValues.rankingSuppressMultiplier > 1) {
249
+ persistentScore *= 1 / utilityValues.rankingSuppressMultiplier;
250
+ }
251
+ }
252
+
253
+ // active_context: current context path through the #2347 adapter.
254
+ let contextScore = 0;
255
+ let contextPlan: ActiveContextPlan | null = null;
256
+ const pressure = state.contextPressure;
257
+ if (activeContextAdapter && typeof pressure === "number" && Number.isFinite(pressure) && pressure > 0.5) {
258
+ contextPlan = activeContextAdapter.plan(state.contextMessages ?? []);
259
+ if (contextPlan && contextPlan.messageIds.length > 0) {
260
+ contextScore = 0.3 + 0.5 * Math.max(0, Math.min(1, pressure));
261
+ }
262
+ }
263
+
264
+ const scores: Record<MemoryControllerActionFamily, number> = {
265
+ recall: clampScore(recallScore),
266
+ persistent_memory: clampScore(persistentScore),
267
+ active_context: clampScore(contextScore),
268
+ no_op: NO_OP_FLOOR,
269
+ };
270
+
271
+ // Bad scores fail closed.
272
+ if (Object.values(scores).some((score) => !Number.isFinite(score) || score < 0 || score > 1)) {
273
+ return { choice: { family: "no_op" }, scores };
274
+ }
275
+
276
+ let choice: MemoryControllerChoice = { family: "no_op" };
277
+ let best = scores.no_op;
278
+ if (scores.recall > best) {
279
+ best = scores.recall;
280
+ choice = { family: "recall", mode: recallMode };
281
+ }
282
+ if (scores.persistent_memory > best) {
283
+ best = scores.persistent_memory;
284
+ choice = {
285
+ family: "persistent_memory",
286
+ action: candidate!.action,
287
+ eligibility: candidate!.eligibility,
288
+ };
289
+ }
290
+ if (scores.active_context > best) {
291
+ choice = { family: "active_context", plan: contextPlan! };
292
+ }
293
+ return { choice, scores };
294
+ }
295
+
296
+ /** Returns the demotion reasons when active-mode gates fail; empty means go. */
297
+ export async function evaluateActiveGates(input: {
298
+ config: MemoryControllerConfig;
299
+ reportReader?: MemoryControllerReportReader;
300
+ recorder?: MemoryControllerRecorder;
301
+ consecutiveReceiptFailures: number;
302
+ now: Date;
303
+ }): Promise<string[]> {
304
+ const { config, reportReader, recorder, consecutiveReceiptFailures, now } = input;
305
+ const reasons: string[] = [];
306
+
307
+ if (!reportReader) return ["no_report_reader"];
308
+
309
+ const evidence = await reportReader.read();
310
+ if (!evidence) return ["no_evidence"];
311
+
312
+ const { report, pairedSeed } = evidence;
313
+ if (report.status !== "pass") reasons.push("report_not_passing");
314
+ if (report.version !== config.reportVersion) reasons.push("report_version_mismatch");
315
+ if (report.configHash !== controllerConfigHash(config)) reasons.push("report_config_unbound");
316
+ if (!verifyEvidenceReport(report)) reasons.push("report_hash_invalid");
317
+ const reportGeneratedAt = Date.parse(report.generatedAt);
318
+ if (!Number.isFinite(reportGeneratedAt) || now.getTime() - reportGeneratedAt > config.evidenceMaxAgeMs) {
319
+ reasons.push("report_stale");
320
+ }
321
+
322
+ if (pairedSeed.status !== "pass") reasons.push("paired_seed_not_passing");
323
+ if (pairedSeed.seedCount < config.minPairedSeeds) reasons.push("paired_seed_count_low");
324
+ const seedGeneratedAt = Date.parse(pairedSeed.generatedAt);
325
+ if (!Number.isFinite(seedGeneratedAt) || now.getTime() - seedGeneratedAt > config.evidenceMaxAgeMs) {
326
+ reasons.push("paired_seed_stale");
327
+ }
328
+
329
+ const shadowRecords = recorder ? await recorder.countShadowRecords() : 0;
330
+ if (shadowRecords < config.shadowMinRecords) reasons.push("shadow_history_insufficient");
331
+
332
+ if (consecutiveReceiptFailures > 0) reasons.push("recent_receipt_failures");
333
+
334
+ return reasons;
335
+ }
336
+
337
+ export class MemoryControllerCoordinator {
338
+ private readonly deps: MemoryControllerDeps;
339
+ private readonly clock: () => Date;
340
+ private consecutiveReceiptFailures = 0;
341
+
342
+ constructor(deps: MemoryControllerDeps) {
343
+ this.deps = deps;
344
+ this.clock = deps.clock ?? (() => new Date());
345
+ }
346
+
347
+ async run(state: MemoryControllerState): Promise<MemoryControllerRunResult> {
348
+ const decisionId = randomUUID();
349
+ const stateHash = hashControllerState(state);
350
+ const requestedMode = this.deps.config.mode;
351
+
352
+ // off: no choice, no read, no write, no call.
353
+ if (requestedMode === "off") {
354
+ return {
355
+ decisionId,
356
+ requestedMode,
357
+ effectiveMode: "off",
358
+ stateHash,
359
+ choice: { family: "no_op" },
360
+ scores: { persistent_memory: 0, recall: 0, active_context: 0, no_op: 0 },
361
+ executed: false,
362
+ reviewOnly: false,
363
+ recorded: false,
364
+ demotionReasons: ["mode_off"],
365
+ };
366
+ }
367
+
368
+ const [runtimeValues, utilityValues] = await Promise.all([
369
+ this.deps.policyRuntime?.loadRuntimeValues() ?? null,
370
+ this.deps.readUtilityRuntime?.() ?? null,
371
+ ]);
372
+ const { choice, scores } = chooseAction({
373
+ state,
374
+ activeContextAdapter: this.deps.activeContextAdapter,
375
+ runtimeValues,
376
+ utilityValues,
377
+ });
378
+
379
+ let demotionReasons: string[] = [];
380
+ let effectiveMode = requestedMode;
381
+ if (requestedMode === "active") {
382
+ demotionReasons = await evaluateActiveGates({
383
+ config: this.deps.config,
384
+ reportReader: this.deps.reportReader,
385
+ recorder: this.deps.recorder,
386
+ consecutiveReceiptFailures: this.consecutiveReceiptFailures,
387
+ now: this.clock(),
388
+ });
389
+ if (demotionReasons.length > 0) effectiveMode = "shadow";
390
+ }
391
+
392
+ const baseEvent: MemoryControllerEvent = {
393
+ schemaVersion: 1,
394
+ phase: "choice",
395
+ decisionId,
396
+ timestamp: this.clock().toISOString(),
397
+ requestedMode,
398
+ effectiveMode,
399
+ stateHash,
400
+ choice,
401
+ scores,
402
+ executed: false,
403
+ ...(demotionReasons.length > 0 ? { demotionReasons } : {}),
404
+ };
405
+
406
+ // Shadow records before any active dispatch.
407
+ let recorded = false;
408
+ if (this.deps.recorder) {
409
+ try {
410
+ await this.deps.recorder.record(baseEvent);
411
+ this.deps.telemetry?.(baseEvent);
412
+ recorded = true;
413
+ } catch {
414
+ // Bad recorder stops work: no dispatch, no outcome event.
415
+ return {
416
+ decisionId,
417
+ requestedMode,
418
+ effectiveMode,
419
+ stateHash,
420
+ choice,
421
+ scores,
422
+ executed: false,
423
+ reviewOnly: false,
424
+ recorded: false,
425
+ demotionReasons: [...demotionReasons, "record_failed"],
426
+ };
427
+ }
428
+ }
429
+
430
+ if (effectiveMode !== "active") {
431
+ return {
432
+ decisionId,
433
+ requestedMode,
434
+ effectiveMode,
435
+ stateHash,
436
+ choice,
437
+ scores,
438
+ executed: false,
439
+ reviewOnly: false,
440
+ recorded,
441
+ demotionReasons,
442
+ };
443
+ }
444
+
445
+ // First active scope: reversible actions only.
446
+ if (choice.family === "persistent_memory" && REVIEW_ONLY_ACTIONS[choice.action]) {
447
+ const event: MemoryControllerEvent = {
448
+ ...baseEvent,
449
+ phase: "outcome",
450
+ reviewOnly: true,
451
+ demotionReasons: ["review_only_action"],
452
+ };
453
+ await this.recordOutcome(event);
454
+ return {
455
+ decisionId,
456
+ requestedMode,
457
+ effectiveMode,
458
+ stateHash,
459
+ choice,
460
+ scores,
461
+ executed: false,
462
+ reviewOnly: true,
463
+ recorded,
464
+ demotionReasons,
465
+ };
466
+ }
467
+
468
+ const receipt = await this.dispatch(choice, stateHash, decisionId, baseEvent);
469
+ return {
470
+ decisionId,
471
+ requestedMode,
472
+ effectiveMode,
473
+ stateHash,
474
+ choice,
475
+ scores,
476
+ executed: receipt?.ok === true,
477
+ reviewOnly: false,
478
+ recorded,
479
+ ...(receipt ? { receipt } : {}),
480
+ demotionReasons,
481
+ };
482
+ }
483
+
484
+ private async dispatch(
485
+ choice: MemoryControllerChoice,
486
+ stateHash: string,
487
+ decisionId: string,
488
+ baseEvent: MemoryControllerEvent
489
+ ): Promise<MemoryControllerReceipt | undefined> {
490
+ const executors = this.deps.executors ?? {};
491
+ try {
492
+ let receipt: MemoryControllerReceipt | undefined;
493
+ if (choice.family === "persistent_memory") {
494
+ if (!executors.executePersistentMemory) throw new Error("no_executor:persistent_memory");
495
+ receipt = await executors.executePersistentMemory({
496
+ decisionId,
497
+ action: choice.action,
498
+ eligibility: choice.eligibility,
499
+ stateHash,
500
+ });
501
+ } else if (choice.family === "recall") {
502
+ if (!executors.executeRecall) throw new Error("no_executor:recall");
503
+ receipt = await executors.executeRecall({ decisionId, mode: choice.mode });
504
+ } else if (choice.family === "active_context") {
505
+ if (!executors.executeActiveContext) throw new Error("no_executor:active_context");
506
+ receipt = await executors.executeActiveContext({ decisionId, plan: choice.plan });
507
+ } else {
508
+ // no_op executed trivially; no executor call.
509
+ receipt = { decisionId, ok: true };
510
+ }
511
+ if (!isValidReceipt(receipt, decisionId)) {
512
+ this.consecutiveReceiptFailures += 1;
513
+ await this.recordOutcome({ ...baseEvent, phase: "outcome", failureClass: "bad_receipt" });
514
+ return undefined;
515
+ }
516
+ this.consecutiveReceiptFailures = 0;
517
+ await this.recordOutcome({ ...baseEvent, phase: "outcome", executed: receipt.ok, receipt });
518
+ return receipt;
519
+ } catch (error) {
520
+ this.consecutiveReceiptFailures += 1;
521
+ await this.recordOutcome({
522
+ ...baseEvent,
523
+ phase: "outcome",
524
+ failureClass: (error as Error)?.message?.startsWith("no_executor:") ? "no_executor" : "executor_error",
525
+ });
526
+ return undefined;
527
+ }
528
+ }
529
+
530
+ private async recordOutcome(event: MemoryControllerEvent): Promise<void> {
531
+ if (!this.deps.recorder) return;
532
+ await this.deps.recorder.record(event);
533
+ this.deps.telemetry?.(event);
534
+ }
535
+ }
536
+
537
+ function isValidReceipt(receipt: unknown, decisionId: string): boolean {
538
+ return (
539
+ typeof receipt === "object" &&
540
+ receipt !== null &&
541
+ (receipt as MemoryControllerReceipt).decisionId === decisionId &&
542
+ typeof (receipt as MemoryControllerReceipt).ok === "boolean"
543
+ );
544
+ }
545
+
546
+ // ponytail: consecutiveReceiptFailures is per-instance, not persisted; persist
547
+ // with the recorder if coordinator restarts must carry receipt health forward.
@@ -1,14 +1,15 @@
1
- import test from "node:test";
2
1
  import assert from "node:assert/strict";
2
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
- import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
5
+ import test from "node:test";
6
6
 
7
- import { StorageManager } from "./storage.js";
8
7
  import {
9
- recordMemoryOutcome,
10
8
  memoryWorthOutcomeEligibleCategories,
9
+ recordMemoryOutcome,
10
+ toMemoryOutcomeObservation,
11
11
  } from "./memory-worth-outcomes.js";
12
+ import { StorageManager } from "./storage.js";
12
13
 
13
14
  /**
14
15
  * Issue #560 PR 3 — tests for the outcome signal pipeline.
@@ -27,7 +28,7 @@ import {
27
28
  async function writeFactFile(
28
29
  storage: StorageManager,
29
30
  body: string,
30
- extraFrontmatterLines: string[] = [],
31
+ extraFrontmatterLines: string[] = []
31
32
  ): Promise<{ id: string; filePath: string }> {
32
33
  const today = new Date().toISOString().slice(0, 10);
33
34
  const id = `fact-${Date.now()}-${Math.random().toString(36).slice(2)}`;
@@ -51,10 +52,7 @@ async function writeFactFile(
51
52
  return { id, filePath };
52
53
  }
53
54
 
54
- async function writeCorrectionFile(
55
- storage: StorageManager,
56
- body: string,
57
- ): Promise<{ id: string; filePath: string }> {
55
+ async function writeCorrectionFile(storage: StorageManager, body: string): Promise<{ id: string; filePath: string }> {
58
56
  const id = `correction-${Date.now()}-${Math.random().toString(36).slice(2)}`;
59
57
  const lines = [
60
58
  "---",
@@ -68,10 +66,7 @@ async function writeCorrectionFile(
68
66
  "tags: []",
69
67
  "---",
70
68
  ];
71
- const correctionsDir = path.join(
72
- (storage as unknown as { baseDir: string }).baseDir,
73
- "corrections",
74
- );
69
+ const correctionsDir = path.join((storage as unknown as { baseDir: string }).baseDir, "corrections");
75
70
  await mkdir(correctionsDir, { recursive: true });
76
71
  const filePath = path.join(correctionsDir, `${id}.md`);
77
72
  await writeFile(filePath, `${lines.join("\n")}\n\n${body}\n`, "utf-8");
@@ -140,10 +135,7 @@ test("consecutive outcomes accumulate independently", async () => {
140
135
  try {
141
136
  const storage = new StorageManager(dir);
142
137
  await storage.ensureDirectories();
143
- const { id, filePath } = await writeFactFile(storage, "Accumulating outcomes.", [
144
- "mw_success: 2",
145
- "mw_fail: 0",
146
- ]);
138
+ const { id, filePath } = await writeFactFile(storage, "Accumulating outcomes.", ["mw_success: 2", "mw_fail: 0"]);
147
139
 
148
140
  await recordMemoryOutcome(storage, { memoryPath: filePath, outcome: "success" });
149
141
  await recordMemoryOutcome(storage, { memoryPath: filePath, outcome: "failure" });
@@ -289,7 +281,7 @@ test("concurrent outcomes for the same memory do NOT lose updates", async () =>
289
281
 
290
282
  const N = 10;
291
283
  const calls = Array.from({ length: N }, () =>
292
- recordMemoryOutcome(storage, { memoryPath: filePath, outcome: "success" }),
284
+ recordMemoryOutcome(storage, { memoryPath: filePath, outcome: "success" })
293
285
  );
294
286
  const results = await Promise.all(calls);
295
287
 
@@ -318,3 +310,46 @@ test("eligible-category set is exactly {fact, procedure}", () => {
318
310
  assert.ok(eligible.has("fact"));
319
311
  assert.ok(eligible.has("procedure"));
320
312
  });
313
+
314
+ // ---------------------------------------------------------------------------
315
+ // Issue #2345 — pure MemoryOutcomeObservation view (no writes, no counters)
316
+ // ---------------------------------------------------------------------------
317
+
318
+ test("outcome facts with time and join data become observations", () => {
319
+ const view = toMemoryOutcomeObservation({
320
+ memoryId: "fact-1",
321
+ namespace: "test-ns",
322
+ outcome: "success",
323
+ observedAt: "2026-08-12T00:00:00.000Z",
324
+ joinId: "act-1",
325
+ });
326
+ assert.equal(view.status, "observed");
327
+ if (view.status === "observed") {
328
+ assert.equal(view.observation.schemaVersion, 1);
329
+ assert.equal(view.observation.observedAt, "2026-08-12T00:00:00.000Z");
330
+ assert.equal(view.observation.joinId, "act-1");
331
+ // Round-trips through public types (undefined optionals drop in JSON).
332
+ const roundTripped = JSON.parse(JSON.stringify(view.observation)) as Record<string, unknown>;
333
+ assert.equal(roundTripped.schemaVersion, 1);
334
+ assert.equal(roundTripped.memoryId, "fact-1");
335
+ assert.equal(roundTripped.joinId, "act-1");
336
+ }
337
+ });
338
+
339
+ test("counter-only rows stay missing_observation and never guess an action", () => {
340
+ const noTime = toMemoryOutcomeObservation({
341
+ memoryId: "fact-1",
342
+ namespace: "test-ns",
343
+ outcome: "success",
344
+ joinId: "act-1",
345
+ });
346
+ assert.deepEqual(noTime, { status: "missing_observation", memoryId: "fact-1", reason: "missing_observed_at" });
347
+
348
+ const noJoin = toMemoryOutcomeObservation({
349
+ memoryId: "fact-2",
350
+ namespace: "test-ns",
351
+ outcome: "failure",
352
+ observedAt: new Date("2026-08-12T00:00:00.000Z"),
353
+ });
354
+ assert.deepEqual(noJoin, { status: "missing_observation", memoryId: "fact-2", reason: "missing_join_data" });
355
+ });