@codyswann/lisa 5.3.2 → 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 (373) 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-contract.mjs +13 -3
  8. package/all/copy-overwrite/scripts/lib/automation-provenance-local.mjs +22 -1
  9. package/all/copy-overwrite/scripts/lib/build-marker.mjs +410 -0
  10. package/all/copy-overwrite/scripts/lib/gate-pass-cache.mjs +537 -0
  11. package/all/copy-overwrite/scripts/lib/kill-marks.mjs +1 -2
  12. package/all/copy-overwrite/scripts/lib/lisa-cleanup-sweep-processes.mjs +3 -4
  13. package/all/copy-overwrite/scripts/lib/npm-update-bun.mjs +39 -14
  14. package/all/copy-overwrite/scripts/lib/npm-update-controller-broker.mjs +1 -1
  15. package/all/copy-overwrite/scripts/lib/npm-update-gate-hooks.mjs +2 -1
  16. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +8 -1
  17. package/all/copy-overwrite/scripts/lib/npm-update-hosted-gate.mjs +25 -9
  18. package/all/copy-overwrite/scripts/lib/npm-update-hosted-hook.mjs +1 -1
  19. package/all/copy-overwrite/scripts/lib/npm-update-tool-launcher.mjs +1 -1
  20. package/all/copy-overwrite/scripts/lib/push-admission.mjs +158 -0
  21. package/all/copy-overwrite/scripts/lib/push-gate-defaults.d.mts +34 -0
  22. package/all/copy-overwrite/scripts/lib/push-gate-defaults.mjs +147 -0
  23. package/all/copy-overwrite/scripts/lib/push-timing.mjs +323 -0
  24. package/all/copy-overwrite/scripts/lib/rspec-selection.mjs +672 -0
  25. package/all/copy-overwrite/scripts/lisa-affected-tests.mjs +566 -0
  26. package/all/copy-overwrite/scripts/lisa-gates.mjs +29 -0
  27. package/all/copy-overwrite/scripts/lisa-lint-staged-preflight.mjs +10 -1
  28. package/all/copy-overwrite/scripts/lisa-push-timing-report.mjs +153 -0
  29. package/all/copy-overwrite/scripts/lisa-rspec-select.mjs +982 -0
  30. package/all/copy-overwrite/scripts/lisa-run-gates.mjs +231 -6
  31. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +108 -20
  32. package/all/deletions.json +11 -2
  33. package/cdk/create-only/vitest.config.local.ts +1 -7
  34. package/cdk/package-lisa/package.lisa.json +4 -4
  35. package/dist/cli/admit-cmd.d.ts +21 -0
  36. package/dist/cli/admit-cmd.d.ts.map +1 -0
  37. package/dist/cli/admit-cmd.js +142 -0
  38. package/dist/cli/admit-cmd.js.map +1 -0
  39. package/dist/cli/check-cmd.d.ts +72 -0
  40. package/dist/cli/check-cmd.d.ts.map +1 -0
  41. package/dist/cli/check-cmd.js +316 -0
  42. package/dist/cli/check-cmd.js.map +1 -0
  43. package/dist/cli/index.d.ts.map +1 -1
  44. package/dist/cli/index.js +6 -4
  45. package/dist/cli/index.js.map +1 -1
  46. package/dist/cli/lisa-test-run-admission.d.ts +18 -0
  47. package/dist/cli/lisa-test-run-admission.d.ts.map +1 -0
  48. package/dist/cli/lisa-test-run-admission.js +62 -0
  49. package/dist/cli/lisa-test-run-admission.js.map +1 -0
  50. package/dist/cli/lisa-test-run-payload.d.ts +37 -0
  51. package/dist/cli/lisa-test-run-payload.d.ts.map +1 -0
  52. package/dist/cli/lisa-test-run-payload.js +55 -0
  53. package/dist/cli/lisa-test-run-payload.js.map +1 -0
  54. package/dist/cli/lisa-test-run-shard-files.d.ts +89 -0
  55. package/dist/cli/lisa-test-run-shard-files.d.ts.map +1 -0
  56. package/dist/cli/lisa-test-run-shard-files.js +239 -0
  57. package/dist/cli/lisa-test-run-shard-files.js.map +1 -0
  58. package/dist/cli/lisa-test-run-shard.d.ts +6 -2
  59. package/dist/cli/lisa-test-run-shard.d.ts.map +1 -1
  60. package/dist/cli/lisa-test-run-shard.js +25 -13
  61. package/dist/cli/lisa-test-run-shard.js.map +1 -1
  62. package/dist/cli/lisa-test-run.d.ts +1 -1
  63. package/dist/cli/lisa-test-run.d.ts.map +1 -1
  64. package/dist/cli/lisa-test-run.js +47 -10
  65. package/dist/cli/lisa-test-run.js.map +1 -1
  66. package/dist/cli/update-check-hook.d.ts.map +1 -1
  67. package/dist/cli/update-check-hook.js +3 -0
  68. package/dist/cli/update-check-hook.js.map +1 -1
  69. package/dist/configs/vitest/base.d.ts +58 -135
  70. package/dist/configs/vitest/base.d.ts.map +1 -1
  71. package/dist/configs/vitest/base.js +76 -228
  72. package/dist/configs/vitest/base.js.map +1 -1
  73. package/dist/configs/vitest/cdk.d.ts.map +1 -1
  74. package/dist/configs/vitest/cdk.js +3 -2
  75. package/dist/configs/vitest/cdk.js.map +1 -1
  76. package/dist/configs/vitest/coverage-include-global-setup.d.ts.map +1 -1
  77. package/dist/configs/vitest/coverage-include-global-setup.js +3 -4
  78. package/dist/configs/vitest/coverage-include-global-setup.js.map +1 -1
  79. package/dist/configs/vitest/coverage-reports-directory.d.ts +27 -5
  80. package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
  81. package/dist/configs/vitest/coverage-reports-directory.js +47 -10
  82. package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
  83. package/dist/configs/vitest/harper-fabric.d.ts.map +1 -1
  84. package/dist/configs/vitest/harper-fabric.js +3 -2
  85. package/dist/configs/vitest/harper-fabric.js.map +1 -1
  86. package/dist/configs/vitest/nestjs.d.ts.map +1 -1
  87. package/dist/configs/vitest/nestjs.js +3 -2
  88. package/dist/configs/vitest/nestjs.js.map +1 -1
  89. package/dist/configs/vitest/phaser.d.ts.map +1 -1
  90. package/dist/configs/vitest/phaser.js +3 -2
  91. package/dist/configs/vitest/phaser.js.map +1 -1
  92. package/dist/configs/vitest/refusal-announcement.d.ts +51 -0
  93. package/dist/configs/vitest/refusal-announcement.d.ts.map +1 -0
  94. package/dist/configs/vitest/refusal-announcement.js +97 -0
  95. package/dist/configs/vitest/refusal-announcement.js.map +1 -0
  96. package/dist/configs/vitest/socket-safe-temp-base.d.ts +3 -4
  97. package/dist/configs/vitest/socket-safe-temp-base.d.ts.map +1 -1
  98. package/dist/configs/vitest/socket-safe-temp-base.js +7 -6
  99. package/dist/configs/vitest/socket-safe-temp-base.js.map +1 -1
  100. package/dist/configs/vitest/typescript.d.ts.map +1 -1
  101. package/dist/configs/vitest/typescript.js +3 -2
  102. package/dist/configs/vitest/typescript.js.map +1 -1
  103. package/dist/core/admission-decision.d.ts +110 -0
  104. package/dist/core/admission-decision.d.ts.map +1 -0
  105. package/dist/core/admission-decision.js +91 -0
  106. package/dist/core/admission-decision.js.map +1 -0
  107. package/dist/core/admission-lock.d.ts +69 -0
  108. package/dist/core/admission-lock.d.ts.map +1 -0
  109. package/dist/core/admission-lock.js +278 -0
  110. package/dist/core/admission-lock.js.map +1 -0
  111. package/dist/core/admission-settings.d.ts +69 -0
  112. package/dist/core/admission-settings.d.ts.map +1 -0
  113. package/dist/core/admission-settings.js +204 -0
  114. package/dist/core/admission-settings.js.map +1 -0
  115. package/dist/core/admission-state.d.ts +50 -0
  116. package/dist/core/admission-state.d.ts.map +1 -0
  117. package/dist/core/admission-state.js +168 -0
  118. package/dist/core/admission-state.js.map +1 -0
  119. package/dist/core/admission.d.ts +70 -0
  120. package/dist/core/admission.d.ts.map +1 -0
  121. package/dist/core/admission.js +205 -0
  122. package/dist/core/admission.js.map +1 -0
  123. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  124. package/dist/core/lisa-owned-hash-ledger.js +336 -0
  125. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  126. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  127. package/dist/core/project-config-push-gate.d.ts +66 -0
  128. package/dist/core/project-config-push-gate.d.ts.map +1 -0
  129. package/dist/core/project-config-push-gate.js +82 -0
  130. package/dist/core/project-config-push-gate.js.map +1 -0
  131. package/dist/core/project-config.d.ts +4 -0
  132. package/dist/core/project-config.d.ts.map +1 -1
  133. package/dist/core/project-config.js +14 -9
  134. package/dist/core/project-config.js.map +1 -1
  135. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  136. package/dist/core/upstream-evidence-manifest.js +207 -126
  137. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  138. package/expo/package-lisa/package.lisa.json +2 -2
  139. package/harper-fabric/package-lisa/package.lisa.json +4 -4
  140. package/nestjs/create-only/vitest.config.local.ts +1 -7
  141. package/nestjs/package-lisa/package.lisa.json +4 -4
  142. package/npm-package/package-lisa/package.lisa.json +4 -4
  143. package/package.json +12 -11
  144. package/phaser/package-lisa/package.lisa.json +4 -4
  145. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  146. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  147. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  148. package/plugins/lisa/.codex-plugin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  149. package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +1 -1
  150. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  151. package/plugins/lisa/skills/lisa-git-submit-pr/SKILL.md +1 -1
  152. package/plugins/lisa/skills/lisa-implement/SKILL.md +1 -1
  153. package/plugins/lisa-agy/plugin.json +1 -1
  154. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  155. package/plugins/lisa-agy/skills/lisa-git-submit-pr/SKILL.md +1 -1
  156. package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +1 -1
  157. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  158. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  159. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  160. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  161. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  162. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  163. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  164. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  165. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  166. package/plugins/lisa-copilot/skills/lisa-git-submit-pr/SKILL.md +1 -1
  167. package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +1 -1
  168. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  169. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  170. package/plugins/lisa-cursor/skills/lisa-git-submit-pr/SKILL.md +1 -1
  171. package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +1 -1
  172. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  173. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  174. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  175. package/plugins/lisa-devin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  176. package/plugins/lisa-devin/skills/lisa-implement/SKILL.md +1 -1
  177. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  178. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  179. package/plugins/lisa-expo-agy/plugin.json +1 -1
  180. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  181. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  183. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  184. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  185. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  186. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  187. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  188. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  189. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  190. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  191. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  192. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  193. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  194. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  195. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  196. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  197. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  198. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  199. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  200. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  201. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  202. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  204. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  205. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  206. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  207. package/plugins/lisa-rails-agy/plugin.json +1 -1
  208. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  209. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  210. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  211. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  212. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  213. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  214. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  215. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  216. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  217. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  218. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  219. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  220. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  221. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  222. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  223. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  224. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  225. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  226. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  227. package/plugins/src/base/skills/lisa-git-submit-pr/SKILL.md +1 -1
  228. package/plugins/src/base/skills/lisa-implement/SKILL.md +1 -1
  229. package/rails/copy-overwrite/Gemfile.lisa +8 -0
  230. package/rails/copy-overwrite/lefthook.yml +25 -11
  231. package/rails/copy-overwrite/scripts/lisa-rails-gates.mjs +686 -0
  232. package/rails/copy-overwrite/scripts/lisa-rspec-shards.mjs +2 -2
  233. package/rails/copy-overwrite/scripts/lisa_crystalball_recorder.rb +239 -0
  234. package/rails/copy-overwrite/scripts/lisa_rspec_partial_coverage.rb +83 -0
  235. package/scripts/build-unless-marked.mjs +83 -0
  236. package/scripts/check-plugins-sync.sh +22 -5
  237. package/scripts/classify-markdown-assertions.mjs +141 -0
  238. package/scripts/integration-shard-build.mjs +143 -0
  239. package/scripts/lib/history-scanner-suites.mjs +19 -0
  240. package/scripts/lib/markdown-assertions/classify.mjs +289 -0
  241. package/scripts/lib/markdown-assertions/context.mjs +53 -0
  242. package/scripts/lib/markdown-assertions/corpus.mjs +222 -0
  243. package/scripts/lib/markdown-assertions/manifest-cull.mjs +86 -0
  244. package/scripts/lib/markdown-assertions/record-setup.mjs +265 -0
  245. package/scripts/lib/markdown-assertions/record.mjs +115 -0
  246. package/scripts/lib/markdown-assertions/record.vitest.config.mjs +24 -0
  247. package/scripts/lib/markdown-assertions/sites.mjs +273 -0
  248. package/scripts/lib/markdown-assertions/test-cull.mjs +768 -0
  249. package/scripts/lib/markdown-assertions/tokens.mjs +158 -0
  250. package/scripts/lib/shell-guard-trace.mjs +6 -0
  251. package/scripts/lib/test-access-map-setup.mjs +40 -0
  252. package/scripts/lib/test-access-map-tracer.mjs +205 -0
  253. package/scripts/lib/test-access-map.d.mts +72 -0
  254. package/scripts/lib/test-access-map.mjs +395 -0
  255. package/scripts/lib/test-timings-reporter.d.mts +17 -0
  256. package/scripts/lib/test-timings-reporter.mjs +99 -0
  257. package/scripts/plan-integration-shards.mjs +300 -0
  258. package/scripts/test-timing-report.d.mts +41 -0
  259. package/scripts/test-timing-report.mjs +361 -0
  260. package/scripts/two-channel-couplings.json +132 -36
  261. package/scripts/verify-npm-advisories-4333.mjs +3 -12
  262. package/typescript/copy-overwrite/.prettierignore +12 -0
  263. package/typescript/create-only/vitest.config.local.ts +1 -7
  264. package/typescript/package-lisa/package.lisa.json +4 -4
  265. package/all/copy-overwrite/scripts/lisa-scratch-run.sh +0 -1078
  266. package/dist/cli/lisa-test-run-bootstrap.d.ts +0 -3
  267. package/dist/cli/lisa-test-run-bootstrap.d.ts.map +0 -1
  268. package/dist/cli/lisa-test-run-bootstrap.js +0 -229
  269. package/dist/cli/lisa-test-run-bootstrap.js.map +0 -1
  270. package/dist/cli/lisa-test-run-ipc.d.ts +0 -49
  271. package/dist/cli/lisa-test-run-ipc.d.ts.map +0 -1
  272. package/dist/cli/lisa-test-run-ipc.js +0 -226
  273. package/dist/cli/lisa-test-run-ipc.js.map +0 -1
  274. package/dist/cli/lisa-test-run-process-group.d.ts +0 -30
  275. package/dist/cli/lisa-test-run-process-group.d.ts.map +0 -1
  276. package/dist/cli/lisa-test-run-process-group.js +0 -140
  277. package/dist/cli/lisa-test-run-process-group.js.map +0 -1
  278. package/dist/cli/lisa-test-run-reaper.d.ts +0 -3
  279. package/dist/cli/lisa-test-run-reaper.d.ts.map +0 -1
  280. package/dist/cli/lisa-test-run-reaper.js +0 -195
  281. package/dist/cli/lisa-test-run-reaper.js.map +0 -1
  282. package/dist/cli/lisa-test-run-runtime.d.ts +0 -46
  283. package/dist/cli/lisa-test-run-runtime.d.ts.map +0 -1
  284. package/dist/cli/lisa-test-run-runtime.js +0 -123
  285. package/dist/cli/lisa-test-run-runtime.js.map +0 -1
  286. package/dist/cli/lisa-test-run-supervisor.d.ts +0 -13
  287. package/dist/cli/lisa-test-run-supervisor.d.ts.map +0 -1
  288. package/dist/cli/lisa-test-run-supervisor.js +0 -265
  289. package/dist/cli/lisa-test-run-supervisor.js.map +0 -1
  290. package/dist/configs/vitest/fleet-admission-global-setup.d.ts +0 -34
  291. package/dist/configs/vitest/fleet-admission-global-setup.d.ts.map +0 -1
  292. package/dist/configs/vitest/fleet-admission-global-setup.js +0 -123
  293. package/dist/configs/vitest/fleet-admission-global-setup.js.map +0 -1
  294. package/dist/configs/vitest/fleet-admission.d.ts +0 -129
  295. package/dist/configs/vitest/fleet-admission.d.ts.map +0 -1
  296. package/dist/configs/vitest/fleet-admission.js +0 -239
  297. package/dist/configs/vitest/fleet-admission.js.map +0 -1
  298. package/dist/configs/vitest/scratch-authority.d.ts +0 -25
  299. package/dist/configs/vitest/scratch-authority.d.ts.map +0 -1
  300. package/dist/configs/vitest/scratch-authority.js +0 -107
  301. package/dist/configs/vitest/scratch-authority.js.map +0 -1
  302. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts +0 -5
  303. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts.map +0 -1
  304. package/dist/configs/vitest/scratch-bound-cleanup-programs.js +0 -219
  305. package/dist/configs/vitest/scratch-bound-cleanup-programs.js.map +0 -1
  306. package/dist/configs/vitest/scratch-bound-cleanup.d.ts +0 -28
  307. package/dist/configs/vitest/scratch-bound-cleanup.d.ts.map +0 -1
  308. package/dist/configs/vitest/scratch-bound-cleanup.js +0 -155
  309. package/dist/configs/vitest/scratch-bound-cleanup.js.map +0 -1
  310. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts +0 -17
  311. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts.map +0 -1
  312. package/dist/configs/vitest/scratch-bound-root-cleanup.js +0 -149
  313. package/dist/configs/vitest/scratch-bound-root-cleanup.js.map +0 -1
  314. package/dist/configs/vitest/scratch-global-setup.d.ts +0 -258
  315. package/dist/configs/vitest/scratch-global-setup.d.ts.map +0 -1
  316. package/dist/configs/vitest/scratch-global-setup.js +0 -505
  317. package/dist/configs/vitest/scratch-global-setup.js.map +0 -1
  318. package/dist/configs/vitest/scratch-leak-setup.d.ts +0 -2
  319. package/dist/configs/vitest/scratch-leak-setup.d.ts.map +0 -1
  320. package/dist/configs/vitest/scratch-leak-setup.js +0 -108
  321. package/dist/configs/vitest/scratch-leak-setup.js.map +0 -1
  322. package/dist/configs/vitest/scratch-namespace-authority.d.ts +0 -80
  323. package/dist/configs/vitest/scratch-namespace-authority.d.ts.map +0 -1
  324. package/dist/configs/vitest/scratch-namespace-authority.js +0 -291
  325. package/dist/configs/vitest/scratch-namespace-authority.js.map +0 -1
  326. package/dist/configs/vitest/scratch-owner.d.ts +0 -131
  327. package/dist/configs/vitest/scratch-owner.d.ts.map +0 -1
  328. package/dist/configs/vitest/scratch-owner.js +0 -297
  329. package/dist/configs/vitest/scratch-owner.js.map +0 -1
  330. package/dist/configs/vitest/scratch-route-profile.d.ts +0 -46
  331. package/dist/configs/vitest/scratch-route-profile.d.ts.map +0 -1
  332. package/dist/configs/vitest/scratch-route-profile.js +0 -233
  333. package/dist/configs/vitest/scratch-route-profile.js.map +0 -1
  334. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts +0 -33
  335. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts.map +0 -1
  336. package/dist/configs/vitest/scratch-run-root-compatibility.js +0 -137
  337. package/dist/configs/vitest/scratch-run-root-compatibility.js.map +0 -1
  338. package/dist/configs/vitest/scratch-run-root-intent.d.ts +0 -66
  339. package/dist/configs/vitest/scratch-run-root-intent.d.ts.map +0 -1
  340. package/dist/configs/vitest/scratch-run-root-intent.js +0 -183
  341. package/dist/configs/vitest/scratch-run-root-intent.js.map +0 -1
  342. package/dist/configs/vitest/scratch-setup.d.ts +0 -46
  343. package/dist/configs/vitest/scratch-setup.d.ts.map +0 -1
  344. package/dist/configs/vitest/scratch-setup.js +0 -226
  345. package/dist/configs/vitest/scratch-setup.js.map +0 -1
  346. package/dist/configs/vitest/scratch-supervision-intent.d.ts +0 -8
  347. package/dist/configs/vitest/scratch-supervision-intent.d.ts.map +0 -1
  348. package/dist/configs/vitest/scratch-supervision-intent.js +0 -125
  349. package/dist/configs/vitest/scratch-supervision-intent.js.map +0 -1
  350. package/dist/configs/vitest/scratch-supervision-protocol.d.ts +0 -12
  351. package/dist/configs/vitest/scratch-supervision-protocol.d.ts.map +0 -1
  352. package/dist/configs/vitest/scratch-supervision-protocol.js +0 -230
  353. package/dist/configs/vitest/scratch-supervision-protocol.js.map +0 -1
  354. package/dist/configs/vitest/scratch-supervision.d.ts +0 -69
  355. package/dist/configs/vitest/scratch-supervision.d.ts.map +0 -1
  356. package/dist/configs/vitest/scratch-supervision.js +0 -244
  357. package/dist/configs/vitest/scratch-supervision.js.map +0 -1
  358. package/dist/configs/vitest/scratch-sweep.d.ts +0 -66
  359. package/dist/configs/vitest/scratch-sweep.d.ts.map +0 -1
  360. package/dist/configs/vitest/scratch-sweep.js +0 -82
  361. package/dist/configs/vitest/scratch-sweep.js.map +0 -1
  362. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts +0 -48
  363. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts.map +0 -1
  364. package/dist/configs/vitest/scratch-tmpdir-trust.js +0 -194
  365. package/dist/configs/vitest/scratch-tmpdir-trust.js.map +0 -1
  366. package/dist/configs/vitest/scratch.d.ts +0 -19
  367. package/dist/configs/vitest/scratch.d.ts.map +0 -1
  368. package/dist/configs/vitest/scratch.js +0 -34
  369. package/dist/configs/vitest/scratch.js.map +0 -1
  370. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts +0 -86
  371. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts.map +0 -1
  372. package/dist/configs/vitest/synthesis-scratch-reclaim.js +0 -226
  373. package/dist/configs/vitest/synthesis-scratch-reclaim.js.map +0 -1
