@codyswann/lisa 5.4.0 → 5.5.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 (370) hide show
  1. package/README.md +60 -3
  2. package/all/copy-contents/gitignore +16 -0
  3. package/all/copy-contents/scripts/lisa-mutation.sh +4 -6
  4. package/all/copy-overwrite/scripts/fetch-test-access-map.d.mts +71 -0
  5. package/all/copy-overwrite/scripts/fetch-test-access-map.mjs +674 -0
  6. package/all/copy-overwrite/scripts/lib/affected-tests.mjs +818 -0
  7. package/all/copy-overwrite/scripts/lib/automation-provenance-local.mjs +22 -1
  8. package/all/copy-overwrite/scripts/lib/build-marker.mjs +410 -0
  9. package/all/copy-overwrite/scripts/lib/gate-pass-cache.mjs +537 -0
  10. package/all/copy-overwrite/scripts/lib/kill-marks.mjs +1 -2
  11. package/all/copy-overwrite/scripts/lib/lisa-cleanup-sweep-processes.mjs +3 -4
  12. package/all/copy-overwrite/scripts/lib/npm-update-controller-broker.mjs +1 -1
  13. package/all/copy-overwrite/scripts/lib/npm-update-gate-hooks.mjs +2 -1
  14. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +8 -1
  15. package/all/copy-overwrite/scripts/lib/npm-update-hosted-hook.mjs +1 -1
  16. package/all/copy-overwrite/scripts/lib/npm-update-tool-launcher.mjs +1 -1
  17. package/all/copy-overwrite/scripts/lib/push-admission.mjs +158 -0
  18. package/all/copy-overwrite/scripts/lib/push-gate-defaults.d.mts +34 -0
  19. package/all/copy-overwrite/scripts/lib/push-gate-defaults.mjs +147 -0
  20. package/all/copy-overwrite/scripts/lib/push-timing.mjs +323 -0
  21. package/all/copy-overwrite/scripts/lib/rspec-selection.mjs +672 -0
  22. package/all/copy-overwrite/scripts/lisa-affected-tests.mjs +566 -0
  23. package/all/copy-overwrite/scripts/lisa-gates.mjs +29 -0
  24. package/all/copy-overwrite/scripts/lisa-lint-staged-preflight.mjs +10 -1
  25. package/all/copy-overwrite/scripts/lisa-push-timing-report.mjs +153 -0
  26. package/all/copy-overwrite/scripts/lisa-rspec-select.mjs +982 -0
  27. package/all/copy-overwrite/scripts/lisa-run-gates.mjs +231 -6
  28. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +105 -17
  29. package/all/deletions.json +11 -2
  30. package/cdk/create-only/vitest.config.local.ts +1 -7
  31. package/cdk/package-lisa/package.lisa.json +4 -4
  32. package/dist/cli/admit-cmd.d.ts +21 -0
  33. package/dist/cli/admit-cmd.d.ts.map +1 -0
  34. package/dist/cli/admit-cmd.js +142 -0
  35. package/dist/cli/admit-cmd.js.map +1 -0
  36. package/dist/cli/check-cmd.d.ts +72 -0
  37. package/dist/cli/check-cmd.d.ts.map +1 -0
  38. package/dist/cli/check-cmd.js +316 -0
  39. package/dist/cli/check-cmd.js.map +1 -0
  40. package/dist/cli/index.d.ts.map +1 -1
  41. package/dist/cli/index.js +6 -4
  42. package/dist/cli/index.js.map +1 -1
  43. package/dist/cli/lisa-test-run-admission.d.ts +18 -0
  44. package/dist/cli/lisa-test-run-admission.d.ts.map +1 -0
  45. package/dist/cli/lisa-test-run-admission.js +62 -0
  46. package/dist/cli/lisa-test-run-admission.js.map +1 -0
  47. package/dist/cli/lisa-test-run-payload.d.ts +37 -0
  48. package/dist/cli/lisa-test-run-payload.d.ts.map +1 -0
  49. package/dist/cli/lisa-test-run-payload.js +55 -0
  50. package/dist/cli/lisa-test-run-payload.js.map +1 -0
  51. package/dist/cli/lisa-test-run-shard-files.d.ts +89 -0
  52. package/dist/cli/lisa-test-run-shard-files.d.ts.map +1 -0
  53. package/dist/cli/lisa-test-run-shard-files.js +239 -0
  54. package/dist/cli/lisa-test-run-shard-files.js.map +1 -0
  55. package/dist/cli/lisa-test-run-shard.d.ts +6 -2
  56. package/dist/cli/lisa-test-run-shard.d.ts.map +1 -1
  57. package/dist/cli/lisa-test-run-shard.js +25 -13
  58. package/dist/cli/lisa-test-run-shard.js.map +1 -1
  59. package/dist/cli/lisa-test-run.d.ts +1 -1
  60. package/dist/cli/lisa-test-run.d.ts.map +1 -1
  61. package/dist/cli/lisa-test-run.js +47 -10
  62. package/dist/cli/lisa-test-run.js.map +1 -1
  63. package/dist/cli/update-check-hook.d.ts.map +1 -1
  64. package/dist/cli/update-check-hook.js +3 -0
  65. package/dist/cli/update-check-hook.js.map +1 -1
  66. package/dist/configs/vitest/base.d.ts +58 -135
  67. package/dist/configs/vitest/base.d.ts.map +1 -1
  68. package/dist/configs/vitest/base.js +76 -228
  69. package/dist/configs/vitest/base.js.map +1 -1
  70. package/dist/configs/vitest/cdk.d.ts.map +1 -1
  71. package/dist/configs/vitest/cdk.js +3 -2
  72. package/dist/configs/vitest/cdk.js.map +1 -1
  73. package/dist/configs/vitest/coverage-include-global-setup.d.ts.map +1 -1
  74. package/dist/configs/vitest/coverage-include-global-setup.js +3 -4
  75. package/dist/configs/vitest/coverage-include-global-setup.js.map +1 -1
  76. package/dist/configs/vitest/coverage-reports-directory.d.ts +27 -5
  77. package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
  78. package/dist/configs/vitest/coverage-reports-directory.js +47 -10
  79. package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
  80. package/dist/configs/vitest/harper-fabric.d.ts.map +1 -1
  81. package/dist/configs/vitest/harper-fabric.js +3 -2
  82. package/dist/configs/vitest/harper-fabric.js.map +1 -1
  83. package/dist/configs/vitest/nestjs.d.ts.map +1 -1
  84. package/dist/configs/vitest/nestjs.js +3 -2
  85. package/dist/configs/vitest/nestjs.js.map +1 -1
  86. package/dist/configs/vitest/phaser.d.ts.map +1 -1
  87. package/dist/configs/vitest/phaser.js +3 -2
  88. package/dist/configs/vitest/phaser.js.map +1 -1
  89. package/dist/configs/vitest/refusal-announcement.d.ts +51 -0
  90. package/dist/configs/vitest/refusal-announcement.d.ts.map +1 -0
  91. package/dist/configs/vitest/refusal-announcement.js +97 -0
  92. package/dist/configs/vitest/refusal-announcement.js.map +1 -0
  93. package/dist/configs/vitest/socket-safe-temp-base.d.ts +3 -4
  94. package/dist/configs/vitest/socket-safe-temp-base.d.ts.map +1 -1
  95. package/dist/configs/vitest/socket-safe-temp-base.js +7 -6
  96. package/dist/configs/vitest/socket-safe-temp-base.js.map +1 -1
  97. package/dist/configs/vitest/typescript.d.ts.map +1 -1
  98. package/dist/configs/vitest/typescript.js +3 -2
  99. package/dist/configs/vitest/typescript.js.map +1 -1
  100. package/dist/core/admission-decision.d.ts +110 -0
  101. package/dist/core/admission-decision.d.ts.map +1 -0
  102. package/dist/core/admission-decision.js +91 -0
  103. package/dist/core/admission-decision.js.map +1 -0
  104. package/dist/core/admission-lock.d.ts +69 -0
  105. package/dist/core/admission-lock.d.ts.map +1 -0
  106. package/dist/core/admission-lock.js +278 -0
  107. package/dist/core/admission-lock.js.map +1 -0
  108. package/dist/core/admission-settings.d.ts +69 -0
  109. package/dist/core/admission-settings.d.ts.map +1 -0
  110. package/dist/core/admission-settings.js +204 -0
  111. package/dist/core/admission-settings.js.map +1 -0
  112. package/dist/core/admission-state.d.ts +50 -0
  113. package/dist/core/admission-state.d.ts.map +1 -0
  114. package/dist/core/admission-state.js +168 -0
  115. package/dist/core/admission-state.js.map +1 -0
  116. package/dist/core/admission.d.ts +70 -0
  117. package/dist/core/admission.d.ts.map +1 -0
  118. package/dist/core/admission.js +205 -0
  119. package/dist/core/admission.js.map +1 -0
  120. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  121. package/dist/core/lisa-owned-hash-ledger.js +318 -0
  122. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  123. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  124. package/dist/core/project-config-push-gate.d.ts +66 -0
  125. package/dist/core/project-config-push-gate.d.ts.map +1 -0
  126. package/dist/core/project-config-push-gate.js +82 -0
  127. package/dist/core/project-config-push-gate.js.map +1 -0
  128. package/dist/core/project-config.d.ts +4 -0
  129. package/dist/core/project-config.d.ts.map +1 -1
  130. package/dist/core/project-config.js +14 -9
  131. package/dist/core/project-config.js.map +1 -1
  132. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  133. package/dist/core/upstream-evidence-manifest.js +197 -123
  134. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  135. package/expo/package-lisa/package.lisa.json +2 -2
  136. package/harper-fabric/package-lisa/package.lisa.json +4 -4
  137. package/nestjs/create-only/vitest.config.local.ts +1 -7
  138. package/nestjs/package-lisa/package.lisa.json +4 -4
  139. package/npm-package/package-lisa/package.lisa.json +4 -4
  140. package/package.json +12 -11
  141. package/phaser/package-lisa/package.lisa.json +4 -4
  142. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  143. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  144. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  145. package/plugins/lisa/.codex-plugin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  146. package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +1 -1
  147. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  148. package/plugins/lisa/skills/lisa-git-submit-pr/SKILL.md +1 -1
  149. package/plugins/lisa/skills/lisa-implement/SKILL.md +1 -1
  150. package/plugins/lisa-agy/plugin.json +1 -1
  151. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  152. package/plugins/lisa-agy/skills/lisa-git-submit-pr/SKILL.md +1 -1
  153. package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +1 -1
  154. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  155. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  156. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  157. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  158. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  159. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  160. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  161. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  162. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  163. package/plugins/lisa-copilot/skills/lisa-git-submit-pr/SKILL.md +1 -1
  164. package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +1 -1
  165. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  166. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  167. package/plugins/lisa-cursor/skills/lisa-git-submit-pr/SKILL.md +1 -1
  168. package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +1 -1
  169. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  170. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  171. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  172. package/plugins/lisa-devin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  173. package/plugins/lisa-devin/skills/lisa-implement/SKILL.md +1 -1
  174. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  175. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  176. package/plugins/lisa-expo-agy/plugin.json +1 -1
  177. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  178. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  179. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  180. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  181. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  183. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  184. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  185. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  186. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  187. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  188. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  189. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  190. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  191. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  192. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  193. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  194. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  195. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  196. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  197. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  198. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  199. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  200. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  201. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  202. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  204. package/plugins/lisa-rails-agy/plugin.json +1 -1
  205. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  206. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  207. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  208. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  209. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  210. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  211. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  212. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  213. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  214. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  215. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  216. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  217. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  218. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  219. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  220. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  221. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  222. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  223. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  224. package/plugins/src/base/skills/lisa-git-submit-pr/SKILL.md +1 -1
  225. package/plugins/src/base/skills/lisa-implement/SKILL.md +1 -1
  226. package/rails/copy-overwrite/Gemfile.lisa +8 -0
  227. package/rails/copy-overwrite/lefthook.yml +25 -11
  228. package/rails/copy-overwrite/scripts/lisa-rails-gates.mjs +686 -0
  229. package/rails/copy-overwrite/scripts/lisa-rspec-shards.mjs +2 -2
  230. package/rails/copy-overwrite/scripts/lisa_crystalball_recorder.rb +239 -0
  231. package/rails/copy-overwrite/scripts/lisa_rspec_partial_coverage.rb +83 -0
  232. package/scripts/build-unless-marked.mjs +83 -0
  233. package/scripts/check-plugins-sync.sh +22 -5
  234. package/scripts/classify-markdown-assertions.mjs +141 -0
  235. package/scripts/integration-shard-build.mjs +143 -0
  236. package/scripts/lib/history-scanner-suites.mjs +19 -0
  237. package/scripts/lib/markdown-assertions/classify.mjs +289 -0
  238. package/scripts/lib/markdown-assertions/context.mjs +53 -0
  239. package/scripts/lib/markdown-assertions/corpus.mjs +222 -0
  240. package/scripts/lib/markdown-assertions/manifest-cull.mjs +86 -0
  241. package/scripts/lib/markdown-assertions/record-setup.mjs +265 -0
  242. package/scripts/lib/markdown-assertions/record.mjs +115 -0
  243. package/scripts/lib/markdown-assertions/record.vitest.config.mjs +24 -0
  244. package/scripts/lib/markdown-assertions/sites.mjs +273 -0
  245. package/scripts/lib/markdown-assertions/test-cull.mjs +768 -0
  246. package/scripts/lib/markdown-assertions/tokens.mjs +158 -0
  247. package/scripts/lib/shell-guard-trace.mjs +6 -0
  248. package/scripts/lib/test-access-map-setup.mjs +40 -0
  249. package/scripts/lib/test-access-map-tracer.mjs +205 -0
  250. package/scripts/lib/test-access-map.d.mts +72 -0
  251. package/scripts/lib/test-access-map.mjs +395 -0
  252. package/scripts/lib/test-timings-reporter.d.mts +17 -0
  253. package/scripts/lib/test-timings-reporter.mjs +99 -0
  254. package/scripts/plan-integration-shards.mjs +300 -0
  255. package/scripts/test-timing-report.d.mts +41 -0
  256. package/scripts/test-timing-report.mjs +361 -0
  257. package/scripts/two-channel-couplings.json +132 -36
  258. package/scripts/verify-npm-advisories-4333.mjs +3 -12
  259. package/typescript/copy-overwrite/.prettierignore +12 -0
  260. package/typescript/create-only/vitest.config.local.ts +1 -7
  261. package/typescript/package-lisa/package.lisa.json +4 -4
  262. package/all/copy-overwrite/scripts/lisa-scratch-run.sh +0 -1078
  263. package/dist/cli/lisa-test-run-bootstrap.d.ts +0 -3
  264. package/dist/cli/lisa-test-run-bootstrap.d.ts.map +0 -1
  265. package/dist/cli/lisa-test-run-bootstrap.js +0 -229
  266. package/dist/cli/lisa-test-run-bootstrap.js.map +0 -1
  267. package/dist/cli/lisa-test-run-ipc.d.ts +0 -49
  268. package/dist/cli/lisa-test-run-ipc.d.ts.map +0 -1
  269. package/dist/cli/lisa-test-run-ipc.js +0 -226
  270. package/dist/cli/lisa-test-run-ipc.js.map +0 -1
  271. package/dist/cli/lisa-test-run-process-group.d.ts +0 -30
  272. package/dist/cli/lisa-test-run-process-group.d.ts.map +0 -1
  273. package/dist/cli/lisa-test-run-process-group.js +0 -140
  274. package/dist/cli/lisa-test-run-process-group.js.map +0 -1
  275. package/dist/cli/lisa-test-run-reaper.d.ts +0 -3
  276. package/dist/cli/lisa-test-run-reaper.d.ts.map +0 -1
  277. package/dist/cli/lisa-test-run-reaper.js +0 -195
  278. package/dist/cli/lisa-test-run-reaper.js.map +0 -1
  279. package/dist/cli/lisa-test-run-runtime.d.ts +0 -46
  280. package/dist/cli/lisa-test-run-runtime.d.ts.map +0 -1
  281. package/dist/cli/lisa-test-run-runtime.js +0 -123
  282. package/dist/cli/lisa-test-run-runtime.js.map +0 -1
  283. package/dist/cli/lisa-test-run-supervisor.d.ts +0 -13
  284. package/dist/cli/lisa-test-run-supervisor.d.ts.map +0 -1
  285. package/dist/cli/lisa-test-run-supervisor.js +0 -265
  286. package/dist/cli/lisa-test-run-supervisor.js.map +0 -1
  287. package/dist/configs/vitest/fleet-admission-global-setup.d.ts +0 -34
  288. package/dist/configs/vitest/fleet-admission-global-setup.d.ts.map +0 -1
  289. package/dist/configs/vitest/fleet-admission-global-setup.js +0 -123
  290. package/dist/configs/vitest/fleet-admission-global-setup.js.map +0 -1
  291. package/dist/configs/vitest/fleet-admission.d.ts +0 -129
  292. package/dist/configs/vitest/fleet-admission.d.ts.map +0 -1
  293. package/dist/configs/vitest/fleet-admission.js +0 -239
  294. package/dist/configs/vitest/fleet-admission.js.map +0 -1
  295. package/dist/configs/vitest/scratch-authority.d.ts +0 -25
  296. package/dist/configs/vitest/scratch-authority.d.ts.map +0 -1
  297. package/dist/configs/vitest/scratch-authority.js +0 -107
  298. package/dist/configs/vitest/scratch-authority.js.map +0 -1
  299. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts +0 -5
  300. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts.map +0 -1
  301. package/dist/configs/vitest/scratch-bound-cleanup-programs.js +0 -219
  302. package/dist/configs/vitest/scratch-bound-cleanup-programs.js.map +0 -1
  303. package/dist/configs/vitest/scratch-bound-cleanup.d.ts +0 -28
  304. package/dist/configs/vitest/scratch-bound-cleanup.d.ts.map +0 -1
  305. package/dist/configs/vitest/scratch-bound-cleanup.js +0 -155
  306. package/dist/configs/vitest/scratch-bound-cleanup.js.map +0 -1
  307. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts +0 -17
  308. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts.map +0 -1
  309. package/dist/configs/vitest/scratch-bound-root-cleanup.js +0 -149
  310. package/dist/configs/vitest/scratch-bound-root-cleanup.js.map +0 -1
  311. package/dist/configs/vitest/scratch-global-setup.d.ts +0 -258
  312. package/dist/configs/vitest/scratch-global-setup.d.ts.map +0 -1
  313. package/dist/configs/vitest/scratch-global-setup.js +0 -505
  314. package/dist/configs/vitest/scratch-global-setup.js.map +0 -1
  315. package/dist/configs/vitest/scratch-leak-setup.d.ts +0 -2
  316. package/dist/configs/vitest/scratch-leak-setup.d.ts.map +0 -1
  317. package/dist/configs/vitest/scratch-leak-setup.js +0 -108
  318. package/dist/configs/vitest/scratch-leak-setup.js.map +0 -1
  319. package/dist/configs/vitest/scratch-namespace-authority.d.ts +0 -80
  320. package/dist/configs/vitest/scratch-namespace-authority.d.ts.map +0 -1
  321. package/dist/configs/vitest/scratch-namespace-authority.js +0 -291
  322. package/dist/configs/vitest/scratch-namespace-authority.js.map +0 -1
  323. package/dist/configs/vitest/scratch-owner.d.ts +0 -131
  324. package/dist/configs/vitest/scratch-owner.d.ts.map +0 -1
  325. package/dist/configs/vitest/scratch-owner.js +0 -297
  326. package/dist/configs/vitest/scratch-owner.js.map +0 -1
  327. package/dist/configs/vitest/scratch-route-profile.d.ts +0 -46
  328. package/dist/configs/vitest/scratch-route-profile.d.ts.map +0 -1
  329. package/dist/configs/vitest/scratch-route-profile.js +0 -233
  330. package/dist/configs/vitest/scratch-route-profile.js.map +0 -1
  331. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts +0 -33
  332. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts.map +0 -1
  333. package/dist/configs/vitest/scratch-run-root-compatibility.js +0 -137
  334. package/dist/configs/vitest/scratch-run-root-compatibility.js.map +0 -1
  335. package/dist/configs/vitest/scratch-run-root-intent.d.ts +0 -66
  336. package/dist/configs/vitest/scratch-run-root-intent.d.ts.map +0 -1
  337. package/dist/configs/vitest/scratch-run-root-intent.js +0 -183
  338. package/dist/configs/vitest/scratch-run-root-intent.js.map +0 -1
  339. package/dist/configs/vitest/scratch-setup.d.ts +0 -46
  340. package/dist/configs/vitest/scratch-setup.d.ts.map +0 -1
  341. package/dist/configs/vitest/scratch-setup.js +0 -226
  342. package/dist/configs/vitest/scratch-setup.js.map +0 -1
  343. package/dist/configs/vitest/scratch-supervision-intent.d.ts +0 -8
  344. package/dist/configs/vitest/scratch-supervision-intent.d.ts.map +0 -1
  345. package/dist/configs/vitest/scratch-supervision-intent.js +0 -125
  346. package/dist/configs/vitest/scratch-supervision-intent.js.map +0 -1
  347. package/dist/configs/vitest/scratch-supervision-protocol.d.ts +0 -12
  348. package/dist/configs/vitest/scratch-supervision-protocol.d.ts.map +0 -1
  349. package/dist/configs/vitest/scratch-supervision-protocol.js +0 -230
  350. package/dist/configs/vitest/scratch-supervision-protocol.js.map +0 -1
  351. package/dist/configs/vitest/scratch-supervision.d.ts +0 -69
  352. package/dist/configs/vitest/scratch-supervision.d.ts.map +0 -1
  353. package/dist/configs/vitest/scratch-supervision.js +0 -244
  354. package/dist/configs/vitest/scratch-supervision.js.map +0 -1
  355. package/dist/configs/vitest/scratch-sweep.d.ts +0 -66
  356. package/dist/configs/vitest/scratch-sweep.d.ts.map +0 -1
  357. package/dist/configs/vitest/scratch-sweep.js +0 -82
  358. package/dist/configs/vitest/scratch-sweep.js.map +0 -1
  359. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts +0 -48
  360. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts.map +0 -1
  361. package/dist/configs/vitest/scratch-tmpdir-trust.js +0 -194
  362. package/dist/configs/vitest/scratch-tmpdir-trust.js.map +0 -1
  363. package/dist/configs/vitest/scratch.d.ts +0 -19
  364. package/dist/configs/vitest/scratch.d.ts.map +0 -1
  365. package/dist/configs/vitest/scratch.js +0 -34
  366. package/dist/configs/vitest/scratch.js.map +0 -1
  367. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts +0 -86
  368. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts.map +0 -1
  369. package/dist/configs/vitest/synthesis-scratch-reclaim.js +0 -226
  370. package/dist/configs/vitest/synthesis-scratch-reclaim.js.map +0 -1
