@remnic/core 10.0.169 → 10.0.171

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 (360) hide show
  1. package/dist/access-admin-ops-surface.js +124 -123
  2. package/dist/access-cli.js +124 -123
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +8 -8
  5. package/dist/access-extraction-force-flush-preempt.js +124 -123
  6. package/dist/access-extraction-force-flush.js +124 -123
  7. package/dist/access-http-briefing.js +124 -123
  8. package/dist/access-http-query.js +124 -123
  9. package/dist/access-http.js +124 -123
  10. package/dist/access-identity-continuity-surface.js +124 -123
  11. package/dist/access-lcm-surface.js +124 -123
  12. package/dist/access-mcp.js +124 -123
  13. package/dist/access-observe-write-category.js +8 -8
  14. package/dist/access-observe-write-surface.js +124 -123
  15. package/dist/access-offline-manifest.js +5 -5
  16. package/dist/access-operations-batch.js +124 -123
  17. package/dist/access-operations.js +124 -123
  18. package/dist/access-recall-concurrency.js +124 -123
  19. package/dist/access-recall-diagnostics.js +2 -2
  20. package/dist/access-recall-response.js +124 -123
  21. package/dist/access-recall-surface.d.ts.map +1 -1
  22. package/dist/access-recall-surface.js +124 -123
  23. package/dist/access-schema.js +7 -7
  24. package/dist/access-service.js +124 -123
  25. package/dist/active-recall.js +21 -20
  26. package/dist/active-recall.js.map +1 -1
  27. package/dist/adapters/index.js +4 -4
  28. package/dist/adapters/registry.js +2 -2
  29. package/dist/behavior-learner.js +1 -1
  30. package/dist/briefing.js +13 -13
  31. package/dist/buffer.js +6 -6
  32. package/dist/causal-behavior.js +2 -2
  33. package/dist/causal-chain.js +2 -2
  34. package/dist/causal-consolidation.js +16 -16
  35. package/dist/causal-retrieval.js +2 -2
  36. package/dist/causal-trajectory-graph.js +2 -2
  37. package/dist/causal-trajectory.js +1 -1
  38. package/dist/chat/chat-engine.d.ts +5 -3
  39. package/dist/chat/chat-engine.d.ts.map +1 -1
  40. package/dist/chat/chat-executor.d.ts +3 -4
  41. package/dist/chat/chat-executor.d.ts.map +1 -1
  42. package/dist/{chunk-FHWX2REL.js → chunk-2OAFPBQB.js} +2 -2
  43. package/dist/{chunk-5IZL4DCV.js → chunk-4DF5LMBJ.js} +2 -2
  44. package/dist/{chunk-FWTGO4NE.js → chunk-4DLGKTM6.js} +2 -2
  45. package/dist/{chunk-D6YCETHG.js → chunk-4E2Z44CV.js} +2 -2
  46. package/dist/{chunk-W4EJMMPP.js → chunk-4LVQSHHN.js} +11 -11
  47. package/dist/{chunk-W4Q65VJL.js → chunk-4X7HQKAG.js} +2 -2
  48. package/dist/{chunk-I74SUMNI.js → chunk-5ACIRCBO.js} +65 -3
  49. package/dist/chunk-5ACIRCBO.js.map +1 -0
  50. package/dist/{chunk-LPUEBFX2.js → chunk-5JCYPBY5.js} +2 -2
  51. package/dist/{chunk-ID65XTF3.js → chunk-5SOSQTVE.js} +2 -2
  52. package/dist/{chunk-SEIGLG62.js → chunk-6VFMEBXY.js} +4 -4
  53. package/dist/{chunk-333SBFXB.js → chunk-7AAMJQFW.js} +2 -2
  54. package/dist/{chunk-AHOYKJ5X.js → chunk-7SNEJNA3.js} +96 -23
  55. package/dist/chunk-7SNEJNA3.js.map +1 -0
  56. package/dist/{chunk-T3MCVSUC.js → chunk-A2XFG462.js} +2 -2
  57. package/dist/{chunk-HXFIILGF.js → chunk-BFPF5N3H.js} +4 -4
  58. package/dist/{chunk-GWY5ZFHP.js → chunk-BJOQQCYC.js} +5 -5
  59. package/dist/{chunk-7OYDFIL4.js → chunk-CY2C5LM4.js} +3 -3
  60. package/dist/{chunk-BFBS7OFQ.js → chunk-DC55RIEZ.js} +4 -4
  61. package/dist/{chunk-TGQW3AMK.js → chunk-DNXQVCIC.js} +3 -3
  62. package/dist/{chunk-TQ4CELUR.js → chunk-E53NLIAP.js} +3 -3
  63. package/dist/{chunk-2LA3H54D.js → chunk-E5IZTY4W.js} +2 -2
  64. package/dist/{chunk-PFR6ZKQI.js → chunk-EBI6FI5U.js} +6 -6
  65. package/dist/{chunk-JN7OSQJR.js → chunk-ETTV5F53.js} +2 -2
  66. package/dist/{chunk-FRYCXXTB.js → chunk-FSORYJRP.js} +3 -3
  67. package/dist/{chunk-K36RMINQ.js → chunk-GOZXQNIM.js} +3 -3
  68. package/dist/{chunk-H4IU24V5.js → chunk-GUF2JKG5.js} +2 -2
  69. package/dist/{chunk-XTRC6SSS.js → chunk-H6TCS5XX.js} +11 -8
  70. package/dist/chunk-H6TCS5XX.js.map +1 -0
  71. package/dist/{chunk-MTJFK42O.js → chunk-HHVK2JRE.js} +2 -2
  72. package/dist/{chunk-D5ZLTLHF.js → chunk-HR3DKJCU.js} +2 -2
  73. package/dist/{chunk-AUFPPBC3.js → chunk-IJKO5RVJ.js} +3 -3
  74. package/dist/{chunk-O3OEVYUR.js → chunk-IK7NPYYU.js} +2 -2
  75. package/dist/{chunk-ILNPU5W5.js → chunk-IMA4DJ7K.js} +5 -45
  76. package/dist/chunk-IMA4DJ7K.js.map +1 -0
  77. package/dist/{chunk-ACPFBVUD.js → chunk-JDH2BA2P.js} +2 -2
  78. package/dist/{chunk-VF6SC4OD.js → chunk-JNBSTHVT.js} +2 -2
  79. package/dist/chunk-JVVWCZ2P.js +18 -0
  80. package/dist/chunk-JVVWCZ2P.js.map +1 -0
  81. package/dist/{chunk-OBPOIZNR.js → chunk-KBHUGMUW.js} +2 -2
  82. package/dist/{chunk-M7CFCRWJ.js → chunk-KW4XA7GM.js} +3 -3
  83. package/dist/{chunk-B5KTTWC7.js → chunk-L5EE2CXU.js} +2 -2
  84. package/dist/{chunk-QNUNAXBE.js → chunk-L7LZDISF.js} +1 -9
  85. package/dist/{chunk-QNUNAXBE.js.map → chunk-L7LZDISF.js.map} +1 -1
  86. package/dist/{chunk-N3FRR6II.js → chunk-LAOJHOTG.js} +2 -2
  87. package/dist/{chunk-QPLI7LUU.js → chunk-LH57QATU.js} +2 -2
  88. package/dist/{chunk-JGGNUEVD.js → chunk-NDPS6OU2.js} +2 -2
  89. package/dist/{chunk-N7AIFTSH.js → chunk-NJG63FY2.js} +1 -1
  90. package/dist/{chunk-N7AIFTSH.js.map → chunk-NJG63FY2.js.map} +1 -1
  91. package/dist/{chunk-UPD5XDJX.js → chunk-NKAGGDSL.js} +4 -4
  92. package/dist/{chunk-G3RLCVJC.js → chunk-OGQL7QC7.js} +2 -2
  93. package/dist/{chunk-K3FH3LAQ.js → chunk-OJXK5C6Z.js} +4 -4
  94. package/dist/{chunk-HDLNSDLK.js → chunk-P3XO7HE3.js} +2 -2
  95. package/dist/{chunk-VMRPLHEU.js → chunk-PQIFYBUX.js} +2 -2
  96. package/dist/{chunk-WLT6LTQP.js → chunk-PRRWKTK6.js} +2 -2
  97. package/dist/{chunk-CX24SVLK.js → chunk-Q7OKGBZY.js} +2 -2
  98. package/dist/{chunk-BHRPZBAH.js → chunk-QJBULLKG.js} +3 -3
  99. package/dist/{chunk-WCJQ3OUP.js → chunk-QKAFFVSO.js} +2 -2
  100. package/dist/{chunk-VKXJQF5C.js → chunk-QKBFVLDH.js} +2 -2
  101. package/dist/{chunk-I7WPLMUX.js → chunk-QRCE77YX.js} +2 -2
  102. package/dist/{chunk-K2DTHNDY.js → chunk-R2AJAAHJ.js} +4 -4
  103. package/dist/{chunk-5KDDAQ6K.js → chunk-R3UQIS3F.js} +6 -6
  104. package/dist/{chunk-B3M56D2A.js → chunk-RDHEBINJ.js} +2 -2
  105. package/dist/{chunk-3I3NXB6X.js → chunk-RHQL2RIM.js} +2 -2
  106. package/dist/{chunk-FMIM36I4.js → chunk-SA2YALFU.js} +2 -2
  107. package/dist/{chunk-DPL5VO5V.js → chunk-SAPC7N43.js} +3 -3
  108. package/dist/{chunk-7FPI5MFB.js → chunk-SLWD7TB6.js} +5 -5
  109. package/dist/{chunk-ZA6CYFAK.js → chunk-SOQOUZ2Y.js} +2 -2
  110. package/dist/{chunk-VHXRLD6S.js → chunk-T2JZF45K.js} +2 -2
  111. package/dist/{chunk-32OTLNAU.js → chunk-T2KCROPA.js} +230 -216
  112. package/dist/chunk-T2KCROPA.js.map +1 -0
  113. package/dist/{chunk-63A2BU2B.js → chunk-T4MKFTJF.js} +2 -2
  114. package/dist/{chunk-E7ATID4Z.js → chunk-UFX24WNJ.js} +14 -14
  115. package/dist/{chunk-HQPFACXO.js → chunk-UH3FPX3L.js} +2 -2
  116. package/dist/{chunk-3LADDLAF.js → chunk-V5W67PQV.js} +4 -4
  117. package/dist/{chunk-PRC7SZYM.js → chunk-VAQIBC2L.js} +2 -2
  118. package/dist/{chunk-3Q3XD3NO.js → chunk-W2E2WFXL.js} +3 -3
  119. package/dist/{chunk-GF5NN3LE.js → chunk-W2UV6VE3.js} +2 -2
  120. package/dist/{chunk-SH3GOZWK.js → chunk-W35ICLYZ.js} +2 -2
  121. package/dist/{chunk-ALTLOHO7.js → chunk-WF2LYKOB.js} +2 -2
  122. package/dist/{chunk-FSXYBIEZ.js → chunk-X5MFCZDL.js} +72 -35
  123. package/dist/chunk-X5MFCZDL.js.map +1 -0
  124. package/dist/{chunk-FZVROZKC.js → chunk-XVZA6VXC.js} +4 -4
  125. package/dist/{chunk-IJVU4ILJ.js → chunk-XYNUEXLC.js} +4 -4
  126. package/dist/{chunk-RVAPK2S7.js → chunk-Y65XX5PC.js} +2 -2
  127. package/dist/{chunk-YWMCV5HL.js → chunk-YE77U5HZ.js} +3 -3
  128. package/dist/{chunk-VPEIWMUT.js → chunk-YLTU2DC4.js} +2 -2
  129. package/dist/{chunk-62YZOQFR.js → chunk-YRD525ZO.js} +2 -2
  130. package/dist/{chunk-TBBDFYXW.js → chunk-YVUNHNB6.js} +2 -3
  131. package/dist/chunk-YVUNHNB6.js.map +1 -0
  132. package/dist/{chunk-ITGAGNX5.js → chunk-YY5UXARJ.js} +24 -12
  133. package/dist/chunk-YY5UXARJ.js.map +1 -0
  134. package/dist/{chunk-U7KP6QFU.js → chunk-ZJ3CEAJD.js} +2 -2
  135. package/dist/{chunk-QC2MHZDD.js → chunk-ZOJUWVAU.js} +1 -1
  136. package/dist/{chunk-HH6PXQ2B.js → chunk-ZYP4YEEI.js} +2 -2
  137. package/dist/cli.js +124 -123
  138. package/dist/coding/export-okf-codegraph.js +21 -21
  139. package/dist/coding/pre-action-gate.js +2 -2
  140. package/dist/compounding/engine.js +14 -14
  141. package/dist/config-deprecations.d.ts +3 -0
  142. package/dist/config-deprecations.d.ts.map +1 -0
  143. package/dist/config-deprecations.js +9 -0
  144. package/dist/config.d.ts.map +1 -1
  145. package/dist/config.js +21 -20
  146. package/dist/connectors/codex-materialize-runner.js +13 -13
  147. package/dist/connectors/index.js +13 -13
  148. package/dist/convergence-refresh.js +16 -16
  149. package/dist/corpus-watermark.js +15 -15
  150. package/dist/correction/correction-access-wiring.d.ts +4 -1
  151. package/dist/correction/correction-access-wiring.d.ts.map +1 -1
  152. package/dist/deep-recall-http-glue.js +8 -8
  153. package/dist/deep-recall.js +2 -2
  154. package/dist/embedding-fallback.js +1 -1
  155. package/dist/entity-retrieval.js +14 -14
  156. package/dist/explicit-capture.js +124 -123
  157. package/dist/extraction-span-materialize.js +2 -2
  158. package/dist/extraction.js +22 -22
  159. package/dist/{first-start-migration-BPVJ4HJQ.js → first-start-migration-PPPP54X6.js} +5 -5
  160. package/dist/{graph-edge-decay-CXTNJ7IQ.js → graph-edge-decay-EKWXRBWF.js} +5 -5
  161. package/dist/graph-jsonl.js +3 -3
  162. package/dist/graph-snapshot.js +3 -3
  163. package/dist/graph.js +2 -2
  164. package/dist/harmonic-retrieval.js +13 -13
  165. package/dist/index.js +173 -171
  166. package/dist/lcm/engine.js +2 -2
  167. package/dist/lcm/index.js +4 -4
  168. package/dist/lifecycle.d.ts +0 -6
  169. package/dist/lifecycle.d.ts.map +1 -1
  170. package/dist/lifecycle.js +1 -1
  171. package/dist/location/index.js +25 -15
  172. package/dist/location/provider-setup.d.ts +26 -1
  173. package/dist/location/provider-setup.d.ts.map +1 -1
  174. package/dist/maintenance/memory-governance.js +14 -14
  175. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +13 -13
  176. package/dist/maintenance/rebuild-memory-projection-runner.js +16 -16
  177. package/dist/maintenance/rebuild-memory-projection.js +15 -15
  178. package/dist/memory-browse.js +6 -6
  179. package/dist/{migrate-from-identity-anchor-MJYB6NNN.js → migrate-from-identity-anchor-TZSZXJ6L.js} +2 -2
  180. package/dist/migrate-from-identity-anchor-TZSZXJ6L.js.map +1 -0
  181. package/dist/model-registry.d.ts +0 -5
  182. package/dist/model-registry.d.ts.map +1 -1
  183. package/dist/model-registry.js +1 -1
  184. package/dist/namespaces/migrate.js +14 -14
  185. package/dist/namespaces/search.js +6 -6
  186. package/dist/namespaces/storage.js +13 -13
  187. package/dist/offline-sync-changeset-generations.js +3 -3
  188. package/dist/offline-sync-embedding-generation.js +2 -2
  189. package/dist/offline-sync-snapshot-stream.js +5 -5
  190. package/dist/offline-sync.js +4 -4
  191. package/dist/operator-doctor-corpus.js +16 -16
  192. package/dist/operator-toolkit.js +32 -31
  193. package/dist/orchestration/backlog-scheduler.js +125 -124
  194. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  195. package/dist/orchestration/buffer-drain-runner.js +125 -124
  196. package/dist/orchestration/maintenance.js +22 -22
  197. package/dist/orchestration/semantic-consolidation-coordinator.d.ts.map +1 -1
  198. package/dist/orchestration/workspace-ops.d.ts.map +1 -1
  199. package/dist/orchestrator.js +124 -123
  200. package/dist/peers/index.d.ts +2 -1
  201. package/dist/peers/index.d.ts.map +1 -1
  202. package/dist/peers/index.js +3 -3
  203. package/dist/peers/interaction-log-append.d.ts +8 -0
  204. package/dist/peers/interaction-log-append.d.ts.map +1 -0
  205. package/dist/peers/storage.d.ts +22 -8
  206. package/dist/peers/storage.d.ts.map +1 -1
  207. package/dist/policy-runtime.js +2 -2
  208. package/dist/qmd.js +2 -2
  209. package/dist/recall-explain-renderer.js +3 -3
  210. package/dist/recall-navigate-access.js +2 -2
  211. package/dist/recall-navigate-disclosure.js +2 -2
  212. package/dist/recall-navigate.js +2 -2
  213. package/dist/recall-navigation.js +124 -123
  214. package/dist/recall-state-view-admission.js +6 -6
  215. package/dist/recall-why-service.js +6 -6
  216. package/dist/recall-xray-cli.js +4 -4
  217. package/dist/recall-xray-renderer.js +3 -3
  218. package/dist/recall-xray.js +2 -2
  219. package/dist/resume-bundles.js +22 -21
  220. package/dist/retrieval.js +2 -2
  221. package/dist/search/factory.js +5 -5
  222. package/dist/search/index.js +9 -9
  223. package/dist/semantic-consolidation.d.ts +10 -16
  224. package/dist/semantic-consolidation.d.ts.map +1 -1
  225. package/dist/semantic-consolidation.js +14 -14
  226. package/dist/semantic-rule-promotion.js +13 -13
  227. package/dist/semantic-rule-verifier.js +13 -13
  228. package/dist/source-agent-qualifier.js +17 -17
  229. package/dist/standup/build.js +13 -13
  230. package/dist/storage/links-frontmatter.d.ts +3 -0
  231. package/dist/storage/links-frontmatter.d.ts.map +1 -0
  232. package/dist/storage.d.ts.map +1 -1
  233. package/dist/storage.js +12 -12
  234. package/dist/summarizer.js +2 -2
  235. package/dist/tier-routing.js +2 -2
  236. package/dist/{tier-stats-FLFKN7Y6.js → tier-stats-XWJSVEHC.js} +5 -5
  237. package/dist/transfer/capsule-export.js +2 -2
  238. package/dist/transfer/capsule-import.js +2 -2
  239. package/dist/transfer/export-okf.js +13 -13
  240. package/dist/types.d.ts +1 -0
  241. package/dist/types.d.ts.map +1 -1
  242. package/dist/types.js +1 -1
  243. package/dist/utility-learner.js +2 -2
  244. package/dist/utility-runtime.js +3 -3
  245. package/dist/verified-recall.js +13 -13
  246. package/dist/who-knows-cli.js +14 -14
  247. package/dist/who-knows.js +13 -13
  248. package/package.json +2 -2
  249. package/src/access-recall-surface.ts +0 -2
  250. package/src/chat/chat-engine.ts +5 -3
  251. package/src/chat/chat-executor.test.ts +150 -0
  252. package/src/chat/chat-executor.ts +31 -20
  253. package/src/chat/chat-factory.ts +1 -1
  254. package/src/config-deprecations.ts +14 -0
  255. package/src/config.ts +2 -1
  256. package/src/correction/correction-access-wiring.ts +4 -1
  257. package/src/lifecycle.ts +0 -8
  258. package/src/location/provider-setup.test.ts +273 -2
  259. package/src/location/provider-setup.ts +138 -32
  260. package/src/model-registry.ts +0 -11
  261. package/src/orchestration/semantic-consolidation-coordinator.ts +40 -33
  262. package/src/orchestration/semantic-consolidation-split.test.ts +72 -0
  263. package/src/orchestration/workspace-ops.test.ts +23 -0
  264. package/src/orchestration/workspace-ops.ts +6 -5
  265. package/src/peers/index.ts +1 -1
  266. package/src/peers/interaction-log-append.ts +132 -0
  267. package/src/peers/peers.test.ts +30 -0
  268. package/src/peers/profile-reasoner.ts +1 -1
  269. package/src/peers/storage.ts +4 -105
  270. package/src/semantic-consolidation.ts +35 -27
  271. package/src/storage/links-frontmatter.ts +69 -0
  272. package/src/storage-links-parse.test.ts +153 -0
  273. package/src/storage.ts +4 -18
  274. package/src/testing/subjects/dependency-propagation.test.ts +5 -4
  275. package/src/types.ts +1 -0
  276. package/dist/chunk-32OTLNAU.js.map +0 -1
  277. package/dist/chunk-AHOYKJ5X.js.map +0 -1
  278. package/dist/chunk-FSXYBIEZ.js.map +0 -1
  279. package/dist/chunk-I74SUMNI.js.map +0 -1
  280. package/dist/chunk-ILNPU5W5.js.map +0 -1
  281. package/dist/chunk-ITGAGNX5.js.map +0 -1
  282. package/dist/chunk-TBBDFYXW.js.map +0 -1
  283. package/dist/chunk-XTRC6SSS.js.map +0 -1
  284. /package/dist/{chunk-FHWX2REL.js.map → chunk-2OAFPBQB.js.map} +0 -0
  285. /package/dist/{chunk-5IZL4DCV.js.map → chunk-4DF5LMBJ.js.map} +0 -0
  286. /package/dist/{chunk-FWTGO4NE.js.map → chunk-4DLGKTM6.js.map} +0 -0
  287. /package/dist/{chunk-D6YCETHG.js.map → chunk-4E2Z44CV.js.map} +0 -0
  288. /package/dist/{chunk-W4EJMMPP.js.map → chunk-4LVQSHHN.js.map} +0 -0
  289. /package/dist/{chunk-W4Q65VJL.js.map → chunk-4X7HQKAG.js.map} +0 -0
  290. /package/dist/{chunk-LPUEBFX2.js.map → chunk-5JCYPBY5.js.map} +0 -0
  291. /package/dist/{chunk-ID65XTF3.js.map → chunk-5SOSQTVE.js.map} +0 -0
  292. /package/dist/{chunk-SEIGLG62.js.map → chunk-6VFMEBXY.js.map} +0 -0
  293. /package/dist/{chunk-333SBFXB.js.map → chunk-7AAMJQFW.js.map} +0 -0
  294. /package/dist/{chunk-T3MCVSUC.js.map → chunk-A2XFG462.js.map} +0 -0
  295. /package/dist/{chunk-HXFIILGF.js.map → chunk-BFPF5N3H.js.map} +0 -0
  296. /package/dist/{chunk-GWY5ZFHP.js.map → chunk-BJOQQCYC.js.map} +0 -0
  297. /package/dist/{chunk-7OYDFIL4.js.map → chunk-CY2C5LM4.js.map} +0 -0
  298. /package/dist/{chunk-BFBS7OFQ.js.map → chunk-DC55RIEZ.js.map} +0 -0
  299. /package/dist/{chunk-TGQW3AMK.js.map → chunk-DNXQVCIC.js.map} +0 -0
  300. /package/dist/{chunk-TQ4CELUR.js.map → chunk-E53NLIAP.js.map} +0 -0
  301. /package/dist/{chunk-2LA3H54D.js.map → chunk-E5IZTY4W.js.map} +0 -0
  302. /package/dist/{chunk-PFR6ZKQI.js.map → chunk-EBI6FI5U.js.map} +0 -0
  303. /package/dist/{chunk-JN7OSQJR.js.map → chunk-ETTV5F53.js.map} +0 -0
  304. /package/dist/{chunk-FRYCXXTB.js.map → chunk-FSORYJRP.js.map} +0 -0
  305. /package/dist/{chunk-K36RMINQ.js.map → chunk-GOZXQNIM.js.map} +0 -0
  306. /package/dist/{chunk-H4IU24V5.js.map → chunk-GUF2JKG5.js.map} +0 -0
  307. /package/dist/{chunk-MTJFK42O.js.map → chunk-HHVK2JRE.js.map} +0 -0
  308. /package/dist/{chunk-D5ZLTLHF.js.map → chunk-HR3DKJCU.js.map} +0 -0
  309. /package/dist/{chunk-AUFPPBC3.js.map → chunk-IJKO5RVJ.js.map} +0 -0
  310. /package/dist/{chunk-O3OEVYUR.js.map → chunk-IK7NPYYU.js.map} +0 -0
  311. /package/dist/{chunk-ACPFBVUD.js.map → chunk-JDH2BA2P.js.map} +0 -0
  312. /package/dist/{chunk-VF6SC4OD.js.map → chunk-JNBSTHVT.js.map} +0 -0
  313. /package/dist/{chunk-OBPOIZNR.js.map → chunk-KBHUGMUW.js.map} +0 -0
  314. /package/dist/{chunk-M7CFCRWJ.js.map → chunk-KW4XA7GM.js.map} +0 -0
  315. /package/dist/{chunk-B5KTTWC7.js.map → chunk-L5EE2CXU.js.map} +0 -0
  316. /package/dist/{chunk-N3FRR6II.js.map → chunk-LAOJHOTG.js.map} +0 -0
  317. /package/dist/{chunk-QPLI7LUU.js.map → chunk-LH57QATU.js.map} +0 -0
  318. /package/dist/{chunk-JGGNUEVD.js.map → chunk-NDPS6OU2.js.map} +0 -0
  319. /package/dist/{chunk-UPD5XDJX.js.map → chunk-NKAGGDSL.js.map} +0 -0
  320. /package/dist/{chunk-G3RLCVJC.js.map → chunk-OGQL7QC7.js.map} +0 -0
  321. /package/dist/{chunk-K3FH3LAQ.js.map → chunk-OJXK5C6Z.js.map} +0 -0
  322. /package/dist/{chunk-HDLNSDLK.js.map → chunk-P3XO7HE3.js.map} +0 -0
  323. /package/dist/{chunk-VMRPLHEU.js.map → chunk-PQIFYBUX.js.map} +0 -0
  324. /package/dist/{chunk-WLT6LTQP.js.map → chunk-PRRWKTK6.js.map} +0 -0
  325. /package/dist/{chunk-CX24SVLK.js.map → chunk-Q7OKGBZY.js.map} +0 -0
  326. /package/dist/{chunk-BHRPZBAH.js.map → chunk-QJBULLKG.js.map} +0 -0
  327. /package/dist/{chunk-WCJQ3OUP.js.map → chunk-QKAFFVSO.js.map} +0 -0
  328. /package/dist/{chunk-VKXJQF5C.js.map → chunk-QKBFVLDH.js.map} +0 -0
  329. /package/dist/{chunk-I7WPLMUX.js.map → chunk-QRCE77YX.js.map} +0 -0
  330. /package/dist/{chunk-K2DTHNDY.js.map → chunk-R2AJAAHJ.js.map} +0 -0
  331. /package/dist/{chunk-5KDDAQ6K.js.map → chunk-R3UQIS3F.js.map} +0 -0
  332. /package/dist/{chunk-B3M56D2A.js.map → chunk-RDHEBINJ.js.map} +0 -0
  333. /package/dist/{chunk-3I3NXB6X.js.map → chunk-RHQL2RIM.js.map} +0 -0
  334. /package/dist/{chunk-FMIM36I4.js.map → chunk-SA2YALFU.js.map} +0 -0
  335. /package/dist/{chunk-DPL5VO5V.js.map → chunk-SAPC7N43.js.map} +0 -0
  336. /package/dist/{chunk-7FPI5MFB.js.map → chunk-SLWD7TB6.js.map} +0 -0
  337. /package/dist/{chunk-ZA6CYFAK.js.map → chunk-SOQOUZ2Y.js.map} +0 -0
  338. /package/dist/{chunk-VHXRLD6S.js.map → chunk-T2JZF45K.js.map} +0 -0
  339. /package/dist/{chunk-63A2BU2B.js.map → chunk-T4MKFTJF.js.map} +0 -0
  340. /package/dist/{chunk-E7ATID4Z.js.map → chunk-UFX24WNJ.js.map} +0 -0
  341. /package/dist/{chunk-HQPFACXO.js.map → chunk-UH3FPX3L.js.map} +0 -0
  342. /package/dist/{chunk-3LADDLAF.js.map → chunk-V5W67PQV.js.map} +0 -0
  343. /package/dist/{chunk-PRC7SZYM.js.map → chunk-VAQIBC2L.js.map} +0 -0
  344. /package/dist/{chunk-3Q3XD3NO.js.map → chunk-W2E2WFXL.js.map} +0 -0
  345. /package/dist/{chunk-GF5NN3LE.js.map → chunk-W2UV6VE3.js.map} +0 -0
  346. /package/dist/{chunk-SH3GOZWK.js.map → chunk-W35ICLYZ.js.map} +0 -0
  347. /package/dist/{chunk-ALTLOHO7.js.map → chunk-WF2LYKOB.js.map} +0 -0
  348. /package/dist/{chunk-FZVROZKC.js.map → chunk-XVZA6VXC.js.map} +0 -0
  349. /package/dist/{chunk-IJVU4ILJ.js.map → chunk-XYNUEXLC.js.map} +0 -0
  350. /package/dist/{chunk-RVAPK2S7.js.map → chunk-Y65XX5PC.js.map} +0 -0
  351. /package/dist/{chunk-YWMCV5HL.js.map → chunk-YE77U5HZ.js.map} +0 -0
  352. /package/dist/{chunk-VPEIWMUT.js.map → chunk-YLTU2DC4.js.map} +0 -0
  353. /package/dist/{chunk-62YZOQFR.js.map → chunk-YRD525ZO.js.map} +0 -0
  354. /package/dist/{chunk-U7KP6QFU.js.map → chunk-ZJ3CEAJD.js.map} +0 -0
  355. /package/dist/{chunk-QC2MHZDD.js.map → chunk-ZOJUWVAU.js.map} +0 -0
  356. /package/dist/{chunk-HH6PXQ2B.js.map → chunk-ZYP4YEEI.js.map} +0 -0
  357. /package/dist/{graph-edge-decay-CXTNJ7IQ.js.map → config-deprecations.js.map} +0 -0
  358. /package/dist/{first-start-migration-BPVJ4HJQ.js.map → first-start-migration-PPPP54X6.js.map} +0 -0
  359. /package/dist/{migrate-from-identity-anchor-MJYB6NNN.js.map → graph-edge-decay-EKWXRBWF.js.map} +0 -0
  360. /package/dist/{tier-stats-FLFKN7Y6.js.map → tier-stats-XWJSVEHC.js.map} +0 -0