@@ -0,0 +1,566 @@
1
+ #!/usr/bin/env node
2
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
3
+ // Do not edit directly — durable changes belong upstream in Lisa.
4
+
5
+ /**
6
+ * Run a test command at push, narrowed to the tests the change can affect
7
+ * (CodySwannGT/lisa#4600). The decisions are in `lib/affected-tests.mjs`; this
8
+ * file gathers their inputs (git, `.lisa.config.json`, the access map) and
9
+ * runs the command.
10
+ *
11
+ * Usage:
12
+ * node scripts/lisa-affected-tests.mjs [--fetch <script>] -- <full test command…>
13
+ *
14
+ * The command after `--` is the FULL command, exactly as the push gate ran it
15
+ * before. With `pushGate.affectedTests` off it runs unchanged and this prints
16
+ * nothing. With it on, the command runs unchanged whenever a full-suite reason
17
+ * holds (the reason is printed), or with its `vitest run` rewritten to
18
+ * `vitest related --run <changed files> <map-selected tests>` otherwise.
19
+ *
20
+ * `--fetch <script>` names the script that downloads the access map
21
+ * (`--base <sha> --out <dir>`, exit 1 when there is none). Without it, or when
22
+ * it fails or takes too long, a map already on disk is used if it is still
23
+ * valid for this branch; otherwise the full suite runs.
24
+ * @module lisa-affected-tests
25
+ */
26
+ import { spawnSync } from "node:child_process";
27
+ import {
28
+ existsSync,
29
+ mkdirSync,
30
+ mkdtempSync,
31
+ readFileSync,
32
+ realpathSync,
33
+ rmSync,
34
+ writeFileSync,
35
+ } from "node:fs";
36
+ import { tmpdir } from "node:os";
37
+ import { join } from "node:path";
38
+
39
+ import {
40
+ DEFAULT_MAX_AGE_DAYS,
41
+ MAX_AGE_ENV,
42
+ PARTIAL_COVERAGE_SKIP_REASON,
43
+ SELECTION_REPORT_ENV,
44
+ affectedTestsSettings,
45
+ changedFileCoverage,
46
+ coverageDeclaredAtPush,
47
+ coverageEscalationLines,
48
+ excludedBy,
49
+ explainSelection,
50
+ fullSuiteEscalation,
51
+ measuresCoverage,
52
+ narrowable,
53
+ partialArgv,
54
+ recordedTriggers,
55
+ selectAffectedTests,
56
+ staleMapReason,
57
+ } from "./lib/affected-tests.mjs";
58
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
59
+ import { withPushGateDefaults } from "./lib/push-gate-defaults.mjs";
60
+
61
+ /** Where the map lives, relative to the repository root (gitignored). */
62
+ export const MAP_DIR = ".lisa/test-access-map";
63
+
64
+ /** Who speaks in this selector's lines. */
65
+ const SUBJECT = "affected tests";
66
+
67
+ /** The coverage mode that holds each changed file to the floor. */
68
+ const CHANGED_FILES = "changed-files";
69
+
70
+ /** How long a failed download is remembered before it is tried again. */
71
+ const MISS_TTL_MS = 15 * 60_000;
72
+
73
+ /** How long a map download may take before the push stops waiting for it. */
74
+ const FETCH_TIMEOUT_MS = 60_000;
75
+
76
+ /** Git's location variables, which a hook exports to its children. */
77
+ const GIT_LOCATION_ENV = new Set([
78
+ "GIT_DIR",
79
+ "GIT_WORK_TREE",
80
+ "GIT_INDEX_FILE",
81
+ "GIT_PREFIX",
82
+ ]);
83
+
84
+ /**
85
+ * Narrow only when the push gate runner asked for it.
86
+ *
87
+ * A host's shared `test:cov:unit` script carries the selector
88
+ * (CodySwannGT/lisa#4611), and a developer who runs that script by hand
89
+ * expects every test. With this flag the command runs unchanged unless the
90
+ * gate runner set `LISA_SELECTION_REPORT`, which it does only at push (and
91
+ * for `lisa check`, which runs the push gates ahead of the push).
92
+ */
93
+ export const PUSH_ONLY_FLAG = "--push-only";
94
+
95
+ /**
96
+ * Split `[--fetch <script>] [--push-only] -- <command…>`.
97
+ * @param {ReadonlyArray<string>} argv Arguments after the script.
98
+ * @returns {{fetch: string|undefined, pushOnly: boolean, command: string[]}} Parsed options.
99
+ */
100
+ export function parseArgs(argv) {
101
+ const separator = argv.indexOf("--");
102
+ const own = separator === -1 ? [] : argv.slice(0, separator);
103
+ const command = separator === -1 ? [] : argv.slice(separator + 1);
104
+ const at = own.indexOf("--fetch");
105
+ return {
106
+ fetch: at === -1 ? undefined : own[at + 1],
107
+ pushOnly: own.includes(PUSH_ONLY_FLAG),
108
+ command,
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Run git in `root`, without the location variables a hook exports.
114
+ * @param {string} root Repository root.
115
+ * @param {string[]} args Git arguments.
116
+ * @returns {string|null} Trimmed stdout, or null when git fails.
117
+ */
118
+ function git(root, args) {
119
+ const env = Object.fromEntries(
120
+ Object.entries(process.env).filter(([key]) => !GIT_LOCATION_ENV.has(key))
121
+ );
122
+ const child = spawnSync("git", args, {
123
+ cwd: root,
124
+ env,
125
+ encoding: "utf8",
126
+ maxBuffer: 64 * 1024 * 1024,
127
+ });
128
+ return child.status === 0 ? child.stdout.trim() : null;
129
+ }
130
+
131
+ /**
132
+ * Parse a JSON file, or undefined when it is missing or unreadable.
133
+ * @param {string} file Path.
134
+ * @returns {any} Parsed value.
135
+ */
136
+ function readJson(file) {
137
+ try {
138
+ return JSON.parse(readFileSync(file, "utf8"));
139
+ } catch {
140
+ return undefined;
141
+ }
142
+ }
143
+
144
+ /**
145
+ * The commit this branch left the default branch at.
146
+ * @param {string} root Repository root.
147
+ * @param {NodeJS.ProcessEnv} env Environment (`LISA_AFFECTED_BASE_REF` overrides).
148
+ * @returns {{sha: string, ref: string}|null} The merge-base, or null.
149
+ */
150
+ function mergeBaseOf(root, env) {
151
+ const symbolic = git(root, [
152
+ "symbolic-ref",
153
+ "--quiet",
154
+ "refs/remotes/origin/HEAD",
155
+ ]);
156
+ const ref =
157
+ env.LISA_AFFECTED_BASE_REF ||
158
+ (symbolic ? symbolic.replace(/^refs\/remotes\//, "") : "origin/main");
159
+ const sha = git(root, ["merge-base", "HEAD", ref]);
160
+ return sha ? { sha, ref } : null;
161
+ }
162
+
163
+ /**
164
+ * Files that differ between the merge-base and the working tree.
165
+ * @param {string} root Repository root.
166
+ * @param {string} base Merge-base.
167
+ * @returns {Array<{path: string, status: "added"|"modified"|"deleted"}>|null} Changes, or null.
168
+ */
169
+ function changedFiles(root, base) {
170
+ const tracked = git(root, ["diff", "--name-status", "--no-renames", base]);
171
+ const untracked = git(root, ["ls-files", "--others", "--exclude-standard"]);
172
+ if (tracked === null || untracked === null) return null;
173
+ const status = letter =>
174
+ letter === "A" ? "added" : letter === "D" ? "deleted" : "modified";
175
+ const entries = tracked
176
+ .split("\n")
177
+ .filter(Boolean)
178
+ .map(line => {
179
+ const [letter, ...rest] = line.split("\t");
180
+ return { path: rest.join("\t"), status: status(letter[0]) };
181
+ });
182
+ const seen = new Set(entries.map(entry => entry.path));
183
+ const added = untracked
184
+ .split("\n")
185
+ .filter(file => file && !seen.has(file))
186
+ .map(file => ({ path: file, status: "added" }));
187
+ return [...entries, ...added];
188
+ }
189
+
190
+ /**
191
+ * Make sure a map for `base` is on disk, downloading it when needed.
192
+ *
193
+ * A map already downloaded for this exact base is reused without asking the
194
+ * network. A download that found nothing is remembered for a few minutes so
195
+ * a run of pushes does not pay for it each time.
196
+ * @param {object} input Inputs.
197
+ * @param {string} input.root Repository root.
198
+ * @param {string} input.base Merge-base.
199
+ * @param {string|undefined} input.fetch The download script.
200
+ * @param {(line: string) => void} input.out Output.
201
+ * @param {() => Date} input.now Clock.
202
+ * @returns {void}
203
+ */
204
+ function ensureMap({ root, base, fetch, out, now }) {
205
+ const dir = join(root, MAP_DIR);
206
+ if (readJson(join(dir, "meta.json"))?.requestedBase === base) return;
207
+ if (!fetch || !existsSync(join(root, fetch))) return;
208
+ const missFile = join(dir, "miss.json");
209
+ const miss = readJson(missFile);
210
+ if (
211
+ miss?.requestedBase === base &&
212
+ now().getTime() - Date.parse(miss.at) < MISS_TTL_MS
213
+ ) {
214
+ return;
215
+ }
216
+ out(
217
+ `🎯 affected tests: downloading the test access map for ${base.slice(0, 12)}…`
218
+ );
219
+ const child = spawnSync(
220
+ process.execPath,
221
+ [join(root, fetch), "--base", base, "--out", dir],
222
+ { cwd: root, encoding: "utf8", timeout: FETCH_TIMEOUT_MS }
223
+ );
224
+ if (child.status === 0) return;
225
+ const why =
226
+ child.error?.code === "ETIMEDOUT"
227
+ ? `it took longer than ${FETCH_TIMEOUT_MS / 1000}s`
228
+ : (child.stderr || "").trim().split("\n").at(-1) || "it failed";
229
+ out(` No new map: ${why}.`);
230
+ mkdirSync(dir, { recursive: true });
231
+ writeFileSync(
232
+ missFile,
233
+ `${JSON.stringify({ requestedBase: base, at: now().toISOString() })}\n`
234
+ );
235
+ }
236
+
237
+ /**
238
+ * Read the map, or say why it cannot be used.
239
+ * @param {object} input Inputs.
240
+ * @param {string} input.root Repository root.
241
+ * @param {string} input.base Merge-base.
242
+ * @param {NodeJS.ProcessEnv} input.env Environment.
243
+ * @param {() => Date} input.now Clock.
244
+ * @returns {{map: Record<string, string[]>, meta: Record<string, any>}|{problem: string}} The map.
245
+ */
246
+ function loadMap({ root, base, env, now }) {
247
+ const dir = join(root, MAP_DIR);
248
+ const meta = readJson(join(dir, "meta.json"));
249
+ if (meta === undefined) {
250
+ return {
251
+ problem:
252
+ "missing map: no test access map is available for this branch's base",
253
+ };
254
+ }
255
+ const configured = Number(env[MAX_AGE_ENV]);
256
+ const maxAgeDays =
257
+ env[MAX_AGE_ENV] !== undefined &&
258
+ env[MAX_AGE_ENV] !== "" &&
259
+ Number.isFinite(configured)
260
+ ? configured
261
+ : DEFAULT_MAX_AGE_DAYS;
262
+ const stale = staleMapReason({
263
+ meta,
264
+ mergeBase: base,
265
+ isAncestor: (a, b) =>
266
+ git(root, ["merge-base", "--is-ancestor", a, b]) !== null,
267
+ now: now(),
268
+ maxAgeDays,
269
+ });
270
+ if (stale) return { problem: stale };
271
+ const map = readJson(join(dir, "map.json"));
272
+ if (!map || typeof map !== "object" || Array.isArray(map)) {
273
+ return {
274
+ problem: "missing map: the downloaded map file could not be read",
275
+ };
276
+ }
277
+ return { map, meta };
278
+ }
279
+
280
+ /**
281
+ * The project's coverage floors, from `vitest.thresholds.json`'s `global`.
282
+ * @param {string} root Repository root.
283
+ * @returns {Record<string, number>|null} Floors, or null when there are none.
284
+ */
285
+ function thresholdsOf(root) {
286
+ const floors = readJson(join(root, "vitest.thresholds.json"))?.global;
287
+ return floors && typeof floors === "object" ? floors : null;
288
+ }
289
+
290
+ /**
291
+ * Decide what to run.
292
+ * @param {object} input Inputs.
293
+ * @param {string} input.root Repository root.
294
+ * @param {string[]} input.command The full command.
295
+ * @param {string|undefined} input.fetch The download script.
296
+ * @param {Record<string, any>} input.config Parsed `.lisa.config.json`.
297
+ * @param {"full"|"changed-files"|"skip"} input.mode Coverage mode.
298
+ * @param {NodeJS.ProcessEnv} input.env Environment.
299
+ * @param {(line: string) => void} input.out Output.
300
+ * @param {() => Date} input.now Clock.
301
+ * @returns {{selection: import("./lib/affected-tests.mjs").Selection, coverage: "measured"|"changed-files"|"skip"|"none"}} The plan.
302
+ */
303
+ export function plan({ root, command, fetch, config, mode, env, out, now }) {
304
+ const coverageWanted = measuresCoverage(command);
305
+ const fullRun = reason => ({
306
+ selection: { kind: "full", reason, tests: [], related: [], unread: [] },
307
+ coverage: coverageWanted ? "measured" : "none",
308
+ });
309
+ if (env.CI || env.GITHUB_ACTIONS) {
310
+ return fullRun("this is a CI run, and CI always runs every test");
311
+ }
312
+ if (!narrowable(command)) {
313
+ return fullRun(
314
+ "the test command is not a `vitest run`, so it cannot be narrowed"
315
+ );
316
+ }
317
+ const declared = coverageDeclaredAtPush(config.gates) && coverageWanted;
318
+ if (declared && mode === "full") {
319
+ return fullRun(
320
+ 'coverage-adequacy is checked at push and needs every test, because pushGate.affectedCoverage is "full"'
321
+ );
322
+ }
323
+ if (declared && mode === CHANGED_FILES && !thresholdsOf(root)) {
324
+ return fullRun(
325
+ "there is no vitest.thresholds.json to hold the changed files to"
326
+ );
327
+ }
328
+ const base = mergeBaseOf(root, env);
329
+ if (!base) {
330
+ return fullRun("could not find where this branch left the default branch");
331
+ }
332
+ const changed = changedFiles(root, base.sha);
333
+ if (!changed) return fullRun("could not list the changed files");
334
+ if (changed.length === 0) {
335
+ return fullRun(
336
+ `nothing differs from ${base.ref}, so there is no change to narrow to`
337
+ );
338
+ }
339
+ ensureMap({ root, base: base.sha, fetch, out, now });
340
+ const loaded = loadMap({ root, base: base.sha, env, now });
341
+ if ("problem" in loaded) return fullRun(loaded.problem);
342
+ const atMapBase = new Set(
343
+ (git(root, ["ls-tree", "-r", "--name-only", loaded.meta.baseSha]) ?? "")
344
+ .split("\n")
345
+ .filter(Boolean)
346
+ );
347
+ const selection = selectAffectedTests({
348
+ changed: changed.map(entry => ({
349
+ ...entry,
350
+ existedAtMapBase: atMapBase.has(entry.path),
351
+ })),
352
+ map: loaded.map,
353
+ excluded: excludedBy(command),
354
+ exists: file => existsSync(join(root, file)),
355
+ testFiles: (
356
+ git(root, ["ls-files", "--cached", "--others", "--exclude-standard"]) ??
357
+ ""
358
+ )
359
+ .split("\n")
360
+ .filter(Boolean),
361
+ triggers: recordedTriggers(loaded.meta),
362
+ });
363
+ if (selection.kind === "full") {
364
+ return { selection, coverage: coverageWanted ? "measured" : "none" };
365
+ }
366
+ if (!declared) return { selection, coverage: "none" };
367
+ if (
368
+ mode === CHANGED_FILES &&
369
+ selection.tests.length === 0 &&
370
+ selection.related.length > 0
371
+ ) {
372
+ return fullRun(
373
+ "no test reaches the changed source files, so their coverage can only be measured by the full suite"
374
+ );
375
+ }
376
+ return { selection, coverage: mode };
377
+ }
378
+
379
+ /** What each coverage outcome means, for the explanation. */
380
+ const COVERAGE_NOTE = Object.freeze({
381
+ measured: "measured over the full suite, as before",
382
+ none: "not measured at push (coverage-adequacy is not checked at push)",
383
+ [CHANGED_FILES]:
384
+ "each changed source file is held to vitest.thresholds.json on its own; one below it sends the push to the full suite",
385
+ skip: `not measured; coverage-adequacy reports SKIPPED (${PARTIAL_COVERAGE_SKIP_REASON})`,
386
+ });
387
+
388
+ /**
389
+ * Run a command with inherited output and return its exit code.
390
+ * @param {string[]} argv Command.
391
+ * @param {string} cwd Working directory.
392
+ * @returns {number} Exit code (1 for a signal or a spawn failure).
393
+ */
394
+ function run(argv, cwd) {
395
+ const child = spawnSync(argv[0], argv.slice(1), { cwd, stdio: "inherit" });
396
+ return typeof child.status === "number" ? child.status : 1;
397
+ }
398
+
399
+ /**
400
+ * The CLI.
401
+ * @param {string[]} argv Arguments after the script.
402
+ * @param {object} [deps] Effects, injectable for tests.
403
+ * @param {NodeJS.ProcessEnv} [deps.env] Environment.
404
+ * @param {string} [deps.cwd] Working directory.
405
+ * @param {(line: string) => void} [deps.out] Output.
406
+ * @param {() => Date} [deps.now] Clock.
407
+ * @returns {number} Exit code.
408
+ */
409
+ export function main(argv, deps = {}) {
410
+ const env = deps.env ?? process.env;
411
+ const out = deps.out ?? (line => console.log(line));
412
+ const now = deps.now ?? (() => new Date());
413
+ const { fetch, pushOnly, command } = parseArgs(argv);
414
+ if (command.length === 0) {
415
+ console.error(
416
+ "usage: lisa-affected-tests.mjs [--fetch <script>] [--push-only] -- <test command…>"
417
+ );
418
+ return 2;
419
+ }
420
+ const cwd = deps.cwd ?? process.cwd();
421
+ if (pushOnly && !env[SELECTION_REPORT_ENV]) return run(command, cwd);
422
+ const root = git(cwd, ["rev-parse", "--show-toplevel"]) ?? cwd;
423
+ // The stack's defaults under the project's own keys (CodySwannGT/lisa#4611).
424
+ const config = withPushGateDefaults(
425
+ readJson(join(root, ".lisa.config.json")) ?? {},
426
+ root
427
+ );
428
+ let settings;
429
+ try {
430
+ settings = affectedTestsSettings(config);
431
+ } catch (error) {
432
+ console.error(
433
+ `🚫 affected tests: ${error.message} Fix pushGate in .lisa.config.json. Nothing ran.`
434
+ );
435
+ return 2;
436
+ }
437
+ if (!settings.enabled) return run(command, cwd);
438
+
439
+ const chosen = plan({
440
+ root,
441
+ command,
442
+ fetch,
443
+ config,
444
+ mode: settings.coverage,
445
+ env,
446
+ out,
447
+ now,
448
+ });
449
+ const { selection, coverage } = chosen;
450
+ if (env[SELECTION_REPORT_ENV]) {
451
+ try {
452
+ writeFileSync(
453
+ env[SELECTION_REPORT_ENV],
454
+ `${JSON.stringify({ selection: selection.kind, reason: selection.reason ?? null, coverage, tests: selection.tests.length })}\n`
455
+ );
456
+ } catch {
457
+ // Without the report the runner reads nothing and reports as before.
458
+ }
459
+ }
460
+ for (const line of explainSelection(selection, COVERAGE_NOTE[coverage]))
461
+ out(line);
462
+ if (selection.kind === "full") return run(command, cwd);
463
+ // Only a selection with neither a test nor a file for Vitest's import graph
464
+ // has nothing to run. With changed files left, `vitest related` still runs:
465
+ // the map may miss an importer that the import graph finds.
466
+ if (selection.tests.length === 0 && selection.related.length === 0) {
467
+ out(
468
+ " No unit test can reach the changed files, so there is nothing to run."
469
+ );
470
+ return 0;
471
+ }
472
+
473
+ const coverageDir =
474
+ coverage === CHANGED_FILES
475
+ ? mkdtempSync(join(tmpdir(), "lisa-affected-coverage-"))
476
+ : undefined;
477
+ let escalation;
478
+ try {
479
+ const code = run(
480
+ partialArgv({
481
+ argv: command,
482
+ selection,
483
+ coverage: coverage === CHANGED_FILES ? "on" : "off",
484
+ coverageDir,
485
+ }),
486
+ cwd
487
+ );
488
+ if (code !== 0 || coverage !== CHANGED_FILES) return code;
489
+ escalation = checkChangedFiles({ root, coverageDir, selection, out });
490
+ } finally {
491
+ if (coverageDir) rmSync(coverageDir, { recursive: true, force: true });
492
+ }
493
+ if (escalation.length === 0) return 0;
494
+ return escalate({ lines: escalation, command, cwd, env, out });
495
+ }
496
+
497
+ /**
498
+ * Run the full command, as `full` mode does, after a partial run could not
499
+ * clear the changed files (CodySwannGT/lisa#4600: a push is never stricter
500
+ * than whole-repo coverage). Its verdict is the push's, and the report says
501
+ * a full run produced it, so the gate runner may remember the pass.
502
+ * @param {object} input Inputs.
503
+ * @param {string[]} input.lines Why, one line per reason.
504
+ * @param {string[]} input.command The full command.
505
+ * @param {string} input.cwd Working directory.
506
+ * @param {NodeJS.ProcessEnv} input.env Environment.
507
+ * @param {(line: string) => void} input.out Output.
508
+ * @returns {number} The full run's exit code.
509
+ */
510
+ function escalate({ lines, command, cwd, env, out }) {
511
+ for (const line of lines) out(line);
512
+ if (env[SELECTION_REPORT_ENV]) {
513
+ try {
514
+ writeFileSync(
515
+ env[SELECTION_REPORT_ENV],
516
+ `${JSON.stringify({ selection: "full", reason: lines.join(" "), coverage: "measured", tests: 0, escalated: true })}\n`
517
+ );
518
+ } catch {
519
+ // Without the report the runner reads nothing and reports as before.
520
+ }
521
+ }
522
+ return run(command, cwd);
523
+ }
524
+
525
+ /**
526
+ * Hold each changed source file to the thresholds after a coverage-on run.
527
+ * @param {object} input Inputs.
528
+ * @param {string} input.root Repository root.
529
+ * @param {string} input.coverageDir Where the run wrote `coverage-summary.json`.
530
+ * @param {import("./lib/affected-tests.mjs").Selection} input.selection The selection.
531
+ * @param {(line: string) => void} input.out Output.
532
+ * @returns {string[]} Escalation lines; empty when every changed file meets its floor.
533
+ */
534
+ function checkChangedFiles({ root, coverageDir, selection, out }) {
535
+ const summary = readJson(join(coverageDir, "coverage-summary.json"));
536
+ if (!summary) {
537
+ return [
538
+ fullSuiteEscalation(SUBJECT, "the partial run wrote no coverage summary"),
539
+ ];
540
+ }
541
+ const verdict = changedFileCoverage({
542
+ summary,
543
+ root,
544
+ realRoot: realpathSync(root),
545
+ files: selection.related,
546
+ thresholds: thresholdsOf(root) ?? {},
547
+ });
548
+ if (verdict.shortfalls.length > 0) {
549
+ return coverageEscalationLines({
550
+ subject: SUBJECT,
551
+ files: selection.related,
552
+ shortfalls: verdict.shortfalls,
553
+ });
554
+ }
555
+ const outside = verdict.unmeasured.length
556
+ ? `; ${verdict.unmeasured.length} are outside coverage`
557
+ : "";
558
+ out(
559
+ `✅ affected tests: ${verdict.measured.length} changed source file(s) meet the coverage floor${outside}`
560
+ );
561
+ return [];
562
+ }
563
+
564
+ if (invokedAsScript(import.meta.url)) {
565
+ process.exitCode = main(process.argv.slice(2));
566
+ }
@@ -74,6 +74,7 @@ import { createRequire } from "node:module";
74
74
  import { dirname, isAbsolute, join, parse, relative } from "node:path";
75
75
  import { fileURLToPath } from "node:url";
76
76
 
77
+ import { CACHE_FIELD } from "./lib/gate-pass-cache.mjs";
77
78
  import { invokedAsScript } from "./lib/invoked-as-script.mjs";
78
79
 
79
80
  /**
@@ -3261,6 +3262,9 @@ export const KNOWN_CONFIG_KEYS = Object.freeze([
3261
3262
  "health",
3262
3263
  "verification",
3263
3264
  "thresholdRatchet",
3265
+ // `pushGate.cache` switches on the push-gate pass cache; see
3266
+ // `lib/gate-pass-cache.mjs` (CodySwannGT/lisa#4594).
3267
+ "pushGate",
3264
3268
  ]);
3265
3269
 
3266
3270
  /**
@@ -4197,6 +4201,30 @@ function validateFailureShape(id, moment, shape) {
4197
4201
  return problems;
4198
4202
  }
4199
4203
 
4204
+ /**
4205
+ * Validate the per-moment `cache` flag (CodySwannGT/lisa#4594).
4206
+ *
4207
+ * `"cache": false` beside `level` and `run` says this moment's verdict can
4208
+ * depend on something the push-gate pass cache does not key on — the tracker,
4209
+ * live machine state, history beyond the tree — so the gate always runs. It
4210
+ * sits on the MOMENT entry, beside `failure_shape`, for the same reason that
4211
+ * field does: an older Lisa ignores an unknown moment key but refuses an
4212
+ * unknown gate-level one, along with the whole gates block. Only a boolean is
4213
+ * accepted; anything else would silently read as "cacheable".
4214
+ * @param {string} id Gate id.
4215
+ * @param {string} moment Moment key.
4216
+ * @param {*} value The declared value, if any.
4217
+ * @returns {string[]} Problems.
4218
+ */
4219
+ function validateCacheFlag(id, moment, value) {
4220
+ if (value === undefined || typeof value === "boolean") return [];
4221
+ return [
4222
+ `gates."${id}"."${moment}".${CACHE_FIELD} is ${JSON.stringify(value)}; ` +
4223
+ `expected false (this verdict depends on more than the pushed tree, ` +
4224
+ `so it must always run) or true.`,
4225
+ ];
4226
+ }
4227
+
4200
4228
  /**
4201
4229
  * Validate one moment entry on a gate.
4202
4230
  * @param {string} id Gate id.
@@ -4253,6 +4281,7 @@ function validateMoment(id, moment, value, known, interceptor, gateRun) {
4253
4281
  problems.push(
4254
4282
  ...validateFailureShape(id, moment, entry[FAILURE_SHAPE_FIELD])
4255
4283
  );
4284
+ problems.push(...validateCacheFlag(id, moment, entry[CACHE_FIELD]));
4256
4285
  problems.push(...validatePostedBy(id, moment, entry));
4257
4286
  problems.push(...validateCallerChain(id, moment, entry));
4258
4287
  if (!known && !interceptor && !entry.await && !entry.run && !gateRun) {
@@ -255,7 +255,6 @@ export const probe = async (executable, cwd, env) => {
255
255
  env,
256
256
  stdio: "ignore",
257
257
  shell: process.platform === "win32",
258
- timeout: PROBE_TIMEOUT_MS,
259
258
  });
260
259
  } catch (error) {
261
260
  settle({
@@ -267,7 +266,17 @@ export const probe = async (executable, cwd, env) => {
267
266
  return;
268
267
  }
269
268
 
269
+ // The deadline is owned here rather than passed to `spawn` as `timeout`.
270
+ // Node clears that option's timer only on `exit`, and a child that never
271
+ // started never exits, so a refusal stayed alive for the whole deadline
272
+ // after it had already been decided (CodySwannGT/lisa#4616). Clearing on
273
+ // both `exit` and `error` keeps the deadline for a started tool and drops
274
+ // it for one that could not start.
275
+ const deadline = setTimeout(() => child.kill(), PROBE_TIMEOUT_MS);
276
+ child.once("exit", () => clearTimeout(deadline));
277
+
270
278
  child.on("error", error => {
279
+ clearTimeout(deadline);
271
280
  settle({
272
281
  executable,
273
282
  started: false,