@opensip-cli/core 0.1.0

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 (604) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +31 -0
  4. package/dist/__tests__/config-resolution.test.d.ts +2 -0
  5. package/dist/__tests__/config-resolution.test.d.ts.map +1 -0
  6. package/dist/__tests__/config-resolution.test.js +94 -0
  7. package/dist/__tests__/config-resolution.test.js.map +1 -0
  8. package/dist/__tests__/public-api.test.d.ts +16 -0
  9. package/dist/__tests__/public-api.test.d.ts.map +1 -0
  10. package/dist/__tests__/public-api.test.js +209 -0
  11. package/dist/__tests__/public-api.test.js.map +1 -0
  12. package/dist/__tests__/signal-batch.test.d.ts +2 -0
  13. package/dist/__tests__/signal-batch.test.d.ts.map +1 -0
  14. package/dist/__tests__/signal-batch.test.js +39 -0
  15. package/dist/__tests__/signal-batch.test.js.map +1 -0
  16. package/dist/__tests__/signal-sink.test.d.ts +2 -0
  17. package/dist/__tests__/signal-sink.test.d.ts.map +1 -0
  18. package/dist/__tests__/signal-sink.test.js +25 -0
  19. package/dist/__tests__/signal-sink.test.js.map +1 -0
  20. package/dist/__tests__/strip-utils.test.d.ts +2 -0
  21. package/dist/__tests__/strip-utils.test.d.ts.map +1 -0
  22. package/dist/__tests__/strip-utils.test.js +397 -0
  23. package/dist/__tests__/strip-utils.test.js.map +1 -0
  24. package/dist/__tests__/text-tree.test.d.ts +2 -0
  25. package/dist/__tests__/text-tree.test.d.ts.map +1 -0
  26. package/dist/__tests__/text-tree.test.js +31 -0
  27. package/dist/__tests__/text-tree.test.js.map +1 -0
  28. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts +2 -0
  29. package/dist/baseline/__tests__/fingerprint-strategy.test.d.ts.map +1 -0
  30. package/dist/baseline/__tests__/fingerprint-strategy.test.js +69 -0
  31. package/dist/baseline/__tests__/fingerprint-strategy.test.js.map +1 -0
  32. package/dist/baseline/fingerprint-strategy.d.ts +70 -0
  33. package/dist/baseline/fingerprint-strategy.d.ts.map +1 -0
  34. package/dist/baseline/fingerprint-strategy.js +90 -0
  35. package/dist/baseline/fingerprint-strategy.js.map +1 -0
  36. package/dist/config-resolution.d.ts +27 -0
  37. package/dist/config-resolution.d.ts.map +1 -0
  38. package/dist/config-resolution.js +92 -0
  39. package/dist/config-resolution.js.map +1 -0
  40. package/dist/index.d.ts +81 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +165 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts +2 -0
  45. package/dist/languages/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
  46. package/dist/languages/__tests__/content-filter-dispatch.test.js +87 -0
  47. package/dist/languages/__tests__/content-filter-dispatch.test.js.map +1 -0
  48. package/dist/languages/__tests__/non-code-formats.test.d.ts +2 -0
  49. package/dist/languages/__tests__/non-code-formats.test.d.ts.map +1 -0
  50. package/dist/languages/__tests__/non-code-formats.test.js +31 -0
  51. package/dist/languages/__tests__/non-code-formats.test.js.map +1 -0
  52. package/dist/languages/__tests__/parse-cache.test.d.ts +2 -0
  53. package/dist/languages/__tests__/parse-cache.test.d.ts.map +1 -0
  54. package/dist/languages/__tests__/parse-cache.test.js +228 -0
  55. package/dist/languages/__tests__/parse-cache.test.js.map +1 -0
  56. package/dist/languages/__tests__/registry.test.d.ts +2 -0
  57. package/dist/languages/__tests__/registry.test.d.ts.map +1 -0
  58. package/dist/languages/__tests__/registry.test.js +193 -0
  59. package/dist/languages/__tests__/registry.test.js.map +1 -0
  60. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts +2 -0
  61. package/dist/languages/__tests__/workspace-unit-contract.test.d.ts.map +1 -0
  62. package/dist/languages/__tests__/workspace-unit-contract.test.js +66 -0
  63. package/dist/languages/__tests__/workspace-unit-contract.test.js.map +1 -0
  64. package/dist/languages/adapter.d.ts +66 -0
  65. package/dist/languages/adapter.d.ts.map +1 -0
  66. package/dist/languages/adapter.js +2 -0
  67. package/dist/languages/adapter.js.map +1 -0
  68. package/dist/languages/content-filter-dispatch.d.ts +36 -0
  69. package/dist/languages/content-filter-dispatch.d.ts.map +1 -0
  70. package/dist/languages/content-filter-dispatch.js +75 -0
  71. package/dist/languages/content-filter-dispatch.js.map +1 -0
  72. package/dist/languages/generic-types.d.ts +22 -0
  73. package/dist/languages/generic-types.d.ts.map +1 -0
  74. package/dist/languages/generic-types.js +3 -0
  75. package/dist/languages/generic-types.js.map +1 -0
  76. package/dist/languages/index.d.ts +12 -0
  77. package/dist/languages/index.d.ts.map +1 -0
  78. package/dist/languages/index.js +7 -0
  79. package/dist/languages/index.js.map +1 -0
  80. package/dist/languages/non-code-formats.d.ts +37 -0
  81. package/dist/languages/non-code-formats.d.ts.map +1 -0
  82. package/dist/languages/non-code-formats.js +45 -0
  83. package/dist/languages/non-code-formats.js.map +1 -0
  84. package/dist/languages/parse-cache-class.d.ts +69 -0
  85. package/dist/languages/parse-cache-class.d.ts.map +1 -0
  86. package/dist/languages/parse-cache-class.js +135 -0
  87. package/dist/languages/parse-cache-class.js.map +1 -0
  88. package/dist/languages/parse-cache.d.ts +54 -0
  89. package/dist/languages/parse-cache.d.ts.map +1 -0
  90. package/dist/languages/parse-cache.js +88 -0
  91. package/dist/languages/parse-cache.js.map +1 -0
  92. package/dist/languages/registry.d.ts +35 -0
  93. package/dist/languages/registry.d.ts.map +1 -0
  94. package/dist/languages/registry.js +123 -0
  95. package/dist/languages/registry.js.map +1 -0
  96. package/dist/languages/strip-scanners.d.ts +170 -0
  97. package/dist/languages/strip-scanners.d.ts.map +1 -0
  98. package/dist/languages/strip-scanners.js +233 -0
  99. package/dist/languages/strip-scanners.js.map +1 -0
  100. package/dist/languages/strip-utils.d.ts +66 -0
  101. package/dist/languages/strip-utils.d.ts.map +1 -0
  102. package/dist/languages/strip-utils.js +88 -0
  103. package/dist/languages/strip-utils.js.map +1 -0
  104. package/dist/languages/text-tree.d.ts +44 -0
  105. package/dist/languages/text-tree.d.ts.map +1 -0
  106. package/dist/languages/text-tree.js +34 -0
  107. package/dist/languages/text-tree.js.map +1 -0
  108. package/dist/languages/workspace-unit.d.ts +18 -0
  109. package/dist/languages/workspace-unit.d.ts.map +1 -0
  110. package/dist/languages/workspace-unit.js +2 -0
  111. package/dist/languages/workspace-unit.js.map +1 -0
  112. package/dist/lib/__tests__/config-version.test.d.ts +12 -0
  113. package/dist/lib/__tests__/config-version.test.d.ts.map +1 -0
  114. package/dist/lib/__tests__/config-version.test.js +92 -0
  115. package/dist/lib/__tests__/config-version.test.js.map +1 -0
  116. package/dist/lib/__tests__/diagnostics-bus.test.d.ts +7 -0
  117. package/dist/lib/__tests__/diagnostics-bus.test.d.ts.map +1 -0
  118. package/dist/lib/__tests__/diagnostics-bus.test.js +44 -0
  119. package/dist/lib/__tests__/diagnostics-bus.test.js.map +1 -0
  120. package/dist/lib/__tests__/env-registry.test.d.ts +7 -0
  121. package/dist/lib/__tests__/env-registry.test.d.ts.map +1 -0
  122. package/dist/lib/__tests__/env-registry.test.js +82 -0
  123. package/dist/lib/__tests__/env-registry.test.js.map +1 -0
  124. package/dist/lib/__tests__/errors.test.d.ts +2 -0
  125. package/dist/lib/__tests__/errors.test.d.ts.map +1 -0
  126. package/dist/lib/__tests__/errors.test.js +218 -0
  127. package/dist/lib/__tests__/errors.test.js.map +1 -0
  128. package/dist/lib/__tests__/format.test.d.ts +2 -0
  129. package/dist/lib/__tests__/format.test.d.ts.map +1 -0
  130. package/dist/lib/__tests__/format.test.js +23 -0
  131. package/dist/lib/__tests__/format.test.js.map +1 -0
  132. package/dist/lib/__tests__/ids.test.d.ts +2 -0
  133. package/dist/lib/__tests__/ids.test.d.ts.map +1 -0
  134. package/dist/lib/__tests__/ids.test.js +80 -0
  135. package/dist/lib/__tests__/ids.test.js.map +1 -0
  136. package/dist/lib/__tests__/logger.test.d.ts +2 -0
  137. package/dist/lib/__tests__/logger.test.d.ts.map +1 -0
  138. package/dist/lib/__tests__/logger.test.js +284 -0
  139. package/dist/lib/__tests__/logger.test.js.map +1 -0
  140. package/dist/lib/__tests__/package-version.test.d.ts +2 -0
  141. package/dist/lib/__tests__/package-version.test.d.ts.map +1 -0
  142. package/dist/lib/__tests__/package-version.test.js +47 -0
  143. package/dist/lib/__tests__/package-version.test.js.map +1 -0
  144. package/dist/lib/__tests__/paths.test.d.ts +5 -0
  145. package/dist/lib/__tests__/paths.test.d.ts.map +1 -0
  146. package/dist/lib/__tests__/paths.test.js +59 -0
  147. package/dist/lib/__tests__/paths.test.js.map +1 -0
  148. package/dist/lib/__tests__/payload-version.test.d.ts +2 -0
  149. package/dist/lib/__tests__/payload-version.test.d.ts.map +1 -0
  150. package/dist/lib/__tests__/payload-version.test.js +35 -0
  151. package/dist/lib/__tests__/payload-version.test.js.map +1 -0
  152. package/dist/lib/__tests__/phantom-detect.test.d.ts +10 -0
  153. package/dist/lib/__tests__/phantom-detect.test.d.ts.map +1 -0
  154. package/dist/lib/__tests__/phantom-detect.test.js +84 -0
  155. package/dist/lib/__tests__/phantom-detect.test.js.map +1 -0
  156. package/dist/lib/__tests__/project-context.test.d.ts +10 -0
  157. package/dist/lib/__tests__/project-context.test.d.ts.map +1 -0
  158. package/dist/lib/__tests__/project-context.test.js +240 -0
  159. package/dist/lib/__tests__/project-context.test.js.map +1 -0
  160. package/dist/lib/__tests__/registry.test.d.ts +2 -0
  161. package/dist/lib/__tests__/registry.test.d.ts.map +1 -0
  162. package/dist/lib/__tests__/registry.test.js +333 -0
  163. package/dist/lib/__tests__/registry.test.js.map +1 -0
  164. package/dist/lib/__tests__/retry.test.d.ts +2 -0
  165. package/dist/lib/__tests__/retry.test.d.ts.map +1 -0
  166. package/dist/lib/__tests__/retry.test.js +71 -0
  167. package/dist/lib/__tests__/retry.test.js.map +1 -0
  168. package/dist/lib/__tests__/run-diagnostics.test.d.ts +9 -0
  169. package/dist/lib/__tests__/run-diagnostics.test.d.ts.map +1 -0
  170. package/dist/lib/__tests__/run-diagnostics.test.js +61 -0
  171. package/dist/lib/__tests__/run-diagnostics.test.js.map +1 -0
  172. package/dist/lib/__tests__/run-scope.test.d.ts +2 -0
  173. package/dist/lib/__tests__/run-scope.test.d.ts.map +1 -0
  174. package/dist/lib/__tests__/run-scope.test.js +202 -0
  175. package/dist/lib/__tests__/run-scope.test.js.map +1 -0
  176. package/dist/lib/__tests__/run-timer.test.d.ts +2 -0
  177. package/dist/lib/__tests__/run-timer.test.d.ts.map +1 -0
  178. package/dist/lib/__tests__/run-timer.test.js +152 -0
  179. package/dist/lib/__tests__/run-timer.test.js.map +1 -0
  180. package/dist/lib/__tests__/severity-policy.test.d.ts +6 -0
  181. package/dist/lib/__tests__/severity-policy.test.d.ts.map +1 -0
  182. package/dist/lib/__tests__/severity-policy.test.js +47 -0
  183. package/dist/lib/__tests__/severity-policy.test.js.map +1 -0
  184. package/dist/lib/__tests__/telemetry.test.d.ts +2 -0
  185. package/dist/lib/__tests__/telemetry.test.d.ts.map +1 -0
  186. package/dist/lib/__tests__/telemetry.test.js +212 -0
  187. package/dist/lib/__tests__/telemetry.test.js.map +1 -0
  188. package/dist/lib/__tests__/verdict-policy.test.d.ts +7 -0
  189. package/dist/lib/__tests__/verdict-policy.test.d.ts.map +1 -0
  190. package/dist/lib/__tests__/verdict-policy.test.js +91 -0
  191. package/dist/lib/__tests__/verdict-policy.test.js.map +1 -0
  192. package/dist/lib/__tests__/yaml.test.d.ts +6 -0
  193. package/dist/lib/__tests__/yaml.test.d.ts.map +1 -0
  194. package/dist/lib/__tests__/yaml.test.js +79 -0
  195. package/dist/lib/__tests__/yaml.test.js.map +1 -0
  196. package/dist/lib/config-version.d.ts +49 -0
  197. package/dist/lib/config-version.d.ts.map +1 -0
  198. package/dist/lib/config-version.js +56 -0
  199. package/dist/lib/config-version.js.map +1 -0
  200. package/dist/lib/diagnostics-bus.d.ts +48 -0
  201. package/dist/lib/diagnostics-bus.d.ts.map +1 -0
  202. package/dist/lib/diagnostics-bus.js +74 -0
  203. package/dist/lib/diagnostics-bus.js.map +1 -0
  204. package/dist/lib/env-registry.d.ts +108 -0
  205. package/dist/lib/env-registry.d.ts.map +1 -0
  206. package/dist/lib/env-registry.js +92 -0
  207. package/dist/lib/env-registry.js.map +1 -0
  208. package/dist/lib/errors.d.ts +132 -0
  209. package/dist/lib/errors.d.ts.map +1 -0
  210. package/dist/lib/errors.js +160 -0
  211. package/dist/lib/errors.js.map +1 -0
  212. package/dist/lib/execution/__tests__/execution.test.d.ts +7 -0
  213. package/dist/lib/execution/__tests__/execution.test.d.ts.map +1 -0
  214. package/dist/lib/execution/__tests__/execution.test.js +254 -0
  215. package/dist/lib/execution/__tests__/execution.test.js.map +1 -0
  216. package/dist/lib/execution/index.d.ts +15 -0
  217. package/dist/lib/execution/index.d.ts.map +1 -0
  218. package/dist/lib/execution/index.js +10 -0
  219. package/dist/lib/execution/index.js.map +1 -0
  220. package/dist/lib/execution/options.d.ts +32 -0
  221. package/dist/lib/execution/options.d.ts.map +1 -0
  222. package/dist/lib/execution/options.js +15 -0
  223. package/dist/lib/execution/options.js.map +1 -0
  224. package/dist/lib/execution/pipeline.d.ts +36 -0
  225. package/dist/lib/execution/pipeline.d.ts.map +1 -0
  226. package/dist/lib/execution/pipeline.js +38 -0
  227. package/dist/lib/execution/pipeline.js.map +1 -0
  228. package/dist/lib/execution/retry.d.ts +38 -0
  229. package/dist/lib/execution/retry.d.ts.map +1 -0
  230. package/dist/lib/execution/retry.js +56 -0
  231. package/dist/lib/execution/retry.js.map +1 -0
  232. package/dist/lib/execution/run-with-timeout.d.ts +46 -0
  233. package/dist/lib/execution/run-with-timeout.d.ts.map +1 -0
  234. package/dist/lib/execution/run-with-timeout.js +86 -0
  235. package/dist/lib/execution/run-with-timeout.js.map +1 -0
  236. package/dist/lib/execution/schedule.d.ts +62 -0
  237. package/dist/lib/execution/schedule.d.ts.map +1 -0
  238. package/dist/lib/execution/schedule.js +130 -0
  239. package/dist/lib/execution/schedule.js.map +1 -0
  240. package/dist/lib/format.d.ts +17 -0
  241. package/dist/lib/format.d.ts.map +1 -0
  242. package/dist/lib/format.js +26 -0
  243. package/dist/lib/format.js.map +1 -0
  244. package/dist/lib/ids.d.ts +13 -0
  245. package/dist/lib/ids.d.ts.map +1 -0
  246. package/dist/lib/ids.js +48 -0
  247. package/dist/lib/ids.js.map +1 -0
  248. package/dist/lib/logger.d.ts +166 -0
  249. package/dist/lib/logger.d.ts.map +1 -0
  250. package/dist/lib/logger.js +283 -0
  251. package/dist/lib/logger.js.map +1 -0
  252. package/dist/lib/package-version.d.ts +17 -0
  253. package/dist/lib/package-version.d.ts.map +1 -0
  254. package/dist/lib/package-version.js +52 -0
  255. package/dist/lib/package-version.js.map +1 -0
  256. package/dist/lib/paths.d.ts +139 -0
  257. package/dist/lib/paths.d.ts.map +1 -0
  258. package/dist/lib/paths.js +105 -0
  259. package/dist/lib/paths.js.map +1 -0
  260. package/dist/lib/payload-version.d.ts +15 -0
  261. package/dist/lib/payload-version.d.ts.map +1 -0
  262. package/dist/lib/payload-version.js +24 -0
  263. package/dist/lib/payload-version.js.map +1 -0
  264. package/dist/lib/phantom-detect.d.ts +21 -0
  265. package/dist/lib/phantom-detect.d.ts.map +1 -0
  266. package/dist/lib/phantom-detect.js +76 -0
  267. package/dist/lib/phantom-detect.js.map +1 -0
  268. package/dist/lib/project-context.d.ts +66 -0
  269. package/dist/lib/project-context.d.ts.map +1 -0
  270. package/dist/lib/project-context.js +112 -0
  271. package/dist/lib/project-context.js.map +1 -0
  272. package/dist/lib/recipe-id.d.ts +13 -0
  273. package/dist/lib/recipe-id.d.ts.map +1 -0
  274. package/dist/lib/recipe-id.js +15 -0
  275. package/dist/lib/recipe-id.js.map +1 -0
  276. package/dist/lib/registry.d.ts +98 -0
  277. package/dist/lib/registry.d.ts.map +1 -0
  278. package/dist/lib/registry.js +152 -0
  279. package/dist/lib/registry.js.map +1 -0
  280. package/dist/lib/retry.d.ts +26 -0
  281. package/dist/lib/retry.d.ts.map +1 -0
  282. package/dist/lib/retry.js +48 -0
  283. package/dist/lib/retry.js.map +1 -0
  284. package/dist/lib/run-diagnostics.d.ts +64 -0
  285. package/dist/lib/run-diagnostics.d.ts.map +1 -0
  286. package/dist/lib/run-diagnostics.js +25 -0
  287. package/dist/lib/run-diagnostics.js.map +1 -0
  288. package/dist/lib/run-scope.d.ts +167 -0
  289. package/dist/lib/run-scope.d.ts.map +1 -0
  290. package/dist/lib/run-scope.js +176 -0
  291. package/dist/lib/run-scope.js.map +1 -0
  292. package/dist/lib/run-timer.d.ts +82 -0
  293. package/dist/lib/run-timer.d.ts.map +1 -0
  294. package/dist/lib/run-timer.js +79 -0
  295. package/dist/lib/run-timer.js.map +1 -0
  296. package/dist/lib/scope-types.d.ts +172 -0
  297. package/dist/lib/scope-types.d.ts.map +1 -0
  298. package/dist/lib/scope-types.js +27 -0
  299. package/dist/lib/scope-types.js.map +1 -0
  300. package/dist/lib/severity-policy.d.ts +38 -0
  301. package/dist/lib/severity-policy.d.ts.map +1 -0
  302. package/dist/lib/severity-policy.js +44 -0
  303. package/dist/lib/severity-policy.js.map +1 -0
  304. package/dist/lib/telemetry.d.ts +93 -0
  305. package/dist/lib/telemetry.d.ts.map +1 -0
  306. package/dist/lib/telemetry.js +144 -0
  307. package/dist/lib/telemetry.js.map +1 -0
  308. package/dist/lib/ui-context.d.ts +34 -0
  309. package/dist/lib/ui-context.d.ts.map +1 -0
  310. package/dist/lib/ui-context.js +16 -0
  311. package/dist/lib/ui-context.js.map +1 -0
  312. package/dist/lib/verdict-policy.d.ts +71 -0
  313. package/dist/lib/verdict-policy.d.ts.map +1 -0
  314. package/dist/lib/verdict-policy.js +82 -0
  315. package/dist/lib/verdict-policy.js.map +1 -0
  316. package/dist/lib/yaml.d.ts +74 -0
  317. package/dist/lib/yaml.d.ts.map +1 -0
  318. package/dist/lib/yaml.js +118 -0
  319. package/dist/lib/yaml.js.map +1 -0
  320. package/dist/plugins/__tests__/as-if-external.test.d.ts +18 -0
  321. package/dist/plugins/__tests__/as-if-external.test.d.ts.map +1 -0
  322. package/dist/plugins/__tests__/as-if-external.test.js +159 -0
  323. package/dist/plugins/__tests__/as-if-external.test.js.map +1 -0
  324. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts +8 -0
  325. package/dist/plugins/__tests__/authored-tool-discovery.test.d.ts.map +1 -0
  326. package/dist/plugins/__tests__/authored-tool-discovery.test.js +97 -0
  327. package/dist/plugins/__tests__/authored-tool-discovery.test.js.map +1 -0
  328. package/dist/plugins/__tests__/capability-discovery.test.d.ts +2 -0
  329. package/dist/plugins/__tests__/capability-discovery.test.d.ts.map +1 -0
  330. package/dist/plugins/__tests__/capability-discovery.test.js +349 -0
  331. package/dist/plugins/__tests__/capability-discovery.test.js.map +1 -0
  332. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts +2 -0
  333. package/dist/plugins/__tests__/capability-from-manifest.test.d.ts.map +1 -0
  334. package/dist/plugins/__tests__/capability-from-manifest.test.js +172 -0
  335. package/dist/plugins/__tests__/capability-from-manifest.test.js.map +1 -0
  336. package/dist/plugins/__tests__/capability-loader.test.d.ts +2 -0
  337. package/dist/plugins/__tests__/capability-loader.test.d.ts.map +1 -0
  338. package/dist/plugins/__tests__/capability-loader.test.js +122 -0
  339. package/dist/plugins/__tests__/capability-loader.test.js.map +1 -0
  340. package/dist/plugins/__tests__/capability-registry.test.d.ts +2 -0
  341. package/dist/plugins/__tests__/capability-registry.test.d.ts.map +1 -0
  342. package/dist/plugins/__tests__/capability-registry.test.js +185 -0
  343. package/dist/plugins/__tests__/capability-registry.test.js.map +1 -0
  344. package/dist/plugins/__tests__/discover.test.d.ts +2 -0
  345. package/dist/plugins/__tests__/discover.test.d.ts.map +1 -0
  346. package/dist/plugins/__tests__/discover.test.js +311 -0
  347. package/dist/plugins/__tests__/discover.test.js.map +1 -0
  348. package/dist/plugins/__tests__/loader.test.d.ts +2 -0
  349. package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
  350. package/dist/plugins/__tests__/loader.test.js +191 -0
  351. package/dist/plugins/__tests__/loader.test.js.map +1 -0
  352. package/dist/plugins/__tests__/manifest-discovery.test.d.ts +2 -0
  353. package/dist/plugins/__tests__/manifest-discovery.test.d.ts.map +1 -0
  354. package/dist/plugins/__tests__/manifest-discovery.test.js +132 -0
  355. package/dist/plugins/__tests__/manifest-discovery.test.js.map +1 -0
  356. package/dist/plugins/__tests__/manifest-loader.test.d.ts +2 -0
  357. package/dist/plugins/__tests__/manifest-loader.test.d.ts.map +1 -0
  358. package/dist/plugins/__tests__/manifest-loader.test.js +434 -0
  359. package/dist/plugins/__tests__/manifest-loader.test.js.map +1 -0
  360. package/dist/plugins/__tests__/marker-discovery.test.d.ts +2 -0
  361. package/dist/plugins/__tests__/marker-discovery.test.d.ts.map +1 -0
  362. package/dist/plugins/__tests__/marker-discovery.test.js +164 -0
  363. package/dist/plugins/__tests__/marker-discovery.test.js.map +1 -0
  364. package/dist/plugins/__tests__/node-modules-walk.test.d.ts +2 -0
  365. package/dist/plugins/__tests__/node-modules-walk.test.d.ts.map +1 -0
  366. package/dist/plugins/__tests__/node-modules-walk.test.js +76 -0
  367. package/dist/plugins/__tests__/node-modules-walk.test.js.map +1 -0
  368. package/dist/plugins/__tests__/package-entry.test.d.ts +9 -0
  369. package/dist/plugins/__tests__/package-entry.test.d.ts.map +1 -0
  370. package/dist/plugins/__tests__/package-entry.test.js +117 -0
  371. package/dist/plugins/__tests__/package-entry.test.js.map +1 -0
  372. package/dist/plugins/__tests__/recipe-loader.test.d.ts +2 -0
  373. package/dist/plugins/__tests__/recipe-loader.test.d.ts.map +1 -0
  374. package/dist/plugins/__tests__/recipe-loader.test.js +130 -0
  375. package/dist/plugins/__tests__/recipe-loader.test.js.map +1 -0
  376. package/dist/plugins/__tests__/scope-validation.test.d.ts +2 -0
  377. package/dist/plugins/__tests__/scope-validation.test.d.ts.map +1 -0
  378. package/dist/plugins/__tests__/scope-validation.test.js +68 -0
  379. package/dist/plugins/__tests__/scope-validation.test.js.map +1 -0
  380. package/dist/plugins/__tests__/single-core-guard.test.d.ts +10 -0
  381. package/dist/plugins/__tests__/single-core-guard.test.d.ts.map +1 -0
  382. package/dist/plugins/__tests__/single-core-guard.test.js +89 -0
  383. package/dist/plugins/__tests__/single-core-guard.test.js.map +1 -0
  384. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts +2 -0
  385. package/dist/plugins/__tests__/tool-package-discovery.test.d.ts.map +1 -0
  386. package/dist/plugins/__tests__/tool-package-discovery.test.js +215 -0
  387. package/dist/plugins/__tests__/tool-package-discovery.test.js.map +1 -0
  388. package/dist/plugins/authored-tool-discovery.d.ts +45 -0
  389. package/dist/plugins/authored-tool-discovery.d.ts.map +1 -0
  390. package/dist/plugins/authored-tool-discovery.js +61 -0
  391. package/dist/plugins/authored-tool-discovery.js.map +1 -0
  392. package/dist/plugins/capability-discovery.d.ts +80 -0
  393. package/dist/plugins/capability-discovery.d.ts.map +1 -0
  394. package/dist/plugins/capability-discovery.js +278 -0
  395. package/dist/plugins/capability-discovery.js.map +1 -0
  396. package/dist/plugins/capability-loader.d.ts +50 -0
  397. package/dist/plugins/capability-loader.d.ts.map +1 -0
  398. package/dist/plugins/capability-loader.js +85 -0
  399. package/dist/plugins/capability-loader.js.map +1 -0
  400. package/dist/plugins/capability-registry.d.ts +169 -0
  401. package/dist/plugins/capability-registry.d.ts.map +1 -0
  402. package/dist/plugins/capability-registry.js +319 -0
  403. package/dist/plugins/capability-registry.js.map +1 -0
  404. package/dist/plugins/discover.d.ts +64 -0
  405. package/dist/plugins/discover.d.ts.map +1 -0
  406. package/dist/plugins/discover.js +303 -0
  407. package/dist/plugins/discover.js.map +1 -0
  408. package/dist/plugins/index.d.ts +37 -0
  409. package/dist/plugins/index.d.ts.map +1 -0
  410. package/dist/plugins/index.js +40 -0
  411. package/dist/plugins/index.js.map +1 -0
  412. package/dist/plugins/json-guards.d.ts +11 -0
  413. package/dist/plugins/json-guards.d.ts.map +1 -0
  414. package/dist/plugins/json-guards.js +15 -0
  415. package/dist/plugins/json-guards.js.map +1 -0
  416. package/dist/plugins/loader.d.ts +67 -0
  417. package/dist/plugins/loader.d.ts.map +1 -0
  418. package/dist/plugins/loader.js +137 -0
  419. package/dist/plugins/loader.js.map +1 -0
  420. package/dist/plugins/manifest-discovery.d.ts +28 -0
  421. package/dist/plugins/manifest-discovery.d.ts.map +1 -0
  422. package/dist/plugins/manifest-discovery.js +103 -0
  423. package/dist/plugins/manifest-discovery.js.map +1 -0
  424. package/dist/plugins/manifest-loader.d.ts +120 -0
  425. package/dist/plugins/manifest-loader.d.ts.map +1 -0
  426. package/dist/plugins/manifest-loader.js +410 -0
  427. package/dist/plugins/manifest-loader.js.map +1 -0
  428. package/dist/plugins/marker-discovery.d.ts +115 -0
  429. package/dist/plugins/marker-discovery.d.ts.map +1 -0
  430. package/dist/plugins/marker-discovery.js +172 -0
  431. package/dist/plugins/marker-discovery.js.map +1 -0
  432. package/dist/plugins/node-modules-walk.d.ts +61 -0
  433. package/dist/plugins/node-modules-walk.d.ts.map +1 -0
  434. package/dist/plugins/node-modules-walk.js +99 -0
  435. package/dist/plugins/node-modules-walk.js.map +1 -0
  436. package/dist/plugins/package-entry.d.ts +38 -0
  437. package/dist/plugins/package-entry.d.ts.map +1 -0
  438. package/dist/plugins/package-entry.js +86 -0
  439. package/dist/plugins/package-entry.js.map +1 -0
  440. package/dist/plugins/recipe-loader.d.ts +63 -0
  441. package/dist/plugins/recipe-loader.d.ts.map +1 -0
  442. package/dist/plugins/recipe-loader.js +67 -0
  443. package/dist/plugins/recipe-loader.js.map +1 -0
  444. package/dist/plugins/scope-validation.d.ts +35 -0
  445. package/dist/plugins/scope-validation.d.ts.map +1 -0
  446. package/dist/plugins/scope-validation.js +55 -0
  447. package/dist/plugins/scope-validation.js.map +1 -0
  448. package/dist/plugins/single-core-guard.d.ts +28 -0
  449. package/dist/plugins/single-core-guard.d.ts.map +1 -0
  450. package/dist/plugins/single-core-guard.js +69 -0
  451. package/dist/plugins/single-core-guard.js.map +1 -0
  452. package/dist/plugins/tool-package-discovery.d.ts +93 -0
  453. package/dist/plugins/tool-package-discovery.d.ts.map +1 -0
  454. package/dist/plugins/tool-package-discovery.js +118 -0
  455. package/dist/plugins/tool-package-discovery.js.map +1 -0
  456. package/dist/plugins/types.d.ts +78 -0
  457. package/dist/plugins/types.d.ts.map +1 -0
  458. package/dist/plugins/types.js +15 -0
  459. package/dist/plugins/types.js.map +1 -0
  460. package/dist/recipes/__tests__/registry.test.d.ts +2 -0
  461. package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
  462. package/dist/recipes/__tests__/registry.test.js +170 -0
  463. package/dist/recipes/__tests__/registry.test.js.map +1 -0
  464. package/dist/recipes/__tests__/selector.test.d.ts +20 -0
  465. package/dist/recipes/__tests__/selector.test.d.ts.map +1 -0
  466. package/dist/recipes/__tests__/selector.test.js +173 -0
  467. package/dist/recipes/__tests__/selector.test.js.map +1 -0
  468. package/dist/recipes/__tests__/unit-config.test.d.ts +7 -0
  469. package/dist/recipes/__tests__/unit-config.test.d.ts.map +1 -0
  470. package/dist/recipes/__tests__/unit-config.test.js +52 -0
  471. package/dist/recipes/__tests__/unit-config.test.js.map +1 -0
  472. package/dist/recipes/registry.d.ts +105 -0
  473. package/dist/recipes/registry.d.ts.map +1 -0
  474. package/dist/recipes/registry.js +141 -0
  475. package/dist/recipes/registry.js.map +1 -0
  476. package/dist/recipes/selector.d.ts +112 -0
  477. package/dist/recipes/selector.d.ts.map +1 -0
  478. package/dist/recipes/selector.js +134 -0
  479. package/dist/recipes/selector.js.map +1 -0
  480. package/dist/recipes/unit-config.d.ts +63 -0
  481. package/dist/recipes/unit-config.d.ts.map +1 -0
  482. package/dist/recipes/unit-config.js +68 -0
  483. package/dist/recipes/unit-config.js.map +1 -0
  484. package/dist/runtime/__tests__/in-process-transport.test.d.ts +6 -0
  485. package/dist/runtime/__tests__/in-process-transport.test.d.ts.map +1 -0
  486. package/dist/runtime/__tests__/in-process-transport.test.js +73 -0
  487. package/dist/runtime/__tests__/in-process-transport.test.js.map +1 -0
  488. package/dist/runtime/__tests__/subprocess-transport.test.d.ts +11 -0
  489. package/dist/runtime/__tests__/subprocess-transport.test.d.ts.map +1 -0
  490. package/dist/runtime/__tests__/subprocess-transport.test.js +118 -0
  491. package/dist/runtime/__tests__/subprocess-transport.test.js.map +1 -0
  492. package/dist/runtime/in-process-transport.d.ts +20 -0
  493. package/dist/runtime/in-process-transport.d.ts.map +1 -0
  494. package/dist/runtime/in-process-transport.js +49 -0
  495. package/dist/runtime/in-process-transport.js.map +1 -0
  496. package/dist/runtime/progress-transport.d.ts +73 -0
  497. package/dist/runtime/progress-transport.d.ts.map +1 -0
  498. package/dist/runtime/progress-transport.js +17 -0
  499. package/dist/runtime/progress-transport.js.map +1 -0
  500. package/dist/runtime/subprocess-transport.d.ts +43 -0
  501. package/dist/runtime/subprocess-transport.d.ts.map +1 -0
  502. package/dist/runtime/subprocess-transport.js +134 -0
  503. package/dist/runtime/subprocess-transport.js.map +1 -0
  504. package/dist/signals/comment-openers.d.ts +29 -0
  505. package/dist/signals/comment-openers.d.ts.map +1 -0
  506. package/dist/signals/comment-openers.js +41 -0
  507. package/dist/signals/comment-openers.js.map +1 -0
  508. package/dist/signals/comment-openers.test.d.ts +7 -0
  509. package/dist/signals/comment-openers.test.d.ts.map +1 -0
  510. package/dist/signals/comment-openers.test.js +41 -0
  511. package/dist/signals/comment-openers.test.js.map +1 -0
  512. package/dist/signals/create-signal-from-violation.d.ts +29 -0
  513. package/dist/signals/create-signal-from-violation.d.ts.map +1 -0
  514. package/dist/signals/create-signal-from-violation.js +29 -0
  515. package/dist/signals/create-signal-from-violation.js.map +1 -0
  516. package/dist/signals/signal-sink.d.ts +49 -0
  517. package/dist/signals/signal-sink.d.ts.map +1 -0
  518. package/dist/signals/signal-sink.js +6 -0
  519. package/dist/signals/signal-sink.js.map +1 -0
  520. package/dist/signals/suppress.d.ts +102 -0
  521. package/dist/signals/suppress.d.ts.map +1 -0
  522. package/dist/signals/suppress.js +325 -0
  523. package/dist/signals/suppress.js.map +1 -0
  524. package/dist/signals/suppress.test.d.ts +2 -0
  525. package/dist/signals/suppress.test.d.ts.map +1 -0
  526. package/dist/signals/suppress.test.js +213 -0
  527. package/dist/signals/suppress.test.js.map +1 -0
  528. package/dist/tools/__tests__/command-spec.test.d.ts +2 -0
  529. package/dist/tools/__tests__/command-spec.test.d.ts.map +1 -0
  530. package/dist/tools/__tests__/command-spec.test.js +191 -0
  531. package/dist/tools/__tests__/command-spec.test.js.map +1 -0
  532. package/dist/tools/__tests__/compatibility.test.d.ts +5 -0
  533. package/dist/tools/__tests__/compatibility.test.d.ts.map +1 -0
  534. package/dist/tools/__tests__/compatibility.test.js +41 -0
  535. package/dist/tools/__tests__/compatibility.test.js.map +1 -0
  536. package/dist/tools/__tests__/ids.test.d.ts +5 -0
  537. package/dist/tools/__tests__/ids.test.d.ts.map +1 -0
  538. package/dist/tools/__tests__/ids.test.js +56 -0
  539. package/dist/tools/__tests__/ids.test.js.map +1 -0
  540. package/dist/tools/__tests__/manifest-assert.test.d.ts +5 -0
  541. package/dist/tools/__tests__/manifest-assert.test.d.ts.map +1 -0
  542. package/dist/tools/__tests__/manifest-assert.test.js +66 -0
  543. package/dist/tools/__tests__/manifest-assert.test.js.map +1 -0
  544. package/dist/tools/__tests__/registry.test.d.ts +2 -0
  545. package/dist/tools/__tests__/registry.test.d.ts.map +1 -0
  546. package/dist/tools/__tests__/registry.test.js +93 -0
  547. package/dist/tools/__tests__/registry.test.js.map +1 -0
  548. package/dist/tools/__tests__/types.test.d.ts +2 -0
  549. package/dist/tools/__tests__/types.test.d.ts.map +1 -0
  550. package/dist/tools/__tests__/types.test.js +51 -0
  551. package/dist/tools/__tests__/types.test.js.map +1 -0
  552. package/dist/tools/capability.d.ts +257 -0
  553. package/dist/tools/capability.d.ts.map +1 -0
  554. package/dist/tools/capability.js +46 -0
  555. package/dist/tools/capability.js.map +1 -0
  556. package/dist/tools/command-spec.d.ts +211 -0
  557. package/dist/tools/command-spec.d.ts.map +1 -0
  558. package/dist/tools/command-spec.js +110 -0
  559. package/dist/tools/command-spec.js.map +1 -0
  560. package/dist/tools/compatibility.d.ts +45 -0
  561. package/dist/tools/compatibility.d.ts.map +1 -0
  562. package/dist/tools/compatibility.js +49 -0
  563. package/dist/tools/compatibility.js.map +1 -0
  564. package/dist/tools/ids.d.ts +61 -0
  565. package/dist/tools/ids.d.ts.map +1 -0
  566. package/dist/tools/ids.js +61 -0
  567. package/dist/tools/ids.js.map +1 -0
  568. package/dist/tools/index.d.ts +22 -0
  569. package/dist/tools/index.d.ts.map +1 -0
  570. package/dist/tools/index.js +28 -0
  571. package/dist/tools/index.js.map +1 -0
  572. package/dist/tools/manifest-assert.d.ts +35 -0
  573. package/dist/tools/manifest-assert.d.ts.map +1 -0
  574. package/dist/tools/manifest-assert.js +67 -0
  575. package/dist/tools/manifest-assert.js.map +1 -0
  576. package/dist/tools/manifest.d.ts +178 -0
  577. package/dist/tools/manifest.d.ts.map +1 -0
  578. package/dist/tools/manifest.js +35 -0
  579. package/dist/tools/manifest.js.map +1 -0
  580. package/dist/tools/registry.d.ts +37 -0
  581. package/dist/tools/registry.d.ts.map +1 -0
  582. package/dist/tools/registry.js +49 -0
  583. package/dist/tools/registry.js.map +1 -0
  584. package/dist/tools/types.d.ts +1021 -0
  585. package/dist/tools/types.d.ts.map +1 -0
  586. package/dist/tools/types.js +77 -0
  587. package/dist/tools/types.js.map +1 -0
  588. package/dist/types/__tests__/signal.test.d.ts +2 -0
  589. package/dist/types/__tests__/signal.test.d.ts.map +1 -0
  590. package/dist/types/__tests__/signal.test.js +111 -0
  591. package/dist/types/__tests__/signal.test.js.map +1 -0
  592. package/dist/types/index.d.ts +5 -0
  593. package/dist/types/index.d.ts.map +1 -0
  594. package/dist/types/index.js +3 -0
  595. package/dist/types/index.js.map +1 -0
  596. package/dist/types/signal-batch.d.ts +56 -0
  597. package/dist/types/signal-batch.d.ts.map +1 -0
  598. package/dist/types/signal-batch.js +54 -0
  599. package/dist/types/signal-batch.js.map +1 -0
  600. package/dist/types/signal.d.ts +77 -0
  601. package/dist/types/signal.d.ts.map +1 -0
  602. package/dist/types/signal.js +42 -0
  603. package/dist/types/signal.js.map +1 -0
  604. package/package.json +57 -0
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @fileoverview Host-owned RunTimer / RunLifecycle primitive
3
+ * (host-owned-run-timing plan).
4
+ *
5
+ * Single source of truth for wall-clock start + monotonic elapsed for one
6
+ * user-visible CLI tool run. The host run-lifecycle plane creates one lifecycle
7
+ * inside the selected command action (after `RunScope` entry, before any
8
+ * tool-owned work) and `complete()`s it once the tool handler / live renderer
9
+ * returns its completion data — that frozen snapshot feeds the generic
10
+ * `StoredSession.startedAt` / `completedAt` / `durationMs`.
11
+ *
12
+ * Tools and engines must never capture their own `Date.now` / `new Date` for
13
+ * the generic session timing fields; only the host lifecycle feeds those.
14
+ * Internal tool timers (per-unit, per-stage, etc.) remain tool-owned for
15
+ * diagnostics.
16
+ *
17
+ * `startedAt` is ISO wall time captured at construction. `complete()` is
18
+ * idempotent: the first call freezes `completedAt` + `durationMs`; later calls
19
+ * return the same frozen snapshot. `snapshot()` reads live before completion
20
+ * (for the ticking live display) and the frozen values after. Elapsed uses a
21
+ * monotonic clock (`performance.now` when available) to avoid skew on long runs
22
+ * or system clock adjustments.
23
+ */
24
+ /**
25
+ * Create a fresh host-owned run timer.
26
+ *
27
+ * Must be called by the CLI host after `RunScope` is entered (so `runId` etc.
28
+ * are available for logging in Phase 1 wiring) but before any tool work that
29
+ * will be timed.
30
+ */
31
+ export function createRunTimer() {
32
+ const startedAt = new Date().toISOString();
33
+ const startedAtEpochMs = Date.now();
34
+ // Prefer a monotonic clock to avoid wall-time skew on long runs.
35
+ // In Node 16.7+ / modern browsers, `performance` is global and provides
36
+ // `performance.now()`. Fall back to Date math if unavailable.
37
+ const perfNow = typeof performance !== 'undefined' && typeof performance.now === 'function'
38
+ ? performance.now.bind(performance)
39
+ : undefined;
40
+ const monotonicStart = perfNow ? perfNow() : undefined;
41
+ function elapsedMs() {
42
+ const raw = monotonicStart !== undefined && perfNow
43
+ ? perfNow() - monotonicStart
44
+ : Date.now() - startedAtEpochMs;
45
+ return Math.max(0, raw);
46
+ }
47
+ let frozen;
48
+ function snapshot() {
49
+ if (frozen)
50
+ return frozen;
51
+ return {
52
+ startedAt,
53
+ completedAt: new Date().toISOString(),
54
+ durationMs: Math.max(0, elapsedMs()),
55
+ };
56
+ }
57
+ function complete() {
58
+ // Idempotent: the first completion freezes completedAt + durationMs.
59
+ frozen ??= {
60
+ startedAt,
61
+ completedAt: new Date().toISOString(),
62
+ durationMs: Math.max(0, elapsedMs()),
63
+ };
64
+ return frozen;
65
+ }
66
+ return {
67
+ startedAt,
68
+ startedAtEpochMs,
69
+ elapsedMs,
70
+ snapshot,
71
+ complete,
72
+ };
73
+ }
74
+ /**
75
+ * Create a fresh host-owned run lifecycle. Alias of {@link createRunTimer}
76
+ * under the spec-named factory (host-owned-run-timing §6.1).
77
+ */
78
+ export const createRunLifecycle = createRunTimer;
79
+ //# sourceMappingURL=run-timer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-timer.js","sourceRoot":"","sources":["../../src/lib/run-timer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAqDH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEpC,iEAAiE;IACjE,wEAAwE;IACxE,8DAA8D;IAC9D,MAAM,OAAO,GACX,OAAO,WAAW,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,GAAG,KAAK,UAAU;QACzE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;QACnC,CAAC,CAAC,SAAS,CAAC;IAEhB,MAAM,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvD,SAAS,SAAS;QAChB,MAAM,GAAG,GACP,cAAc,KAAK,SAAS,IAAI,OAAO;YACrC,CAAC,CAAC,OAAO,EAAE,GAAG,cAAc;YAC5B,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,gBAAgB,CAAC;QACpC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,MAAqC,CAAC;IAE1C,SAAS,QAAQ;QACf,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,OAAO;YACL,SAAS;YACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;SACrC,CAAC;IACJ,CAAC;IAED,SAAS,QAAQ;QACf,qEAAqE;QACrE,MAAM,KAAK;YACT,SAAS;YACT,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;SACrC,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO;QACL,SAAS;QACT,gBAAgB;QAChB,SAAS;QACT,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAuB,cAAc,CAAC"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @fileoverview Scope type contracts — the leaf module that breaks the
3
+ * `RunScope ⟷ Tool` type cycle (audit 2026-05-29, M4).
4
+ *
5
+ * The cycle was `run-scope.ts → tools/registry.ts → tools/types.ts →
6
+ * run-scope.ts`: `RunScope` holds a `ToolRegistry` (→ `Tool`), and the
7
+ * `Tool` contract named the concrete `RunScope` back (via
8
+ * `ToolCliContext.scope` and the old `extendScope`). Both edges are
9
+ * type-only, so there is no runtime cycle — but it's a kernel smell and
10
+ * was invisible to the architecture gate (`tsPreCompilationDeps:false`).
11
+ *
12
+ * The fix is DIP: the `Tool` contract depends on the abstractions here,
13
+ * never on the concrete `RunScope`. This module imports NOTHING from
14
+ * `tools/` or `run-scope.ts`, so it is a true leaf — `tools/types.ts`
15
+ * can depend on it with no edge back to `run-scope.ts`.
16
+ *
17
+ * - `ToolScope` — the Tool-FACING view of the scope (everything tools
18
+ * read via `cli.scope.*`), deliberately WITHOUT the `tools`
19
+ * `ToolRegistry` (which would re-introduce the `→ Tool` edge). Tools
20
+ * never read `scope.tools`. `RunScope` is a `ToolScope` plus `tools`.
21
+ * - `ScopeContribution` — the augmentable slot bag a tool returns from
22
+ * `Tool.contributeScope()`. Tools augment THIS (not `RunScope`); the
23
+ * kernel `Object.assign`s it onto the scope. `RunScope`/`ToolScope`
24
+ * inherit the slots for reading.
25
+ */
26
+ import type { Logger } from './logger.js';
27
+ import type { ProjectContext } from './project-context.js';
28
+ import type { LanguageParseCache } from '../languages/parse-cache-class.js';
29
+ import type { LanguageRegistry } from '../languages/registry.js';
30
+ import type { SignalSink } from '../signals/signal-sink.js';
31
+ /** Opaque slot for per-run recipe configuration (replaces globalThis Symbol). */
32
+ export interface RecipeUnitConfigSlot {
33
+ get<T extends Record<string, unknown>>(slug: string): T | undefined;
34
+ set(slug: string, config: Record<string, unknown>): void;
35
+ setAll(config: Record<string, Record<string, unknown>>): void;
36
+ clear(): void;
37
+ }
38
+ /**
39
+ * The resolved, validated tool configuration for this run (launch,
40
+ * ADR-0023, Phase 4). `namespace -> { key -> value }`, where each top-level
41
+ * key is a tool's namespace (`graph`/`fitness`/`simulation`) after the host
42
+ * composed every tool's contributed schema, validated the document STRICT,
43
+ * and resolved precedence (flag > env > file > defaults).
44
+ *
45
+ * Structurally identical to `@opensip-cli/config`'s `ResolvedConfig`, kept
46
+ * Zod-free here so the kernel carries no config-layer dependency — the CLI
47
+ * (which DOES import `@opensip-cli/config`) writes it, and tools read their
48
+ * own namespace via `currentScope()?.toolConfig?.<namespace>`.
49
+ */
50
+ export type ResolvedToolConfig = Record<string, Record<string, unknown>>;
51
+ /**
52
+ * The structural shape of one registered target the host hands tools through
53
+ * `scope.targets`. A target is a named file set (`include`/`exclude` globs)
54
+ * plus its language/concern metadata. Kept structural (Zod-free, no
55
+ * `@opensip-cli/config` import) so the kernel carries no config-layer or
56
+ * tool-vocabulary dependency — it mirrors `ResolvedToolConfig`'s "structural
57
+ * analog of a config-layer type" pattern. `@opensip-cli/config`'s `Target`
58
+ * (a `{ config: TargetConfig }`) is structurally assignable to this shape.
59
+ */
60
+ export interface TargetView {
61
+ readonly config: {
62
+ readonly name: string;
63
+ readonly description: string;
64
+ readonly include: readonly string[];
65
+ readonly exclude: readonly string[];
66
+ readonly tags?: readonly string[];
67
+ readonly languages?: readonly string[];
68
+ readonly concerns?: readonly string[];
69
+ };
70
+ }
71
+ /**
72
+ * The structural, host-built targeting accessor exposed on `scope.targets`
73
+ * (ADR-0037). Names only the generic methods the host and any tool call to
74
+ * resolve named targets to file sets and apply project-wide exclusions —
75
+ * never the concrete substrate class. `core` names no targeting concrete
76
+ * (it imports nothing workspace); the substrate's `TargetRegistry`, wrapped
77
+ * by the CLI bootstrap with the bound `resolveTargets`/`applyGlobalExcludes`
78
+ * closures + `globalExcludes` list, is structurally assignable here.
79
+ *
80
+ * Mirrors the `ResolvedToolConfig` precedent: a structural, Zod-free analog
81
+ * of a config-layer runtime, declared in the kernel leaf so the `Tool`
82
+ * contract can read it without a layer inversion.
83
+ */
84
+ export interface TargetResolver {
85
+ /** Look up a registered target by its config name. */
86
+ getByName(name: string): TargetView | undefined;
87
+ /** Return every registered target. */
88
+ getAll(): readonly TargetView[];
89
+ /** Return every registered target whose `config.tags` include `tag`. */
90
+ getByTag(tag: string): readonly TargetView[];
91
+ /** Whether a target with the given name is registered. */
92
+ has(name: string): boolean;
93
+ /**
94
+ * Resolve the named targets to a deduplicated, sorted list of absolute file
95
+ * paths, applying per-target `exclude` AND the project `globalExcludes`.
96
+ */
97
+ resolveTargets(names: readonly string[], rootDir: string): readonly string[];
98
+ /** Filter a file list against the project `globalExcludes` (rootDir-relative). */
99
+ applyGlobalExcludes(files: readonly string[], rootDir: string): readonly string[];
100
+ /** The project-wide exclusion globs this resolver was built with. */
101
+ readonly globalExcludes: readonly string[];
102
+ }
103
+ /**
104
+ * Opaque accessor that lazily opens the datastore on first read.
105
+ * Returns `undefined` when no datastore is configured for this scope.
106
+ */
107
+ export type DataStoreThunk = () => unknown;
108
+ /**
109
+ * Per-tool subscope contribution. Each tool augments this interface from
110
+ * its own package (`declare module '@opensip-cli/core' { interface
111
+ * ScopeContribution { graph?: … } }`) and returns the matching object
112
+ * from `Tool.contributeScope()`. The kernel installs it onto the scope.
113
+ * `ToolScope` (and therefore `RunScope`) extends this, so the same slots
114
+ * are readable via `cli.scope.<tool>` / `currentScope()?.<tool>`.
115
+ *
116
+ * Empty here by design — every member arrives via tool augmentation, so
117
+ * core never names a tool-specific type.
118
+ */
119
+ export interface ScopeContribution {
120
+ }
121
+ /**
122
+ * The Tool-facing view of the per-invocation scope: everything a tool
123
+ * reads through `ToolCliContext.scope`. Excludes the `tools`
124
+ * `ToolRegistry` on purpose — tools never read it, and naming it here
125
+ * would re-introduce the `Tool` reference that creates the cycle.
126
+ * `RunScope` is structurally a `ToolScope` with `tools` added.
127
+ */
128
+ export interface ToolScope extends ScopeContribution {
129
+ readonly logger: Logger;
130
+ readonly parseCache: LanguageParseCache;
131
+ readonly recipeUnitConfig: RecipeUnitConfigSlot;
132
+ readonly projectContext: ProjectContext | undefined;
133
+ readonly datastore: DataStoreThunk;
134
+ readonly languages: LanguageRegistry;
135
+ readonly runId: string;
136
+ /** Cloud signal sink for this run (ADR-0008); `noopSignalSink` unless cloud sync is on. */
137
+ readonly signalSink: SignalSink;
138
+ /**
139
+ * The resolved, strict-validated tool configuration for this run (ADR-0023,
140
+ * Phase 4). Seeded by the CLI's pre-action-hook after composing every
141
+ * registered tool's contributed schema and validating the config document;
142
+ * absent on a scope built without a config document (e.g. a project-agnostic
143
+ * command, or a config-less project). A tool reads its own namespace
144
+ * (`scope.toolConfig?.graph`, `?.fitness`, `?.simulation`).
145
+ */
146
+ readonly toolConfig?: ResolvedToolConfig;
147
+ /**
148
+ * The strict-validated raw config document for this run (ADR-0023's
149
+ * one-reader invariant). Seeded by the CLI's pre-action-hook ONLY when a
150
+ * real `opensip-cli.config.yml` was read for this run — absent on a
151
+ * project-agnostic or config-less run, so a tool that hard-errors on a
152
+ * missing config (fitness) stays loud. Tools that project tool-specific
153
+ * shapes out of the document (fitness's signalers/targets loaders) parse
154
+ * THIS instead of re-reading the file: the host is the only runtime config
155
+ * reader; what remains in the tool is tool-specific projection and
156
+ * cross-validation. Structural (`Record<string, unknown>`) so the kernel
157
+ * carries no config-layer dependency — mirrors `ResolvedToolConfig`.
158
+ */
159
+ readonly configDocument?: Readonly<Record<string, unknown>>;
160
+ /**
161
+ * The host-built file-targeting accessor for this run (ADR-0037). Seeded by
162
+ * the CLI's pre-action-hook from the loaded config document's `targets:` /
163
+ * `globalExcludes:` blocks — built once per run, mirroring `toolConfig` and
164
+ * `languages`. Absent on a scope built without a config document (a
165
+ * project-agnostic command, a config-less project, or a project with no
166
+ * `targets:` block). Tools read it generically (`scope.targets?.resolveTargets`
167
+ * / `?.getByTag` / `?.applyGlobalExcludes`); the structural `TargetResolver`
168
+ * names no targeting concrete, so the kernel carries no targeting dependency.
169
+ */
170
+ readonly targets?: TargetResolver;
171
+ }
172
+ //# sourceMappingURL=scope-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-types.d.ts","sourceRoot":"","sources":["../../src/lib/scope-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,iFAAiF;AACjF,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IACpE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACzD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;QACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACvC,CAAC;CACH;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAChD,sCAAsC;IACtC,MAAM,IAAI,SAAS,UAAU,EAAE,CAAC;IAChC,wEAAwE;IACxE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,UAAU,EAAE,CAAC;IAC7C,0DAA0D;IAC1D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC7E,kFAAkF;IAClF,mBAAmB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAClF,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC;AAE3C;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,iBAAiB;CAAG;AAErC;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IAChD,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IACpD,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;IACzC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview Scope type contracts — the leaf module that breaks the
3
+ * `RunScope ⟷ Tool` type cycle (audit 2026-05-29, M4).
4
+ *
5
+ * The cycle was `run-scope.ts → tools/registry.ts → tools/types.ts →
6
+ * run-scope.ts`: `RunScope` holds a `ToolRegistry` (→ `Tool`), and the
7
+ * `Tool` contract named the concrete `RunScope` back (via
8
+ * `ToolCliContext.scope` and the old `extendScope`). Both edges are
9
+ * type-only, so there is no runtime cycle — but it's a kernel smell and
10
+ * was invisible to the architecture gate (`tsPreCompilationDeps:false`).
11
+ *
12
+ * The fix is DIP: the `Tool` contract depends on the abstractions here,
13
+ * never on the concrete `RunScope`. This module imports NOTHING from
14
+ * `tools/` or `run-scope.ts`, so it is a true leaf — `tools/types.ts`
15
+ * can depend on it with no edge back to `run-scope.ts`.
16
+ *
17
+ * - `ToolScope` — the Tool-FACING view of the scope (everything tools
18
+ * read via `cli.scope.*`), deliberately WITHOUT the `tools`
19
+ * `ToolRegistry` (which would re-introduce the `→ Tool` edge). Tools
20
+ * never read `scope.tools`. `RunScope` is a `ToolScope` plus `tools`.
21
+ * - `ScopeContribution` — the augmentable slot bag a tool returns from
22
+ * `Tool.contributeScope()`. Tools augment THIS (not `RunScope`); the
23
+ * kernel `Object.assign`s it onto the scope. `RunScope`/`ToolScope`
24
+ * inherit the slots for reading.
25
+ */
26
+ export {};
27
+ //# sourceMappingURL=scope-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-types.js","sourceRoot":"","sources":["../../src/lib/scope-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * SeverityPolicy — the one home for severity mapping + the gate's error/warning
3
+ * predicate (north-star §5.9, launch).
4
+ *
5
+ * Severity lives at two levels: AUTHOR severity (`error | warning`, what a fitness
6
+ * check or graph rule declares) and WIRE severity (the 4-level
7
+ * {@link SignalSeverity} on the `Signal`). Previously the author→wire map was
8
+ * duplicated (fitness's `mapFindingSeverity` + `liftSeverity`) and the graph
9
+ * override (`applySeverityOverride`) lived apart, while the gate's error/warning
10
+ * counting was inlined in `buildSignalEnvelope`. This consolidates them so a
11
+ * change to severity semantics is one edit and every consumer agrees.
12
+ *
13
+ * The mappings are byte-identical to what they replace: `error → high`,
14
+ * `warning → medium` (UP, never collapsing, so the error-rung / warning-rung
15
+ * bucketing reproduces the historical counts), and the override clamps only when
16
+ * explicitly set (ADR-0005 / baseline-neutral).
17
+ */
18
+ import { type SignalSeverity } from '../types/signal.js';
19
+ /** The 2-level severity a check/rule author declares (mapped UP to the wire level). */
20
+ export type AuthorSeverity = 'error' | 'warning';
21
+ /**
22
+ * The central severity policy. A frozen namespace (not per-run state) — pure
23
+ * functions over the severity types, the single source of truth for author→wire
24
+ * mapping, the override clamp, and the error/warning predicate.
25
+ */
26
+ export declare const SeverityPolicy: Readonly<{
27
+ /** Author `error|warning` → wire severity: `error → high`, `warning → medium`. */
28
+ readonly liftAuthorSeverity: (severity: AuthorSeverity) => SignalSeverity;
29
+ /**
30
+ * Clamp a base wire severity by an opt-in override (`error → high`,
31
+ * `warning → medium`); returns `base` unchanged when no override is set
32
+ * (baseline-neutral, ADR-0005).
33
+ */
34
+ readonly applyOverride: (base: SignalSeverity, override: AuthorSeverity | undefined) => SignalSeverity;
35
+ /** True when a severity is on the error rung (`critical`/`high`) — the gate predicate. */
36
+ readonly isError: (severity: SignalSeverity) => boolean;
37
+ }>;
38
+ //# sourceMappingURL=severity-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity-policy.d.ts","sourceRoot":"","sources":["../../src/lib/severity-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE1E,uFAAuF;AACvF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,cAAc;IACzB,kFAAkF;4CACrD,cAAc,KAAG,cAAc;IAI5D;;;;OAIG;mCACiB,cAAc,YAAY,cAAc,GAAG,SAAS,KAAG,cAAc;IAKzF,0FAA0F;iCACxE,cAAc,KAAG,OAAO;EAGjC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * SeverityPolicy — the one home for severity mapping + the gate's error/warning
3
+ * predicate (north-star §5.9, launch).
4
+ *
5
+ * Severity lives at two levels: AUTHOR severity (`error | warning`, what a fitness
6
+ * check or graph rule declares) and WIRE severity (the 4-level
7
+ * {@link SignalSeverity} on the `Signal`). Previously the author→wire map was
8
+ * duplicated (fitness's `mapFindingSeverity` + `liftSeverity`) and the graph
9
+ * override (`applySeverityOverride`) lived apart, while the gate's error/warning
10
+ * counting was inlined in `buildSignalEnvelope`. This consolidates them so a
11
+ * change to severity semantics is one edit and every consumer agrees.
12
+ *
13
+ * The mappings are byte-identical to what they replace: `error → high`,
14
+ * `warning → medium` (UP, never collapsing, so the error-rung / warning-rung
15
+ * bucketing reproduces the historical counts), and the override clamps only when
16
+ * explicitly set (ADR-0005 / baseline-neutral).
17
+ */
18
+ import { isErrorSeverity } from '../types/signal.js';
19
+ /**
20
+ * The central severity policy. A frozen namespace (not per-run state) — pure
21
+ * functions over the severity types, the single source of truth for author→wire
22
+ * mapping, the override clamp, and the error/warning predicate.
23
+ */
24
+ export const SeverityPolicy = Object.freeze({
25
+ /** Author `error|warning` → wire severity: `error → high`, `warning → medium`. */
26
+ liftAuthorSeverity(severity) {
27
+ return severity === 'error' ? 'high' : 'medium';
28
+ },
29
+ /**
30
+ * Clamp a base wire severity by an opt-in override (`error → high`,
31
+ * `warning → medium`); returns `base` unchanged when no override is set
32
+ * (baseline-neutral, ADR-0005).
33
+ */
34
+ applyOverride(base, override) {
35
+ if (override === undefined)
36
+ return base;
37
+ return override === 'error' ? 'high' : 'medium';
38
+ },
39
+ /** True when a severity is on the error rung (`critical`/`high`) — the gate predicate. */
40
+ isError(severity) {
41
+ return isErrorSeverity(severity);
42
+ },
43
+ });
44
+ //# sourceMappingURL=severity-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"severity-policy.js","sourceRoot":"","sources":["../../src/lib/severity-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,eAAe,EAAuB,MAAM,oBAAoB,CAAC;AAK1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,kFAAkF;IAClF,kBAAkB,CAAC,QAAwB;QACzC,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,aAAa,CAAC,IAAoB,EAAE,QAAoC;QACtE,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACxC,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;IAClD,CAAC;IAED,0FAA0F;IAC1F,OAAO,CAAC,QAAwB;QAC9B,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACO,CAAC,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Tracing primitive for opensip-cli — the kernel sibling of `logger`.
3
+ *
4
+ * This module is a thin wrapper over the **OpenTelemetry API** (`@opentelemetry/api`)
5
+ * — the no-op facade half of OTel's library/application split. It exposes a
6
+ * narrow tracing seam (`getTracer`, `withSpan`) that every tool uses to emit
7
+ * spans, exactly as every tool emits logs through `logger`.
8
+ *
9
+ * ## No-op-until-SDK contract (load-bearing for standalone users)
10
+ *
11
+ * The OpenTelemetry **API** does nothing on its own. Until an SDK registers a
12
+ * global `TracerProvider`, `trace.getTracer(...)` returns a *no-op tracer*:
13
+ * `startActiveSpan` runs the callback with a no-op span, records nothing, makes
14
+ * no network calls, and adds an unmeasurable amount of overhead. That
15
+ * registration happens ONLY at the application boundary — the CLI composition
16
+ * root (`opensip-cli`), gated on `OTEL_EXPORTER_OTLP_ENDPOINT`. The heavy
17
+ * SDK packages (`@opentelemetry/sdk-*`, exporters, context managers) never enter
18
+ * the kernel.
19
+ *
20
+ * The consequence: importing and calling `withSpan` from a standalone CLI run
21
+ * (no OTLP endpoint configured) is a hard no-op — `fn` runs, its value is
22
+ * returned, and nothing is emitted. This is the guarantee standalone users
23
+ * depend on, and it is asserted in `__tests__/telemetry.test.ts`.
24
+ */
25
+ import { type Span, type Attributes, type Meter, type Tracer } from '@opentelemetry/api';
26
+ /**
27
+ * Resolve a `Tracer` for a given instrumentation scope name (e.g.
28
+ * `'opensip-cli-graph'`). Reads the *global* tracer provider set by the SDK
29
+ * at the application boundary; returns a no-op tracer when no SDK is registered.
30
+ */
31
+ export declare function getTracer(name: string): Tracer;
32
+ /**
33
+ * Run `fn` inside an active span.
34
+ *
35
+ * Records exceptions and sets ERROR status if `fn` throws, and always ends the
36
+ * span. When no SDK is registered the underlying tracer is a no-op, so this adds
37
+ * an unmeasurable amount of overhead — see the no-op-until-SDK contract above.
38
+ *
39
+ * Synchronous by design: graph's `runStage` (the first consumer) is synchronous,
40
+ * so `fn` returns `T` and the span ends when the callback returns. An async
41
+ * caller passes an async `fn` and the helper returns its promise — but note the
42
+ * span ends when the synchronous callback returns, so an async caller that wants
43
+ * the span to span the awaited work should `return await fn()` from inside an
44
+ * async `fn` whose promise the helper returns (i.e. `withSpan(name, span, async () => { ... })`).
45
+ *
46
+ * @param tracerName instrumentation scope (passed to {@link getTracer})
47
+ * @param spanName the span name
48
+ * @param fn the work to run inside the span
49
+ * @param attrs optional attributes set on the span before `fn` runs
50
+ */
51
+ export declare function withSpan<T>(tracerName: string, spanName: string, fn: (span: Span) => T, attrs?: Attributes): T;
52
+ /**
53
+ * Async sibling of {@link withSpan}: the span stays open across awaited work and
54
+ * ends only when the returned promise settles.
55
+ *
56
+ * {@link withSpan} is synchronous — its `finally` runs the instant the callback
57
+ * returns, so wrapping awaited work with it would end the span before the work
58
+ * completes and miss async rejections. Use this for any `fn` that returns a
59
+ * promise. The span stays active for the duration of the awaited work (under the
60
+ * SDK's AsyncLocalStorage context manager), so descendants — including spans
61
+ * emitted by spawned subprocesses that inherit {@link currentTraceparent} — nest
62
+ * under it. Same no-op-until-SDK contract: a hard no-op when no SDK is registered.
63
+ *
64
+ * @param tracerName instrumentation scope (passed to {@link getTracer})
65
+ * @param spanName the span name
66
+ * @param fn the async work to run inside the span
67
+ * @param attrs optional attributes set on the span before `fn` runs
68
+ */
69
+ export declare function withSpanAsync<T>(tracerName: string, spanName: string, fn: (span: Span) => Promise<T>, attrs?: Attributes): Promise<T>;
70
+ /**
71
+ * Serialize the currently-active span context to a W3C `traceparent` string, for
72
+ * propagation into a spawned subprocess (passed as the `TRACEPARENT` env var,
73
+ * which {@link initTelemetry} extracts at the child's boundary so its spans nest
74
+ * under ours).
75
+ *
76
+ * Returns `undefined` when there is no active recording span — which includes
77
+ * every standalone run, since the no-op tracer produces an invalid (all-zero)
78
+ * span context that the W3C propagator declines to emit. Uses the globally
79
+ * registered propagator (installed by the SDK at the application boundary), so
80
+ * the kernel stays a pure `@opentelemetry/api` consumer with no SDK dependency.
81
+ */
82
+ export declare function currentTraceparent(): string | undefined;
83
+ /**
84
+ * Resolve a `Meter` for a given instrumentation scope name (e.g.
85
+ * `'opensip-cli'`). Reads the *global* meter provider set by the SDK
86
+ * at the application boundary; returns a no-op meter when no SDK is registered.
87
+ *
88
+ * Same no-op-until-SDK contract as tracing. SDK registration (including
89
+ * `@opentelemetry/sdk-metrics`) happens only in the CLI composition root,
90
+ * gated on `OTEL_EXPORTER_OTLP_ENDPOINT`.
91
+ */
92
+ export declare function getMeter(name: string): Meter;
93
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/lib/telemetry.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAML,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,EACrB,KAAK,CAAC,EAAE,UAAU,GACjB,CAAC,CAgBH;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,aAAa,CAAC,CAAC,EACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9B,KAAK,CAAC,EAAE,UAAU,GACjB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,SAAS,CAIvD;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAE5C"}
@@ -0,0 +1,144 @@
1
+ // @fitness-ignore-file detached-promises -- OTel Span methods (recordException/setStatus/end) return void (sync); the heuristic flags them inside withSpanAsync's async callback. The only promise here (fn(span)) is awaited.
2
+ /**
3
+ * Tracing primitive for opensip-cli — the kernel sibling of `logger`.
4
+ *
5
+ * This module is a thin wrapper over the **OpenTelemetry API** (`@opentelemetry/api`)
6
+ * — the no-op facade half of OTel's library/application split. It exposes a
7
+ * narrow tracing seam (`getTracer`, `withSpan`) that every tool uses to emit
8
+ * spans, exactly as every tool emits logs through `logger`.
9
+ *
10
+ * ## No-op-until-SDK contract (load-bearing for standalone users)
11
+ *
12
+ * The OpenTelemetry **API** does nothing on its own. Until an SDK registers a
13
+ * global `TracerProvider`, `trace.getTracer(...)` returns a *no-op tracer*:
14
+ * `startActiveSpan` runs the callback with a no-op span, records nothing, makes
15
+ * no network calls, and adds an unmeasurable amount of overhead. That
16
+ * registration happens ONLY at the application boundary — the CLI composition
17
+ * root (`opensip-cli`), gated on `OTEL_EXPORTER_OTLP_ENDPOINT`. The heavy
18
+ * SDK packages (`@opentelemetry/sdk-*`, exporters, context managers) never enter
19
+ * the kernel.
20
+ *
21
+ * The consequence: importing and calling `withSpan` from a standalone CLI run
22
+ * (no OTLP endpoint configured) is a hard no-op — `fn` runs, its value is
23
+ * returned, and nothing is emitted. This is the guarantee standalone users
24
+ * depend on, and it is asserted in `__tests__/telemetry.test.ts`.
25
+ */
26
+ import { context, metrics, propagation, trace, SpanStatusCode, } from '@opentelemetry/api';
27
+ /**
28
+ * Resolve a `Tracer` for a given instrumentation scope name (e.g.
29
+ * `'opensip-cli-graph'`). Reads the *global* tracer provider set by the SDK
30
+ * at the application boundary; returns a no-op tracer when no SDK is registered.
31
+ */
32
+ export function getTracer(name) {
33
+ return trace.getTracer(name);
34
+ }
35
+ /**
36
+ * Run `fn` inside an active span.
37
+ *
38
+ * Records exceptions and sets ERROR status if `fn` throws, and always ends the
39
+ * span. When no SDK is registered the underlying tracer is a no-op, so this adds
40
+ * an unmeasurable amount of overhead — see the no-op-until-SDK contract above.
41
+ *
42
+ * Synchronous by design: graph's `runStage` (the first consumer) is synchronous,
43
+ * so `fn` returns `T` and the span ends when the callback returns. An async
44
+ * caller passes an async `fn` and the helper returns its promise — but note the
45
+ * span ends when the synchronous callback returns, so an async caller that wants
46
+ * the span to span the awaited work should `return await fn()` from inside an
47
+ * async `fn` whose promise the helper returns (i.e. `withSpan(name, span, async () => { ... })`).
48
+ *
49
+ * @param tracerName instrumentation scope (passed to {@link getTracer})
50
+ * @param spanName the span name
51
+ * @param fn the work to run inside the span
52
+ * @param attrs optional attributes set on the span before `fn` runs
53
+ */
54
+ export function withSpan(tracerName, spanName, fn, attrs) {
55
+ return getTracer(tracerName).startActiveSpan(spanName, (span) => {
56
+ if (attrs)
57
+ span.setAttributes(attrs);
58
+ try {
59
+ return fn(span);
60
+ }
61
+ catch (error) {
62
+ // Normalize before recording: a thrown non-Error (string, object) must
63
+ // record as a message rather than be unsafely cast to Error. OTel's
64
+ // `recordException` accepts `string | Exception`, so this is type-safe.
65
+ span.recordException(error instanceof Error ? error : String(error));
66
+ span.setStatus({ code: SpanStatusCode.ERROR });
67
+ throw error;
68
+ }
69
+ finally {
70
+ span.end();
71
+ }
72
+ });
73
+ }
74
+ /**
75
+ * Async sibling of {@link withSpan}: the span stays open across awaited work and
76
+ * ends only when the returned promise settles.
77
+ *
78
+ * {@link withSpan} is synchronous — its `finally` runs the instant the callback
79
+ * returns, so wrapping awaited work with it would end the span before the work
80
+ * completes and miss async rejections. Use this for any `fn` that returns a
81
+ * promise. The span stays active for the duration of the awaited work (under the
82
+ * SDK's AsyncLocalStorage context manager), so descendants — including spans
83
+ * emitted by spawned subprocesses that inherit {@link currentTraceparent} — nest
84
+ * under it. Same no-op-until-SDK contract: a hard no-op when no SDK is registered.
85
+ *
86
+ * @param tracerName instrumentation scope (passed to {@link getTracer})
87
+ * @param spanName the span name
88
+ * @param fn the async work to run inside the span
89
+ * @param attrs optional attributes set on the span before `fn` runs
90
+ */
91
+ export async function withSpanAsync(tracerName, spanName, fn, attrs) {
92
+ return getTracer(tracerName).startActiveSpan(spanName, async (span) => {
93
+ if (attrs)
94
+ span.setAttributes(attrs);
95
+ try {
96
+ return await fn(span);
97
+ }
98
+ catch (error) {
99
+ span.recordException(error instanceof Error ? error : String(error));
100
+ span.setStatus({ code: SpanStatusCode.ERROR });
101
+ throw error;
102
+ }
103
+ finally {
104
+ span.end();
105
+ }
106
+ });
107
+ }
108
+ /**
109
+ * Serialize the currently-active span context to a W3C `traceparent` string, for
110
+ * propagation into a spawned subprocess (passed as the `TRACEPARENT` env var,
111
+ * which {@link initTelemetry} extracts at the child's boundary so its spans nest
112
+ * under ours).
113
+ *
114
+ * Returns `undefined` when there is no active recording span — which includes
115
+ * every standalone run, since the no-op tracer produces an invalid (all-zero)
116
+ * span context that the W3C propagator declines to emit. Uses the globally
117
+ * registered propagator (installed by the SDK at the application boundary), so
118
+ * the kernel stays a pure `@opentelemetry/api` consumer with no SDK dependency.
119
+ */
120
+ export function currentTraceparent() {
121
+ const carrier = {};
122
+ propagation.inject(context.active(), carrier);
123
+ return carrier.traceparent;
124
+ }
125
+ /**
126
+ * Resolve a `Meter` for a given instrumentation scope name (e.g.
127
+ * `'opensip-cli'`). Reads the *global* meter provider set by the SDK
128
+ * at the application boundary; returns a no-op meter when no SDK is registered.
129
+ *
130
+ * Same no-op-until-SDK contract as tracing. SDK registration (including
131
+ * `@opentelemetry/sdk-metrics`) happens only in the CLI composition root,
132
+ * gated on `OTEL_EXPORTER_OTLP_ENDPOINT`.
133
+ */
134
+ export function getMeter(name) {
135
+ return metrics.getMeter(name);
136
+ }
137
+ // Profiling support is intentionally minimal in core (thin seam only).
138
+ // The actual profiler (labels, start/stop, flush) lives in the CLI root
139
+ // (`packages/cli/src/telemetry/profiling.ts`) behind the OPENSIP_PROFILING
140
+ // (recommended) + OTEL_EXPORTER_OTLP_ENDPOINT gate (or OTEL-only mode).
141
+ // Core only provides correlation primitives (currentTraceparent, runId via scope)
142
+ // that the CLI uses to label profiles. This keeps the kernel free of any
143
+ // profiling SDK bits. See ADR-0049 and the observability-hardening plan.
144
+ //# sourceMappingURL=telemetry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/lib/telemetry.ts"],"names":[],"mappings":"AAAA,+NAA+N;AAC/N;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,OAAO,EACP,OAAO,EACP,WAAW,EACX,KAAK,EACL,cAAc,GAKf,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,QAAQ,CACtB,UAAkB,EAClB,QAAgB,EAChB,EAAqB,EACrB,KAAkB;IAElB,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;QAC9D,IAAI,KAAK;YAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC;YACH,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uEAAuE;YACvE,oEAAoE;YACpE,wEAAwE;YACxE,IAAI,CAAC,eAAe,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YAC/C,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAkB,EAClB,QAAgB,EAChB,EAA8B,EAC9B,KAAkB;IAElB,OAAO,SAAS,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACpE,IAAI,KAAK;YAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YAC/C,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,uEAAuE;AACvE,wEAAwE;AACxE,2EAA2E;AAC3E,wEAAwE;AACxE,kFAAkF;AAClF,yEAAyE;AACzE,yEAAyE"}