@@ -0,0 +1,150 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { EngramAccessService } from "../access-service.js";
4
+ import type {
5
+ CorrectionOutcome,
6
+ CorrectionPlan,
7
+ CorrectionRequest,
8
+ } from "../correction/index.js";
9
+ import { createChatExecutor } from "./chat-executor.js";
10
+
11
+ interface ApplyOpts {
12
+ confirm?: boolean;
13
+ namespace?: string;
14
+ sessionKey?: string;
15
+ principal?: string;
16
+ abortSignal?: AbortSignal;
17
+ }
18
+
19
+ interface ListPendingOpts {
20
+ namespace?: string;
21
+ sessionKey?: string;
22
+ principal?: string;
23
+ }
24
+
25
+ interface CapturedCalls {
26
+ planRequests: CorrectionRequest[];
27
+ applyPlanIds: string[];
28
+ applyOpts: ApplyOpts[];
29
+ listOpts: ListPendingOpts[];
30
+ }
31
+
32
+ /** Minimal correction surface; captures the args the executor sends. */
33
+ function fakeCorrectionService(calls: CapturedCalls, pending: CorrectionPlan[]): EngramAccessService {
34
+ // SAFETY: the double implements only the three correction methods the
35
+ // executor calls; no other EngramAccessService member is reached here.
36
+ const service = Object.create(EngramAccessService.prototype) as EngramAccessService;
37
+ service.correctionPlan = async (request: CorrectionRequest): Promise<CorrectionPlan> => {
38
+ calls.planRequests.push(request);
39
+ return {
40
+ planId: "corr-real-1",
41
+ request,
42
+ namespace: "ns",
43
+ affected: [],
44
+ classification: "wrong",
45
+ actions: [],
46
+ diff: "DIFF: rewrite fact",
47
+ confidence: 0.9,
48
+ warnings: [],
49
+ createdAt: "t",
50
+ expiresAt: "t+1h",
51
+ };
52
+ };
53
+ service.correctionApply = async (planId: string, opts: ApplyOpts): Promise<CorrectionOutcome> => {
54
+ calls.applyPlanIds.push(planId);
55
+ calls.applyOpts.push(opts);
56
+ return {
57
+ planId,
58
+ status: "applied",
59
+ results: [],
60
+ auditMemoryId: "audit-1",
61
+ appliedAt: "t",
62
+ };
63
+ };
64
+ service.correctionListPending = async (opts: ListPendingOpts): Promise<CorrectionPlan[]> => {
65
+ calls.listOpts.push(opts);
66
+ return pending;
67
+ };
68
+ return service;
69
+ }
70
+
71
+ function emptyCalls(): CapturedCalls {
72
+ return { planRequests: [], applyPlanIds: [], applyOpts: [], listOpts: [] };
73
+ }
74
+
75
+ test("correctionPlan delegates to the access-service plan path", async () => {
76
+ const calls = emptyCalls();
77
+ const executor = createChatExecutor({
78
+ service: fakeCorrectionService(calls, []),
79
+ principal: "reader",
80
+ namespace: "team",
81
+ sessionKey: "sess-1",
82
+ });
83
+ const plan = await executor.correctionPlan("the deploy day is wrong");
84
+ assert.equal(plan.planId, "corr-real-1");
85
+ assert.equal(plan.preview, "DIFF: rewrite fact");
86
+ const request = calls.planRequests[0];
87
+ assert.equal(request?.text, "the deploy day is wrong");
88
+ assert.equal(request?.sessionKey, "sess-1");
89
+ assert.equal(request?.principal, "reader");
90
+ assert.equal(request?.namespace, "team");
91
+ // The stub marker must be gone.
92
+ assert.ok(!plan.planId.startsWith("stub-"));
93
+ assert.ok(!plan.preview.includes("not yet available"));
94
+ });
95
+
96
+ test("correctionPlan retrieves a pending plan preview for the engine sentinel", async () => {
97
+ const calls = emptyCalls();
98
+ const pending: CorrectionPlan[] = [
99
+ {
100
+ planId: "corr-9",
101
+ request: { text: "prior request" },
102
+ namespace: "ns",
103
+ affected: [],
104
+ classification: "outdated",
105
+ actions: [],
106
+ diff: "DIFF: pending preview",
107
+ confidence: 0.8,
108
+ warnings: [],
109
+ createdAt: "t",
110
+ expiresAt: "t+1h",
111
+ },
112
+ ];
113
+ const executor = createChatExecutor({
114
+ service: fakeCorrectionService(calls, pending),
115
+ sessionKey: "sess-1",
116
+ });
117
+ const plan = await executor.correctionPlan("retrieve plan corr-9");
118
+ assert.equal(plan.planId, "corr-9");
119
+ assert.equal(plan.preview, "DIFF: pending preview");
120
+ assert.equal(calls.planRequests.length, 0, "sentinel must not mint a new plan");
121
+ assert.equal(calls.listOpts.length, 1);
122
+ await assert.rejects(
123
+ () => executor.correctionPlan("retrieve plan corr-missing"),
124
+ /not found|expired/i,
125
+ );
126
+ });
127
+
128
+ test("correctionApply delegates with confirm and the bound identity", async () => {
129
+ const calls = emptyCalls();
130
+ const executor = createChatExecutor({
131
+ service: fakeCorrectionService(calls, []),
132
+ principal: "writer",
133
+ namespace: "team",
134
+ sessionKey: "sess-2",
135
+ });
136
+ // SAFETY: correctionApply JSON.stringify's the service outcome, so the
137
+ // parsed shape is the CorrectionOutcome the fake returned.
138
+ const out = JSON.parse(await executor.correctionApply("corr-real-1")) as {
139
+ status: string;
140
+ auditMemoryId: string;
141
+ };
142
+ assert.equal(out.status, "applied");
143
+ assert.equal(out.auditMemoryId, "audit-1");
144
+ assert.equal(calls.applyPlanIds[0], "corr-real-1");
145
+ const opts = calls.applyOpts[0];
146
+ assert.equal(opts?.confirm, true);
147
+ assert.equal(opts?.sessionKey, "sess-2");
148
+ assert.equal(opts?.principal, "writer");
149
+ assert.equal(opts?.namespace, "team");
150
+ });
@@ -6,10 +6,9 @@
6
6
  * session's principal/namespace/sessionKey so every tool call flows through