@@ -0,0 +1,395 @@
1
+ /**
2
+ * The test-to-file access map Lisa's own CI records (CodySwannGT/lisa#4593).
3
+ *
4
+ * During the full PR run, every test file's entry lists the repository files
5
+ * that test imported, read or executed. B4 (#4600) reads the map to pick the
6
+ * tests a push affects, so it must see what the import graph cannot: Markdown
7
+ * a contract test reads through `fs`, and scripts a test spawns.
8
+ *
9
+ * Three pieces share this module so they cannot disagree on a path or a name:
10
+ *
11
+ * - the tracer (`test-access-map-tracer.mjs`), loaded into every test worker
12
+ * and every Node child through `NODE_OPTIONS=--import`, which records file
13
+ * reads, module loads and spawns against `LISA_ACCESS_MAP_TEST_FILE` and
14
+ * appends them as NDJSON under `LISA_ACCESS_MAP_DIR`;
15
+ * - the setup file (`test-access-map-setup.mjs`), which names the current test
16
+ * file for the tracer and adds the modules Vitest's own module runner
17
+ * evaluated (those never reach a Node loader hook);
18
+ * - the reporter built here, which merges the raw records once the run ends
19
+ * into `tmp/test-access-map/<scope>.json`.
20
+ *
21
+ * Everything is off unless `LISA_ACCESS_MAP=1` AND the project's effective
22
+ * `pushGate.affectedTests` is on, so ordinary local runs are untouched. The
23
+ * shipped Vitest presets carry the plugin (CodySwannGT/lisa#4611), so a host's
24
+ * own CI records its map the same way Lisa's does.
25
+ * @module test-access-map
26
+ */
27
+ import * as fs from "node:fs";
28
+ import * as path from "node:path";
29
+ import { pathToFileURL } from "node:url";
30
+
31
+ import { withPushGateDefaults } from "../../all/copy-overwrite/scripts/lib/push-gate-defaults.mjs";
32
+ import { declaredTestScope } from "./test-timings-reporter.mjs";
33
+
34
+ /** Directory, relative to the Vitest root, the per-scope maps land in. */
35
+ export const TEST_ACCESS_MAP_DIRECTORY = "tmp/test-access-map";
36
+
37
+ /** Bumped whenever what the tracer records changes meaning. */
38
+ export const TEST_ACCESS_MAP_TRACER_VERSION = 1;
39
+
40
+ /** Environment the tracer reads; set by {@link armTestAccessMap}. */
41
+ export const ACCESS_MAP_ENV = Object.freeze({
42
+ enabled: "LISA_ACCESS_MAP",
43
+ directory: "LISA_ACCESS_MAP_DIR",
44
+ root: "LISA_ACCESS_MAP_ROOT",
45
+ testFile: "LISA_ACCESS_MAP_TEST_FILE",
46
+ owner: "LISA_ACCESS_MAP_OWNER_PID",
47
+ });
48
+
49
+ /** Repository prefixes that are dependencies or generated output, not sources. */
50
+ const DROPPED_PREFIXES = Object.freeze([
51
+ ".git/",
52
+ "node_modules/",
53
+ "dist/",
54
+ "coverage/",
55
+ "tmp/",
56
+ ]);
57
+
58
+ const TRACER_PATH = path.join(
59
+ import.meta.dirname,
60
+ "test-access-map-tracer.mjs"
61
+ );
62
+
63
+ /** The Vitest setup file that names each test file for the tracer. */
64
+ export const TEST_ACCESS_MAP_SETUP_FILE = path.join(
65
+ import.meta.dirname,
66
+ "test-access-map-setup.mjs"
67
+ );
68
+
69
+ /**
70
+ * Whether the access map is requested for this process.
71
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
72
+ * @returns {boolean} True when `LISA_ACCESS_MAP=1`
73
+ */
74
+ export function testAccessMapEnabled(env) {
75
+ return env[ACCESS_MAP_ENV.enabled] === "1";
76
+ }
77
+
78
+ /**
79
+ * The scope this run records a map for, or `undefined` when it records none.
80
+ * Never in a Vitest process a test spawned (a worker exports
81
+ * `VITEST_WORKER_ID` to its children): a nested fixture run is attributed to
82
+ * the outer test instead of writing a map of its own.
83
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
84
+ * @returns {"unit" | "integration" | undefined} Scope
85
+ */
86
+ export function testAccessMapScope(env) {
87
+ if (!testAccessMapEnabled(env) || env["VITEST_WORKER_ID"] !== undefined)
88
+ return undefined;
89
+ return declaredTestScope(env);
90
+ }
91
+
92
+ /**
93
+ * A recorded absolute path as a repository-relative POSIX path, or
94
+ * `undefined` when it is outside the repository, a dependency, or generated
95
+ * output.
96
+ * @param {string} root - Repository root (absolute)
97
+ * @param {string} file - Absolute or `file:` URL path
98
+ * @returns {string | undefined} Repository-relative path
99
+ */
100
+ export function repositoryFile(root, file) {
101
+ const absolute = file.startsWith("file:")
102
+ ? decodeURIComponent(new URL(file).pathname)
103
+ : file;
104
+ if (!path.isAbsolute(absolute)) return undefined;
105
+ const relative = path.relative(root, path.normalize(absolute));
106
+ if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative))
107
+ return undefined;
108
+ const posix = relative.split(path.sep).join("/");
109
+ if (
110
+ DROPPED_PREFIXES.some(prefix => posix.startsWith(prefix)) ||
111
+ posix.includes("/node_modules/")
112
+ )
113
+ return undefined;
114
+ return posix;
115
+ }
116
+
117
+ /**
118
+ * Merge raw NDJSON records (`{"test": abs, "files": [abs, …]}`) into a map
119
+ * keyed by repository-relative test file. Every executed test file gets an
120
+ * entry, even one that touched nothing else, and lists itself.
121
+ * @param {object} input - Inputs
122
+ * @param {string} input.root - Repository root
123
+ * @param {ReadonlyArray<string>} input.lines - Raw NDJSON lines
124
+ * @param {ReadonlyArray<string>} input.testFiles - Absolute paths of executed test files
125
+ * @returns {Readonly<Record<string, ReadonlyArray<string>>>} Sorted map
126
+ */
127
+ export function mergeAccessRecords({ root, lines, testFiles }) {
128
+ const records = lines.flatMap(line => {
129
+ if (line.trim() === "") return [];
130
+ try {
131
+ const parsed = JSON.parse(line);
132
+ return typeof parsed?.test === "string" && Array.isArray(parsed.files)
133
+ ? [parsed]
134
+ : [];
135
+ } catch {
136
+ return [];
137
+ }
138
+ });
139
+ const entries = [
140
+ ...testFiles.map(test => ({ test, files: [test] })),
141
+ ...records,
142
+ ].flatMap(({ test, files }) => {
143
+ const key = repositoryFile(root, test);
144
+ if (key === undefined) return [];
145
+ return [
146
+ [
147
+ key,
148
+ files.flatMap(file => {
149
+ const relative =
150
+ typeof file === "string" ? repositoryFile(root, file) : undefined;
151
+ return relative === undefined ? [] : [relative];
152
+ }),
153
+ ],
154
+ ];
155
+ });
156
+
157
+ const grouped = entries.reduce((map, [key, files]) => {
158
+ const set = map.get(key) ?? new Set([key]);
159
+ files.forEach(file => set.add(file));
160
+ return map.set(key, set);
161
+ }, new Map());
162
+
163
+ return Object.fromEntries(
164
+ [...grouped.keys()].sort().map(key => [key, [...grouped.get(key)].sort()])
165
+ );
166
+ }
167
+
168
+ /**
169
+ * A whole number from the environment that is at least `minimum`, or null.
170
+ * @param {string | undefined} value - Raw value
171
+ * @param {number} minimum - Smallest accepted value
172
+ * @returns {number | null} The number, or null
173
+ */
174
+ function wholeNumber(value, minimum) {
175
+ const parsed = /^\d+$/.test(value ?? "") ? Number(value) : Number.NaN;
176
+ return Number.isSafeInteger(parsed) && parsed >= minimum ? parsed : null;
177
+ }
178
+
179
+ /**
180
+ * Metadata a published map carries, read from the CI environment.
181
+ *
182
+ * `piece` and `pieces` (CodySwannGT/lisa#4593) say which piece of the scope's
183
+ * map this job uploaded and how many the scope has: the workflow passes the
184
+ * job's `strategy.job-index` and `strategy.job-total` as
185
+ * `LISA_ACCESS_MAP_PIECE` and `LISA_ACCESS_MAP_PIECES`. The fetcher refuses a
186
+ * run missing any piece, because a shard that never uploaded would otherwise
187
+ * drop its tests from the merged map, and refuses a piece with no count.
188
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
189
+ * @param {string} scope - Map scope
190
+ * @param {Date} now - Creation time
191
+ * @param {ReadonlyArray<string>} [triggers] - The project's full-rerun triggers
192
+ * @returns {Readonly<Record<string, unknown>>} Metadata
193
+ */
194
+ export function accessMapMetadata(env, scope, now, triggers = []) {
195
+ return {
196
+ scope,
197
+ baseSha: env["LISA_ACCESS_MAP_BASE_SHA"] || null,
198
+ headSha: env["LISA_ACCESS_MAP_HEAD_SHA"] || env["GITHUB_SHA"] || null,
199
+ runId: env["GITHUB_RUN_ID"] || null,
200
+ createdAt: now.toISOString(),
201
+ tracerVersion: TEST_ACCESS_MAP_TRACER_VERSION,
202
+ piece: wholeNumber(env["LISA_ACCESS_MAP_PIECE"], 0),
203
+ pieces: wholeNumber(env["LISA_ACCESS_MAP_PIECES"], 1),
204
+ triggers: [...triggers],
205
+ };
206
+ }
207
+
208
+ /**
209
+ * The project's own full-rerun triggers, from its resolved Vitest config, as
210
+ * repository-relative globs (CodySwannGT/lisa#4611).
211
+ *
212
+ * The selector cannot resolve a host's merged Vitest config at push, so the
213
+ * recorder writes `forceRerunTriggers`, `setupFiles` and `globalSetup` into
214
+ * the map. A change to any of them then runs the full suite with the trigger
215
+ * printed. Absolute paths become repository-relative, and paths outside the
216
+ * repository or under `node_modules` (Lisa's own preset files) are dropped.
217
+ * @param {string} root - Vitest root directory
218
+ * @param {{ forceRerunTriggers?: unknown, setupFiles?: unknown, globalSetup?: unknown }} config - Resolved Vitest config
219
+ * @returns {ReadonlyArray<string>} Sorted, de-duplicated globs
220
+ */
221
+ export function configuredTriggers(root, config) {
222
+ const listed = ["forceRerunTriggers", "setupFiles", "globalSetup"].flatMap(
223
+ key => {
224
+ const value = config?.[key];
225
+ const entries = Array.isArray(value) ? value : [value];
226
+ return entries.filter(entry => typeof entry === "string" && entry);
227
+ }
228
+ );
229
+ const globs = listed.flatMap(entry => {
230
+ if (!path.isAbsolute(entry) && !entry.startsWith("file:")) return [entry];
231
+ const relative = repositoryFile(root, entry);
232
+ return relative === undefined ? [] : [relative];
233
+ });
234
+ return [...new Set(globs)].sort();
235
+ }
236
+
237
+ /**
238
+ * Whether the project at `root` wants a map recorded: its effective
239
+ * `pushGate.affectedTests`, stack defaults included (CodySwannGT/lisa#4611).
240
+ * A host that turned selection off pays nothing for a map it never reads. A
241
+ * missing or unreadable config falls back to the stack default; a malformed
242
+ * `pushGate` records nothing.
243
+ * @param {string} root - Project root
244
+ * @returns {boolean} True when the map is wanted
245
+ */
246
+ export function accessMapWanted(root) {
247
+ const config = (() => {
248
+ try {
249
+ return JSON.parse(
250
+ fs.readFileSync(path.join(root, ".lisa.config.json"), "utf8")
251
+ );
252
+ } catch {
253
+ return {};
254
+ }
255
+ })();
256
+ return withPushGateDefaults(config, root).pushGate?.affectedTests === true;
257
+ }
258
+
259
+ /**
260
+ * Prepare this process's environment so every worker and Node child the run
261
+ * starts inherits the tracer. Idempotent: the hook runs once per project.
262
+ * Returns the raw-record directory, or `undefined` when the map is off.
263
+ * @param {Record<string, string | undefined>} env - Process environment (mutated)
264
+ * @param {string} root - Vitest root directory
265
+ * @returns {string | undefined} Raw-record directory
266
+ */
267
+ export function armTestAccessMap(env, root) {
268
+ const scope = testAccessMapScope(env);
269
+ if (scope === undefined) return undefined;
270
+ const existing = env[ACCESS_MAP_ENV.directory];
271
+ if (existing !== undefined) return existing;
272
+ const directory = path.join(
273
+ root,
274
+ TEST_ACCESS_MAP_DIRECTORY,
275
+ `raw-${scope}-${process.pid}`
276
+ );
277
+ fs.rmSync(directory, { recursive: true, force: true });
278
+ const importFlag = `--import=${pathToFileURL(TRACER_PATH).href}`;
279
+ const options = env["NODE_OPTIONS"] ?? "";
280
+
281
+ env[ACCESS_MAP_ENV.directory] = directory;
282
+ env[ACCESS_MAP_ENV.root] = root;
283
+ if (!options.includes(importFlag))
284
+ env["NODE_OPTIONS"] = `${options} ${importFlag}`.trim();
285
+
286
+ return directory;
287
+ }
288
+
289
+ /**
290
+ * Every NDJSON line under the raw-record directory.
291
+ * @param {string} directory - Raw-record directory
292
+ * @returns {ReadonlyArray<string> | undefined} Lines, or undefined when nothing was recorded
293
+ */
294
+ function rawLines(directory) {
295
+ if (!fs.existsSync(directory)) return undefined;
296
+ const files = fs
297
+ .readdirSync(directory)
298
+ .filter(name => name.endsWith(".ndjson"));
299
+ if (files.length === 0) return undefined;
300
+ return files.flatMap(name =>
301
+ fs.readFileSync(path.join(directory, name), "utf8").split("\n")
302
+ );
303
+ }
304
+
305
+ /**
306
+ * A Vitest reporter that writes `<root>/tmp/test-access-map/<scope>.json`
307
+ * once the run ends: `{ meta, map }`. A run that recorded nothing — a
308
+ * `--merge-reports` aggregate, say — writes nothing rather than an empty map.
309
+ * @param {object} input - Inputs
310
+ * @param {string} input.root - Vitest root directory
311
+ * @param {string} input.directory - Raw-record directory
312
+ * @param {Readonly<Record<string, string | undefined>>} input.env - Process environment
313
+ * @param {ReadonlyArray<string>} [input.triggers] - The project's full-rerun triggers
314
+ * @returns {{ onTestRunEnd: (modules: ReadonlyArray<{ moduleId: string, state: () => string }>) => void }} Reporter
315
+ */
316
+ export function testAccessMapReporter({ root, directory, env, triggers = [] }) {
317
+ return {
318
+ lisaTestAccessMap: true,
319
+ onTestRunEnd(testModules) {
320
+ const scope = testAccessMapScope(env);
321
+ const lines = rawLines(directory);
322
+ if (scope === undefined || lines === undefined) return;
323
+ const testFiles = testModules
324
+ .filter(module => module.state() !== "skipped")
325
+ .map(module => module.moduleId);
326
+ const map = mergeAccessRecords({ root, lines, testFiles });
327
+ const output = path.join(
328
+ root,
329
+ TEST_ACCESS_MAP_DIRECTORY,
330
+ `${scope}.json`
331
+ );
332
+ fs.mkdirSync(path.dirname(output), { recursive: true });
333
+ fs.writeFileSync(
334
+ output,
335
+ `${JSON.stringify({ meta: accessMapMetadata(env, scope, new Date(), triggers), map }, null, 2)}\n`
336
+ );
337
+ fs.rmSync(directory, { recursive: true, force: true });
338
+ },
339
+ };
340
+ }
341
+
342
+ /**
343
+ * The resolved reporters with the access-map reporter appended once. The
344
+ * config hook runs once per Vitest project and every project shares one list.
345
+ * @param {ReadonlyArray<unknown>} reporters - Resolved reporters
346
+ * @param {object} reporter - The access-map reporter
347
+ * @returns {ReadonlyArray<unknown>} Reporters, with an access-map reporter at most once
348
+ */
349
+ export function withTestAccessMapReporter(reporters, reporter) {
350
+ const present = reporters.some(
351
+ entry =>
352
+ typeof entry === "object" &&
353
+ entry !== null &&
354
+ !Array.isArray(entry) &&
355
+ entry.lisaTestAccessMap === true
356
+ );
357
+ return present ? reporters : [...reporters, reporter];
358
+ }
359
+
360
+ /**
361
+ * The setup files the access map adds: its own when the map is on, else none.
362
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
363
+ * @returns {ReadonlyArray<string>} Setup files
364
+ */
365
+ export function testAccessMapSetupFiles(env) {
366
+ return testAccessMapEnabled(env) ? [TEST_ACCESS_MAP_SETUP_FILE] : [];
367
+ }
368
+
369
+ /**
370
+ * The Vitest plugin that arms the tracer and appends the reporter. It works
371
+ * after config resolution, so a shard leg's CLI `--reporter=blob` keeps it.
372
+ * @param {Record<string, string | undefined>} [env] - Process environment (mutated when armed)
373
+ * @returns {{ name: string, configureVitest: (context: { vitest: { config: { root: string, reporters: unknown[] } } }) => void }} Plugin
374
+ */
375
+ export function testAccessMapPlugin(env = process.env) {
376
+ return {
377
+ name: "lisa:test-access-map",
378
+ configureVitest({ vitest }) {
379
+ const root = vitest.config.root;
380
+ if (!testAccessMapEnabled(env) || !accessMapWanted(root)) return;
381
+ const directory = armTestAccessMap(env, root);
382
+ if (directory === undefined) return;
383
+ const reporter = testAccessMapReporter({
384
+ root,
385
+ directory,
386
+ env,
387
+ triggers: configuredTriggers(root, vitest.config),
388
+ });
389
+
390
+ vitest.config.reporters = [
391
+ ...withTestAccessMapReporter(vitest.config.reporters, reporter),
392
+ ];
393
+ },
394
+ };
395
+ }
@@ -0,0 +1,17 @@
1
+ export declare const TEST_TIMINGS_DIRECTORY: "tmp/test-timings";
2
+ export declare const TEST_TIMINGS_SCOPES: readonly ["unit", "integration"];
3
+ export declare function testTimingsScope(
4
+ env: Readonly<Record<string, string | undefined>>
5
+ ): "unit" | "integration" | undefined;
6
+ export declare function declaredTestScope(
7
+ env: Readonly<Record<string, string | undefined>>
8
+ ): "unit" | "integration" | undefined;
9
+ export declare function testTimingsReporter(
10
+ env: Readonly<Record<string, string | undefined>>,
11
+ root: string
12
+ ): ["json", { outputFile: string }] | undefined;
13
+ export declare function withTestTimingsReporter<T>(
14
+ reporters: readonly T[],
15
+ env: Readonly<Record<string, string | undefined>>,
16
+ root: string
17
+ ): readonly (T | ["json", { outputFile: string }])[];
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Where Lisa's own CI writes per-file test timings (CodySwannGT/lisa#4592).
3
+ *
4
+ * Lisa-only: `vitest.config.local.ts` appends Vitest's built-in `json`
5
+ * reporter beside whatever reporters a run already resolved, and
6
+ * `scripts/test-timing-report.mjs` reads the files it writes. Both sides take
7
+ * the scope and the directory from here so they cannot disagree.
8
+ *
9
+ * The reporter is appended in a `configureVitest` hook rather than declared in
10
+ * `reporters`, because a declared list is replaced outright by a CLI
11
+ * `--reporter`, and every unit-test shard leg runs with `--reporter=blob`
12
+ * (`src/cli/lisa-test-run-shard.ts`). Appending after resolution keeps the
13
+ * blob a shard leg needs, the default and `github-actions` reporters a normal
14
+ * run gets, and adds the timings file to all of them.
15
+ * @module test-timings-reporter
16
+ */
17
+ import * as path from "node:path";
18
+
19
+ /** Directory, relative to the Vitest root, the timing files land in. */
20
+ export const TEST_TIMINGS_DIRECTORY = "tmp/test-timings";
21
+
22
+ /** Every scope a timing file can carry; the report requires each one. */
23
+ export const TEST_TIMINGS_SCOPES = Object.freeze(["unit", "integration"]);
24
+
25
+ /**
26
+ * Whether `CI` is set to something that means "yes".
27
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
28
+ * @returns {boolean} True on a CI runner
29
+ */
30
+ function onCi(env) {
31
+ const value = env["CI"];
32
+ return (
33
+ value !== undefined && value !== "" && value !== "0" && value !== "false"
34
+ );
35
+ }
36
+
37
+ /**
38
+ * The timing scope of this run, or `undefined` when it records none.
39
+ *
40
+ * Only on CI, and never in a Vitest process a test spawned (a worker exports
41
+ * `VITEST_WORKER_ID` to its children): a nested run would otherwise write over
42
+ * the outer run's file with a fixture's results.
43
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
44
+ * @returns {string | undefined} `unit`, `integration`, or undefined
45
+ */
46
+ export function testTimingsScope(env) {
47
+ if (!onCi(env) || env["VITEST_WORKER_ID"] !== undefined) return undefined;
48
+ return declaredTestScope(env);
49
+ }
50
+
51
+ /**
52
+ * The scope a run declares, whether or not anything records it:
53
+ * `LISA_TEST_TIMINGS_SCOPE` when set, else `unit` for the unit coverage
54
+ * scope. The test access map (#4593) keys its files on the same scope.
55
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
56
+ * @returns {string | undefined} `unit`, `integration`, or undefined
57
+ */
58
+ export function declaredTestScope(env) {
59
+ const declared = env["LISA_TEST_TIMINGS_SCOPE"];
60
+ if (declared !== undefined && declared !== "")
61
+ return TEST_TIMINGS_SCOPES.includes(declared) ? declared : undefined;
62
+ return env["LISA_COVERAGE_SCOPE"] === "unit" ? "unit" : undefined;
63
+ }
64
+
65
+ /**
66
+ * The `json` reporter entry this run adds, or `undefined` when it adds none.
67
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
68
+ * @param {string} root - Vitest root directory
69
+ * @returns {readonly ["json", { readonly outputFile: string }] | undefined} Reporter entry
70
+ */
71
+ export function testTimingsReporter(env, root) {
72
+ const scope = testTimingsScope(env);
73
+ if (scope === undefined) return undefined;
74
+ return [
75
+ "json",
76
+ { outputFile: path.join(root, TEST_TIMINGS_DIRECTORY, `${scope}.json`) },
77
+ ];
78
+ }
79
+
80
+ /**
81
+ * The resolved reporters with the timing reporter appended once. Idempotent,
82
+ * because the hook runs once per Vitest project and every project shares one
83
+ * resolved list.
84
+ * @param {ReadonlyArray<unknown>} reporters - Resolved reporters
85
+ * @param {Readonly<Record<string, string | undefined>>} env - Process environment
86
+ * @param {string} root - Vitest root directory
87
+ * @returns {ReadonlyArray<unknown>} Reporters, with the timing reporter at most once
88
+ */
89
+ export function withTestTimingsReporter(reporters, env, root) {
90
+ const reporter = testTimingsReporter(env, root);
91
+ if (reporter === undefined) return reporters;
92
+ const present = reporters.some(
93
+ entry =>
94
+ Array.isArray(entry) &&
95
+ entry[0] === "json" &&
96
+ entry[1]?.outputFile === reporter[1].outputFile
97
+ );
98
+ return present ? reporters : [...reporters, reporter];
99
+ }