7
7
  * access-service with the caller's identity (rule 42).
8
8
  *
9
- * Correction tools (correction_plan / correction_apply / memory_promote) are
10
- * stubbed behind the same interface until the Correction Contract (#1580)
11
- * merges. The stub returns a clear not-available marker so the engine and
12
- * surfaces degrade gracefully.
9
+ * Correction tools (correction_plan / correction_apply / memory_promote)
10
+ * delegate to the Correction Contract (#1580) plan/apply pipeline through
11
+ * the access-service.
13
12
  */
14
13
 
15
14
  import type { EngramAccessService } from "../access-service.js";
@@ -27,6 +26,10 @@ export interface ChatExecutorBindings {
27
26
  */
28
27
  export function createChatExecutor(bindings: ChatExecutorBindings): ChatToolExecutor {
29
28
  const { service, principal, namespace, sessionKey } = bindings;
29
+ const correctionScope: Parameters<EngramAccessService["correctionListPending"]>[0] = {};
30
+ if (namespace) correctionScope.namespace = namespace;
31
+ if (sessionKey) correctionScope.sessionKey = sessionKey;
32
+ if (principal) correctionScope.principal = principal;
30
33
 
31
34
  return {
32
35
  async memorySearch(query: string, maxResults?: number): Promise<string> {
@@ -86,28 +89,36 @@ export function createChatExecutor(bindings: ChatExecutorBindings): ChatToolExec
86
89
  });
87
90
  },
88
91
 
89
- // ── Correction tools — stubbed until #1580 merges ──────────────────
90
- // When the Correction Contract lands, replace these stubs with calls to
91
- // the correction module's plan/apply interface. The engine, CLI, and
92
- // MCP tool all consume this interface, so the stub-to-real swap is a
93
- // single-file change here.
92
+ // ── Correction tools — Correction Contract (#1580) ─────────────────
93
+ // Thin adapters over the service's plan/apply pipeline. The engine's
94
+ // confirmation interception asks for a pending plan's preview via the
95
+ // "retrieve plan <id>" sentinel; that is a lookup, not a new plan.
94
96
 
95
97
  async correctionPlan(request: string): Promise<{ planId: string; preview: string }> {
96
- // Stub: the Correction Contract (#1580) is not yet merged.
97
- // Return a not-available marker that the engine surfaces gracefully.
98
- return {
99
- planId: `stub-${Date.now()}`,
100
- preview: `[Correction Contract (#1580) not yet available]\n\nRequested correction: "${request}"\n\nThe plan/apply pipeline is pending. Inspection tools are fully functional.`,
101
- };
98
+ const retrieve = /^retrieve plan (\S+)$/i.exec(request.trim());
99
+ if (retrieve) {
100
+ const pending = await service.correctionListPending(correctionScope);
101
+ const plan = pending.find((p) => p.planId === retrieve[1]);
102
+ if (!plan) {
103
+ throw new Error(`Correction plan ${retrieve[1]} not found or expired.`);
104
+ }
105
+ return { planId: plan.planId, preview: plan.diff };
106
+ }
107
+ const plan = await service.correctionPlan({
108
+ text: request,
109
+ ...correctionScope,
110
+ });
111
+ return { planId: plan.planId, preview: plan.diff };
102
112
  },
103
113
 
104
114
  async correctionApply(planId: string): Promise<string> {
105
- // Stub: no-op until #1580 merges.
106
- return JSON.stringify({
107
- applied: false,
108
- planId,
109
- reason: "Correction Contract (#1580) not yet available. No mutation was applied.",
115
+ // The engine's confirmation protocol is the explicit consent; pass it
116
+ // through as confirm so the apply gate sees a confirmed call.
117
+ const outcome = await service.correctionApply(planId, {
118
+ confirm: true,
119
+ ...correctionScope,
110
120
  });
121
+ return JSON.stringify(outcome);
111
122
  },
112
123
 
113
124
  async memoryPromote(memoryId: string): Promise<string> {
@@ -62,7 +62,7 @@ export function createChatEngine(opts: ChatEngineFactoryOptions): ChatEngine | n
62
62
  executor,
63
63
  maxToolCallsPerTurn: opts.config.maxToolCallsPerTurn,
64
64
  ...(opts.config.model ? { model: opts.config.model } : {}),
65
- correctionAvailable: false,
65
+ correctionAvailable: opts.service.correctionSurfaceVisible,
66
66
  scopeInspectAvailable: false,
67
67
  });
68
68
  }
@@ -0,0 +1,14 @@
1
+ /** Config keys parsed only so existing configs keep loading; each warns when set. */
2
+ import { log } from "./logger.js";
3
+
4
+ const DEFAULT_CAUSAL_IMPACT_WEIGHT = 0.05;
5
+
6
+ /** Lifecycle scoring never had a causal impact signal, so this weight was never read (#3667). */
7
+ export function warnDeprecatedCausalImpactWeight(weight: number | undefined): number {
8
+ if (weight === undefined) return DEFAULT_CAUSAL_IMPACT_WEIGHT;
9
+ log.warn(
10
+ "cmcLifecycleCausalImpactWeight is deprecated and has no effect: lifecycle scoring has no causal impact signal (#3667). " +
11
+ "Remove it from your config.",
12
+ );
13
+ return weight;
14
+ }
package/src/config.ts CHANGED
@@ -28,6 +28,7 @@ import type {
28
28
  } from "./types.js";
29
29
  import { parseBackgroundGeneration } from "./background-generation-config.js";
30
30
  import { parseSearchBackend } from "./config-search-backend.js";
31
+ import { warnDeprecatedCausalImpactWeight } from "./config-deprecations.js";
31
32
  import { parseLocalLlmConfig } from "./local-llm-config.js";
32
33
  import { parseCorrectionConfig } from "./correction/correction-config.js";
33
34
  import { parseConvergeConfig } from "./converge-config.js";
@@ -3081,7 +3082,7 @@ export function parseConfig(
3081
3082
  cmcBehaviorMinFrequency: typeof cfg.cmcBehaviorMinFrequency === "number" ? cfg.cmcBehaviorMinFrequency : 3,
3082
3083
  cmcBehaviorMinSessions: typeof cfg.cmcBehaviorMinSessions === "number" ? cfg.cmcBehaviorMinSessions : 2,
3083
3084
  cmcBehaviorConfidenceThreshold: typeof cfg.cmcBehaviorConfidenceThreshold === "number" ? cfg.cmcBehaviorConfidenceThreshold : 0.6,
3084
- cmcLifecycleCausalImpactWeight: typeof cfg.cmcLifecycleCausalImpactWeight === "number" ? cfg.cmcLifecycleCausalImpactWeight : 0.05,
3085
+ cmcLifecycleCausalImpactWeight: warnDeprecatedCausalImpactWeight(coerceNumber(cfg.cmcLifecycleCausalImpactWeight)),
3085
3086
 
3086
3087
  // PEDC (Prediction-Error-Driven Calibration) — model-user alignment
3087
3088
  calibrationEnabled: cfg.calibrationEnabled === true,
@@ -947,7 +947,10 @@ function toExecutorMemory(m: MemoryFile): ExecutorMemory {
947
947
  * can never drift out of sync (review thread: correction-gate-config-mismatch):
948
948
  * - nested: `config.correction.enabled`
949
949
  * - flat: the `correctionEnabled` legacy key (ratchet-safe shape)
950
- * Nested wins when present; both default to `true` (plan is read-only, safe on).
950
+ * Nested wins when present; both default to `true`. Default-on predates the
951
+ * chat wiring: the executor's plan/apply tools are mutation-capable but sit
952
+ * behind the engine's interactive preview-confirm protocol, so enabled-by-
953
+ * default is intended for human-attended surfaces.
951
954
  */
952
955
  export function isCorrectionFeatureEnabled(config: PluginConfig): boolean {
953
956
  // parseConfig now resolves this into `resolveRecallAuxiliaryCapabilities(config).correction` (review
package/src/lifecycle.ts CHANGED
@@ -24,12 +24,6 @@ export interface LifecycleSignals {
24
24
  * This is intentionally low-impact to avoid circular amplification.
25
25
  */
26
26
  actionPriorScore?: number;
27
- /**
28
- * Optional causal impact score from CMC chain analysis in [0, 0.3].
29
- * Computed as 0.1 * incomingEdges + 0.15 * outgoingEdges, clamped.
30
- * Weight in heat/decay is intentionally low (0.05) to avoid circular amplification.
31
- */
32
- causalImpactScore?: number;
33
27
  }
34
28
 
35
29
  export interface LifecycleDecision {
@@ -141,13 +135,11 @@ export function computeHeat(
141
135
  if (frontmatter.status === "archived") return 0;
142
136
 
143
137
  const inputs = computeLifecycleValueInputs(memory, now, signals);
144
- const causalBoost = clamp01(signals?.causalImpactScore ?? 0) * 0.05;
145
138
  const score = (inputs.confidence * 0.25)
146
139
  + (inputs.access * 0.3)
147
140
  + (inputs.recency * 0.2)
148
141
  + (inputs.importance * 0.15)
149
142
  + (inputs.feedback * 0.1)
150
- + causalBoost
151
143
  - inputs.disputedPenalty;
152
144
  return clamp01(score);
153
145
  }
@@ -9,7 +9,16 @@ import test from "node:test";
9
9
 
10
10
  import { parseLocationConfig } from "./config.js";
11
11
  import { clearLocationProviders, getLocationProvider, registerLocationProvider } from "./registry.js";
12
- import { ensureConfiguredLocationProviders, type LocationProviderEnv } from "./provider-setup.js";
12
+ import {
13
+ ensureConfiguredLocationProviders,
14
+ getLocationProviderSetup,
15
+ listLocationProviderSetups,
16
+ registerLocationProviderSetup,
17
+ resetLocationProviderSetups,
18
+ unregisterLocationProviderSetup,
19
+ type LocationProviderEnv,
20
+ type LocationProviderSetupEntry,
21
+ } from "./provider-setup.js";
13
22
  import type { LocationProvider } from "./types.js";
14
23
 
15
24
  const ENV: LocationProviderEnv = {
@@ -43,7 +52,10 @@ function importModuleDouble(options: { registered: boolean; failWith?: Error })
43
52
  };
44
53
  }
45
54
 
46
- test.afterEach(() => clearLocationProviders());
55
+ test.afterEach(() => {
56
+ clearLocationProviders();
57
+ resetLocationProviderSetups();
58
+ });
47
59
 
48
60
  test("registers reitti from env credentials with timezone threaded through", async () => {
49
61
  const config = parseLocationConfig({ enabled: true, timezone: "Europe/Berlin", sources: [{ id: "reitti" }] });
@@ -104,3 +116,262 @@ test("invalid authMode falls back to the connector default (single header form)"
104
116
  });
105
117
  assert.equal("authMode" in (loader.calls[0] ?? {}), false, "invalid mode must not be forwarded");
106
118
  });
119
+
120
+ interface OwntracksModule {
121
+ ensureOwntracksRegistered(opts: { baseUrl: string; token: string; timezone: string }): boolean;
122
+ }
123
+
124
+ function stubLocationProvider(id: string, displayName: string): LocationProvider {
125
+ return {
126
+ id,
127
+ displayName,
128
+ verify: async () => ({ ok: true }),
129
+ fetchObservations: async () => ({ observations: [], nextCursor: null }),
130
+ };
131
+ }
132
+
133
+ function makeOwntracksSetupEntry(calls: Array<{ baseUrl: string; token: string; timezone: string }>): LocationProviderSetupEntry {
134
+ return {
135
+ id: "owntracks",
136
+ packageSpecifier: "@remnic/connector-owntracks",
137
+ setup: async (context) => {
138
+ const baseUrl = context.env?.baseUrl?.trim();
139
+ const token = context.env?.token?.trim();
140
+ if (!baseUrl || !token) return false;
141
+ const mod = await context.loadPackage<OwntracksModule>();
142
+ const opts = { baseUrl, token, timezone: context.config.timezone };
143
+ calls.push(opts);
144
+ return mod.ensureOwntracksRegistered(opts);
145
+ },
146
+ };
147
+ }
148
+
149
+ test("registers non-reitti provider registered in setup table with idempotency", async () => {
150
+ const setupCalls: Array<{ baseUrl: string; token: string; timezone: string }> = [];
151
+ const requestedSpecifiers: string[] = [];
152
+ registerLocationProviderSetup(makeOwntracksSetupEntry(setupCalls));
153
+
154
+ assert.equal(getLocationProviderSetup("owntracks")?.packageSpecifier, "@remnic/connector-owntracks");
155
+ assert.ok(listLocationProviderSetups().includes("owntracks"));
156
+
157
+ const importModule = async (specifier: string) => {
158
+ requestedSpecifiers.push(specifier);
159
+ const mod: OwntracksModule = {
160
+ ensureOwntracksRegistered: () => {
161
+ registerLocationProvider(stubLocationProvider("owntracks", "OwnTracks"));
162
+ return true;
163
+ },
164
+ };
165
+ return mod;
166
+ };
167
+
168
+ const config = parseLocationConfig({
169
+ enabled: true,
170
+ timezone: "America/Chicago",
171
+ sources: [{ id: "owntracks" }],
172
+ });
173
+ const registered = await ensureConfiguredLocationProviders(config, {
174
+ env: { baseUrl: "https://owntracks.example.invalid", token: "ot-secret" },
175
+ importModule,
176
+ });
177
+
178
+ assert.deepEqual(registered, ["owntracks"]);
179
+ assert.deepEqual(requestedSpecifiers, ["@remnic/connector-owntracks"]);
180
+ assert.deepEqual(setupCalls, [
181
+ { baseUrl: "https://owntracks.example.invalid", token: "ot-secret", timezone: "America/Chicago" },
182
+ ]);
183
+ assert.equal(getLocationProvider("owntracks")?.displayName, "OwnTracks");
184
+
185
+ const registeredAgain = await ensureConfiguredLocationProviders(config, {
186
+ env: { baseUrl: "https://owntracks.example.invalid", token: "ot-secret" },
187
+ importModule,
188
+ });
189
+ assert.deepEqual(registeredAgain, []);
190
+ assert.equal(requestedSpecifiers.length, 1);
191
+ });
192
+
193
+ test("bootstraps multiple configured sources independently using envBySource", async () => {
194
+ const owntracksCalls: Array<{ baseUrl: string; token: string; timezone: string }> = [];
195
+ registerLocationProviderSetup(makeOwntracksSetupEntry(owntracksCalls));
196
+
197
+ const reittiLoader = importModuleDouble({ registered: true });
198
+ const requestedSpecifiers: string[] = [];
199
+ const importModule = async (specifier: string) => {
200
+ requestedSpecifiers.push(specifier);
201
+ if (specifier === "@remnic/connector-owntracks") {
202
+ const mod: OwntracksModule = {
203
+ ensureOwntracksRegistered: () => {
204
+ registerLocationProvider(stubLocationProvider("owntracks", "OwnTracks"));
205
+ return true;
206
+ },
207
+ };
208
+ return mod;
209
+ }
210
+ return reittiLoader.importModule();
211
+ };
212
+
213
+ const config = parseLocationConfig({
214
+ enabled: true,
215
+ timezone: "UTC",
216
+ sources: [{ id: "reitti" }, { id: "owntracks" }],
217
+ });
218
+ const envBySource = new Map<string, LocationProviderEnv>([
219
+ ["reitti", ENV],
220
+ ["owntracks", { baseUrl: "https://owntracks.example.invalid", token: "ot-token" }],
221
+ ]);
222
+
223
+ const registered = await ensureConfiguredLocationProviders(config, { envBySource, importModule });
224
+ assert.deepEqual(registered, ["reitti", "owntracks"]);
225
+ assert.deepEqual(requestedSpecifiers, ["@remnic/connector-reitti", "@remnic/connector-owntracks"]);
226
+ assert.ok(getLocationProvider("reitti"));
227
+ assert.ok(getLocationProvider("owntracks"));
228
+
229
+ clearLocationProviders();
230
+ const partialEnvBySource = new Map<string, LocationProviderEnv>([
231
+ ["reitti", { baseUrl: ENV.baseUrl }],
232
+ ["owntracks", { baseUrl: "https://owntracks.example.invalid", token: "ot-token" }],
233
+ ]);
234
+ const partialRegistered = await ensureConfiguredLocationProviders(config, {
235
+ envBySource: partialEnvBySource,
236
+ importModule,
237
+ });
238
+ assert.deepEqual(partialRegistered, ["owntracks"]);
239
+ });
240
+
241
+ test("setup registry validates ids, rejects duplicates, unregisters, and resets to defaults", async () => {
242
+ assert.equal(getLocationProviderSetup("reitti")?.packageSpecifier, "@remnic/connector-reitti");
243
+ assert.deepEqual(listLocationProviderSetups(), ["reitti"]);
244
+
245
+ const dummySetup: LocationProviderSetupEntry["setup"] = async () => false;
246
+ assert.throws(
247
+ () => registerLocationProviderSetup({ id: "", packageSpecifier: "@remnic/x", setup: dummySetup }),
248
+ RangeError,
249
+ );
250
+ assert.throws(
251
+ () => registerLocationProviderSetup({ id: "UpperCase", packageSpecifier: "@remnic/x", setup: dummySetup }),
252
+ RangeError,
253
+ );
254
+ assert.throws(
255
+ () => registerLocationProviderSetup({ id: "../traversal", packageSpecifier: "@remnic/x", setup: dummySetup }),
256
+ RangeError,
257
+ );
258
+ assert.throws(
259
+ () => registerLocationProviderSetup({ id: "valid-id", packageSpecifier: " ", setup: dummySetup }),
260
+ TypeError,
261
+ );
262
+ assert.throws(
263
+ () => registerLocationProviderSetup({ id: "reitti", packageSpecifier: "@remnic/other", setup: dummySetup }),
264
+ /already registered/,
265
+ );
266
+
267
+ registerLocationProviderSetup({
268
+ id: "custom-gps",
269
+ packageSpecifier: "@remnic/connector-custom-gps",
270
+ setup: async (context) => {
271
+ await context.loadPackage<OwntracksModule>();
272
+ registerLocationProvider(stubLocationProvider("custom-gps", "Custom GPS"));
273
+ return true;
274
+ },
275
+ });
276
+ assert.deepEqual(listLocationProviderSetups(), ["custom-gps", "reitti"]);
277
+ assert.equal(unregisterLocationProviderSetup("custom-gps"), true);
278
+ assert.equal(unregisterLocationProviderSetup("custom-gps"), false);
279
+
280
+ let loaded = false;
281
+ const skipped = await ensureConfiguredLocationProviders(
282
+ parseLocationConfig({ enabled: true, sources: [{ id: "custom-gps" }] }),
283
+ {
284
+ env: ENV,
285
+ importModule: async () => {
286
+ loaded = true;
287
+ return {};
288
+ },
289
+ },
290
+ );
291
+ assert.deepEqual(skipped, []);
292
+ assert.equal(loaded, false);
293
+
294
+ registerLocationProviderSetup({
295
+ id: "custom-gps",
296
+ packageSpecifier: "@remnic/connector-custom-gps",
297
+ setup: dummySetup,
298
+ });
299
+ resetLocationProviderSetups();
300
+ assert.deepEqual(listLocationProviderSetups(), ["reitti"]);
301
+ });
302
+
303
+ test("absent optional package and load failures on registered custom setup do not throw", async () => {
304
+ const setupCalls: Array<{ baseUrl: string; token: string; timezone: string }> = [];
305
+ registerLocationProviderSetup(makeOwntracksSetupEntry(setupCalls));
306
+ registerLocationProviderSetup({
307
+ id: "second-provider",
308
+ packageSpecifier: "@remnic/connector-second",
309
+ setup: async (context) => {
310
+ const mod = await context.loadPackage<OwntracksModule>();
311
+ return mod.ensureOwntracksRegistered({
312
+ baseUrl: context.env?.baseUrl ?? "",
313
+ token: context.env?.token ?? "",
314
+ timezone: context.config.timezone,
315
+ });
316
+ },
317
+ });
318
+
319
+ const configOne = parseLocationConfig({ enabled: true, sources: [{ id: "owntracks" }] });
320
+ const absent = await ensureConfiguredLocationProviders(configOne, {
321
+ env: ENV,
322
+ importModule: async () => {
323
+ throw Object.assign(new Error("Cannot find module '@remnic/connector-owntracks'"), {
324
+ code: "ERR_MODULE_NOT_FOUND",
325
+ });
326
+ },
327
+ });
328
+ assert.deepEqual(absent, []);
329
+
330
+ const configBoth = parseLocationConfig({
331
+ enabled: true,
332
+ sources: [{ id: "owntracks" }, { id: "second-provider" }],
333
+ });
334
+ const partialAfterFailure = await ensureConfiguredLocationProviders(configBoth, {
335
+ env: ENV,
336
+ importModule: async (specifier: string) => {
337
+ if (specifier === "@remnic/connector-owntracks") {
338
+ throw new Error("syntax error in broken optional package");
339
+ }
340
+ const mod: OwntracksModule = {
341
+ ensureOwntracksRegistered: () => {
342
+ registerLocationProvider(stubLocationProvider("second-provider", "Second"));
343
+ return true;
344
+ },
345
+ };
346
+ return mod;
347
+ },
348
+ });
349
+ assert.deepEqual(partialAfterFailure, ["second-provider"]);
350
+ });
351
+
352
+ test("getSetup dependency overrides global setup lookup", async () => {
353
+ let calledSpecifier = "";
354
+ const injectedEntry: LocationProviderSetupEntry = {
355
+ id: "custom-seam",
356
+ packageSpecifier: "@remnic/connector-seam",
357
+ setup: async (context) => {
358
+ await context.loadPackage<OwntracksModule>();
359
+ registerLocationProvider(stubLocationProvider("custom-seam", "Custom Seam"));
360
+ return true;
361
+ },
362
+ };
363
+
364
+ const registered = await ensureConfiguredLocationProviders(
365
+ parseLocationConfig({ enabled: true, sources: [{ id: "custom-seam" }] }),
366
+ {
367
+ importModule: async (specifier: string) => {
368
+ calledSpecifier = specifier;
369
+ return {};
370
+ },
371
+ getSetup: (id: string) => (id === "custom-seam" ? injectedEntry : undefined),
372
+ },
373
+ );
374
+ assert.deepEqual(registered, ["custom-seam"]);
375
+ assert.equal(calledSpecifier, "@remnic/connector-seam");
376
+ assert.equal(getLocationProviderSetup("custom-seam"), undefined);
377
+ });