@codyswann/lisa 5.4.0 → 5.6.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 (394) 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 +48 -3
  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/github-attestation-provider.mjs +68 -0
  11. package/all/copy-overwrite/scripts/lib/github-attestation-recovery.mjs +25 -10
  12. package/all/copy-overwrite/scripts/lib/github-attestation-verifier.mjs +4 -1
  13. package/all/copy-overwrite/scripts/lib/kill-marks.mjs +1 -2
  14. package/all/copy-overwrite/scripts/lib/lisa-cleanup-sweep-processes.mjs +3 -4
  15. package/all/copy-overwrite/scripts/lib/npm-update-allocate.mjs +1 -6
  16. package/all/copy-overwrite/scripts/lib/npm-update-authorization.mjs +25 -14
  17. package/all/copy-overwrite/scripts/lib/npm-update-cancel-origin.mjs +45 -11
  18. package/all/copy-overwrite/scripts/lib/npm-update-cancellation-proof.mjs +22 -11
  19. package/all/copy-overwrite/scripts/lib/npm-update-cancellation.mjs +29 -17
  20. package/all/copy-overwrite/scripts/lib/npm-update-controller-broker.mjs +1 -1
  21. package/all/copy-overwrite/scripts/lib/npm-update-controller-factory.mjs +19 -1
  22. package/all/copy-overwrite/scripts/lib/npm-update-gate-hooks.mjs +2 -1
  23. package/all/copy-overwrite/scripts/lib/npm-update-gate.mjs +5 -0
  24. package/all/copy-overwrite/scripts/lib/npm-update-gh-requests.mjs +57 -30
  25. package/all/copy-overwrite/scripts/lib/npm-update-helper-inventory.mjs +9 -1
  26. package/all/copy-overwrite/scripts/lib/npm-update-hosted-hook.mjs +1 -1
  27. package/all/copy-overwrite/scripts/lib/npm-update-leaf.mjs +6 -1
  28. package/all/copy-overwrite/scripts/lib/npm-update-policy.mjs +38 -0
  29. package/all/copy-overwrite/scripts/lib/npm-update-publication.mjs +21 -3
  30. package/all/copy-overwrite/scripts/lib/npm-update-publish.mjs +13 -1
  31. package/all/copy-overwrite/scripts/lib/npm-update-recovery.mjs +29 -4
  32. package/all/copy-overwrite/scripts/lib/npm-update-supersession.mjs +21 -7
  33. package/all/copy-overwrite/scripts/lib/npm-update-tool-launcher.mjs +1 -1
  34. package/all/copy-overwrite/scripts/lib/npm-update-tracker-cancel.mjs +139 -0
  35. package/all/copy-overwrite/scripts/lib/npm-update-tracker-jira.mjs +149 -19
  36. package/all/copy-overwrite/scripts/lib/npm-update-tracker-linear.mjs +72 -17
  37. package/all/copy-overwrite/scripts/lib/npm-update-tracker-wire.mjs +102 -12
  38. package/all/copy-overwrite/scripts/lib/npm-update-tracker.mjs +91 -13
  39. package/all/copy-overwrite/scripts/lib/push-admission.mjs +158 -0
  40. package/all/copy-overwrite/scripts/lib/push-gate-defaults.d.mts +34 -0
  41. package/all/copy-overwrite/scripts/lib/push-gate-defaults.mjs +147 -0
  42. package/all/copy-overwrite/scripts/lib/push-timing.mjs +323 -0
  43. package/all/copy-overwrite/scripts/lib/rspec-selection.mjs +672 -0
  44. package/all/copy-overwrite/scripts/lisa-affected-tests.mjs +566 -0
  45. package/all/copy-overwrite/scripts/lisa-automation-provenance.mjs +35 -8
  46. package/all/copy-overwrite/scripts/lisa-gates.mjs +29 -0
  47. package/all/copy-overwrite/scripts/lisa-lint-staged-preflight.mjs +10 -1
  48. package/all/copy-overwrite/scripts/lisa-npm-updater.mjs +8 -5
  49. package/all/copy-overwrite/scripts/lisa-push-timing-report.mjs +153 -0
  50. package/all/copy-overwrite/scripts/lisa-rspec-select.mjs +982 -0
  51. package/all/copy-overwrite/scripts/lisa-run-gates.mjs +231 -6
  52. package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +148 -41
  53. package/all/deletions.json +11 -2
  54. package/cdk/create-only/vitest.config.local.ts +1 -7
  55. package/cdk/package-lisa/package.lisa.json +4 -4
  56. package/dist/cli/admit-cmd.d.ts +21 -0
  57. package/dist/cli/admit-cmd.d.ts.map +1 -0
  58. package/dist/cli/admit-cmd.js +142 -0
  59. package/dist/cli/admit-cmd.js.map +1 -0
  60. package/dist/cli/check-cmd.d.ts +72 -0
  61. package/dist/cli/check-cmd.d.ts.map +1 -0
  62. package/dist/cli/check-cmd.js +316 -0
  63. package/dist/cli/check-cmd.js.map +1 -0
  64. package/dist/cli/index.d.ts.map +1 -1
  65. package/dist/cli/index.js +6 -4
  66. package/dist/cli/index.js.map +1 -1
  67. package/dist/cli/lisa-test-run-admission.d.ts +18 -0
  68. package/dist/cli/lisa-test-run-admission.d.ts.map +1 -0
  69. package/dist/cli/lisa-test-run-admission.js +62 -0
  70. package/dist/cli/lisa-test-run-admission.js.map +1 -0
  71. package/dist/cli/lisa-test-run-payload.d.ts +37 -0
  72. package/dist/cli/lisa-test-run-payload.d.ts.map +1 -0
  73. package/dist/cli/lisa-test-run-payload.js +55 -0
  74. package/dist/cli/lisa-test-run-payload.js.map +1 -0
  75. package/dist/cli/lisa-test-run-shard-files.d.ts +89 -0
  76. package/dist/cli/lisa-test-run-shard-files.d.ts.map +1 -0
  77. package/dist/cli/lisa-test-run-shard-files.js +239 -0
  78. package/dist/cli/lisa-test-run-shard-files.js.map +1 -0
  79. package/dist/cli/lisa-test-run-shard.d.ts +6 -2
  80. package/dist/cli/lisa-test-run-shard.d.ts.map +1 -1
  81. package/dist/cli/lisa-test-run-shard.js +25 -13
  82. package/dist/cli/lisa-test-run-shard.js.map +1 -1
  83. package/dist/cli/lisa-test-run.d.ts +1 -1
  84. package/dist/cli/lisa-test-run.d.ts.map +1 -1
  85. package/dist/cli/lisa-test-run.js +47 -10
  86. package/dist/cli/lisa-test-run.js.map +1 -1
  87. package/dist/cli/update-check-hook.d.ts.map +1 -1
  88. package/dist/cli/update-check-hook.js +3 -0
  89. package/dist/cli/update-check-hook.js.map +1 -1
  90. package/dist/configs/vitest/base.d.ts +58 -135
  91. package/dist/configs/vitest/base.d.ts.map +1 -1
  92. package/dist/configs/vitest/base.js +76 -228
  93. package/dist/configs/vitest/base.js.map +1 -1
  94. package/dist/configs/vitest/cdk.d.ts.map +1 -1
  95. package/dist/configs/vitest/cdk.js +3 -2
  96. package/dist/configs/vitest/cdk.js.map +1 -1
  97. package/dist/configs/vitest/coverage-include-global-setup.d.ts.map +1 -1
  98. package/dist/configs/vitest/coverage-include-global-setup.js +3 -4
  99. package/dist/configs/vitest/coverage-include-global-setup.js.map +1 -1
  100. package/dist/configs/vitest/coverage-reports-directory.d.ts +27 -5
  101. package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
  102. package/dist/configs/vitest/coverage-reports-directory.js +47 -10
  103. package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
  104. package/dist/configs/vitest/harper-fabric.d.ts.map +1 -1
  105. package/dist/configs/vitest/harper-fabric.js +3 -2
  106. package/dist/configs/vitest/harper-fabric.js.map +1 -1
  107. package/dist/configs/vitest/nestjs.d.ts.map +1 -1
  108. package/dist/configs/vitest/nestjs.js +3 -2
  109. package/dist/configs/vitest/nestjs.js.map +1 -1
  110. package/dist/configs/vitest/phaser.d.ts.map +1 -1
  111. package/dist/configs/vitest/phaser.js +3 -2
  112. package/dist/configs/vitest/phaser.js.map +1 -1
  113. package/dist/configs/vitest/refusal-announcement.d.ts +51 -0
  114. package/dist/configs/vitest/refusal-announcement.d.ts.map +1 -0
  115. package/dist/configs/vitest/refusal-announcement.js +97 -0
  116. package/dist/configs/vitest/refusal-announcement.js.map +1 -0
  117. package/dist/configs/vitest/socket-safe-temp-base.d.ts +3 -4
  118. package/dist/configs/vitest/socket-safe-temp-base.d.ts.map +1 -1
  119. package/dist/configs/vitest/socket-safe-temp-base.js +7 -6
  120. package/dist/configs/vitest/socket-safe-temp-base.js.map +1 -1
  121. package/dist/configs/vitest/typescript.d.ts.map +1 -1
  122. package/dist/configs/vitest/typescript.js +3 -2
  123. package/dist/configs/vitest/typescript.js.map +1 -1
  124. package/dist/core/admission-decision.d.ts +110 -0
  125. package/dist/core/admission-decision.d.ts.map +1 -0
  126. package/dist/core/admission-decision.js +91 -0
  127. package/dist/core/admission-decision.js.map +1 -0
  128. package/dist/core/admission-lock.d.ts +69 -0
  129. package/dist/core/admission-lock.d.ts.map +1 -0
  130. package/dist/core/admission-lock.js +278 -0
  131. package/dist/core/admission-lock.js.map +1 -0
  132. package/dist/core/admission-settings.d.ts +69 -0
  133. package/dist/core/admission-settings.d.ts.map +1 -0
  134. package/dist/core/admission-settings.js +204 -0
  135. package/dist/core/admission-settings.js.map +1 -0
  136. package/dist/core/admission-state.d.ts +50 -0
  137. package/dist/core/admission-state.d.ts.map +1 -0
  138. package/dist/core/admission-state.js +168 -0
  139. package/dist/core/admission-state.js.map +1 -0
  140. package/dist/core/admission.d.ts +70 -0
  141. package/dist/core/admission.d.ts.map +1 -0
  142. package/dist/core/admission.js +205 -0
  143. package/dist/core/admission.js.map +1 -0
  144. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  145. package/dist/core/lisa-owned-hash-ledger.js +440 -0
  146. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  147. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  148. package/dist/core/project-config-push-gate.d.ts +66 -0
  149. package/dist/core/project-config-push-gate.d.ts.map +1 -0
  150. package/dist/core/project-config-push-gate.js +82 -0
  151. package/dist/core/project-config-push-gate.js.map +1 -0
  152. package/dist/core/project-config.d.ts +4 -0
  153. package/dist/core/project-config.d.ts.map +1 -1
  154. package/dist/core/project-config.js +14 -9
  155. package/dist/core/project-config.js.map +1 -1
  156. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  157. package/dist/core/upstream-evidence-manifest.js +234 -146
  158. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  159. package/expo/package-lisa/package.lisa.json +2 -2
  160. package/harper-fabric/package-lisa/package.lisa.json +4 -4
  161. package/nestjs/create-only/vitest.config.local.ts +1 -7
  162. package/nestjs/package-lisa/package.lisa.json +4 -4
  163. package/npm-package/package-lisa/package.lisa.json +4 -4
  164. package/package.json +12 -11
  165. package/phaser/package-lisa/package.lisa.json +4 -4
  166. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  167. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  168. package/plugins/lisa/.codex-plugin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  169. package/plugins/lisa/.codex-plugin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  170. package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +1 -1
  171. package/plugins/lisa/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  172. package/plugins/lisa/skills/lisa-git-submit-pr/SKILL.md +1 -1
  173. package/plugins/lisa/skills/lisa-implement/SKILL.md +1 -1
  174. package/plugins/lisa-agy/plugin.json +1 -1
  175. package/plugins/lisa-agy/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  176. package/plugins/lisa-agy/skills/lisa-git-submit-pr/SKILL.md +1 -1
  177. package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +1 -1
  178. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  179. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  180. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  181. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  182. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  183. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  184. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  185. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  186. package/plugins/lisa-copilot/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  187. package/plugins/lisa-copilot/skills/lisa-git-submit-pr/SKILL.md +1 -1
  188. package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +1 -1
  189. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  190. package/plugins/lisa-cursor/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  191. package/plugins/lisa-cursor/skills/lisa-git-submit-pr/SKILL.md +1 -1
  192. package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +1 -1
  193. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  194. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  195. package/plugins/lisa-devin/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  196. package/plugins/lisa-devin/skills/lisa-git-submit-pr/SKILL.md +1 -1
  197. package/plugins/lisa-devin/skills/lisa-implement/SKILL.md +1 -1
  198. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  199. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  200. package/plugins/lisa-expo-agy/plugin.json +1 -1
  201. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  202. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  203. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  204. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  205. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  206. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  207. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  208. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  209. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  210. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  211. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  212. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  213. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  214. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  215. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  216. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  217. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  218. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  219. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  220. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  221. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  222. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  223. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  224. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  225. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  226. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  227. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  228. package/plugins/lisa-rails-agy/plugin.json +1 -1
  229. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  230. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  231. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  232. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  233. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  234. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  235. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  236. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  237. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  238. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  239. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  240. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  241. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  242. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  243. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  244. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  245. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  246. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  247. package/plugins/src/base/skills/lisa-drive-pr-to-merge/SKILL.md +16 -3
  248. package/plugins/src/base/skills/lisa-git-submit-pr/SKILL.md +1 -1
  249. package/plugins/src/base/skills/lisa-implement/SKILL.md +1 -1
  250. package/rails/copy-overwrite/Gemfile.lisa +8 -0
  251. package/rails/copy-overwrite/lefthook.yml +25 -11
  252. package/rails/copy-overwrite/scripts/lisa-rails-gates.mjs +686 -0
  253. package/rails/copy-overwrite/scripts/lisa-rspec-shards.mjs +2 -2
  254. package/rails/copy-overwrite/scripts/lisa_crystalball_recorder.rb +239 -0
  255. package/rails/copy-overwrite/scripts/lisa_rspec_partial_coverage.rb +83 -0
  256. package/scripts/build-unless-marked.mjs +83 -0
  257. package/scripts/check-plugins-sync.sh +22 -5
  258. package/scripts/classify-markdown-assertions.mjs +141 -0
  259. package/scripts/integration-shard-build.mjs +143 -0
  260. package/scripts/lib/history-scanner-suites.mjs +19 -0
  261. package/scripts/lib/markdown-assertions/classify.mjs +289 -0
  262. package/scripts/lib/markdown-assertions/context.mjs +53 -0
  263. package/scripts/lib/markdown-assertions/corpus.mjs +222 -0
  264. package/scripts/lib/markdown-assertions/manifest-cull.mjs +86 -0
  265. package/scripts/lib/markdown-assertions/record-setup.mjs +265 -0
  266. package/scripts/lib/markdown-assertions/record.mjs +115 -0
  267. package/scripts/lib/markdown-assertions/record.vitest.config.mjs +24 -0
  268. package/scripts/lib/markdown-assertions/sites.mjs +273 -0
  269. package/scripts/lib/markdown-assertions/test-cull.mjs +768 -0
  270. package/scripts/lib/markdown-assertions/tokens.mjs +158 -0
  271. package/scripts/lib/shell-guard-trace.mjs +6 -0
  272. package/scripts/lib/test-access-map-setup.mjs +40 -0
  273. package/scripts/lib/test-access-map-tracer.mjs +205 -0
  274. package/scripts/lib/test-access-map.d.mts +72 -0
  275. package/scripts/lib/test-access-map.mjs +395 -0
  276. package/scripts/lib/test-timings-reporter.d.mts +17 -0
  277. package/scripts/lib/test-timings-reporter.mjs +99 -0
  278. package/scripts/plan-integration-shards.mjs +300 -0
  279. package/scripts/test-timing-report.d.mts +41 -0
  280. package/scripts/test-timing-report.mjs +361 -0
  281. package/scripts/two-channel-couplings.json +132 -36
  282. package/scripts/verify-npm-advisories-4333.mjs +3 -12
  283. package/typescript/copy-overwrite/.prettierignore +13 -0
  284. package/typescript/create-only/vitest.config.local.ts +1 -7
  285. package/typescript/package-lisa/package.lisa.json +4 -4
  286. package/all/copy-overwrite/scripts/lisa-scratch-run.sh +0 -1078
  287. package/dist/cli/lisa-test-run-bootstrap.d.ts +0 -3
  288. package/dist/cli/lisa-test-run-bootstrap.d.ts.map +0 -1
  289. package/dist/cli/lisa-test-run-bootstrap.js +0 -229
  290. package/dist/cli/lisa-test-run-bootstrap.js.map +0 -1
  291. package/dist/cli/lisa-test-run-ipc.d.ts +0 -49
  292. package/dist/cli/lisa-test-run-ipc.d.ts.map +0 -1
  293. package/dist/cli/lisa-test-run-ipc.js +0 -226
  294. package/dist/cli/lisa-test-run-ipc.js.map +0 -1
  295. package/dist/cli/lisa-test-run-process-group.d.ts +0 -30
  296. package/dist/cli/lisa-test-run-process-group.d.ts.map +0 -1
  297. package/dist/cli/lisa-test-run-process-group.js +0 -140
  298. package/dist/cli/lisa-test-run-process-group.js.map +0 -1
  299. package/dist/cli/lisa-test-run-reaper.d.ts +0 -3
  300. package/dist/cli/lisa-test-run-reaper.d.ts.map +0 -1
  301. package/dist/cli/lisa-test-run-reaper.js +0 -195
  302. package/dist/cli/lisa-test-run-reaper.js.map +0 -1
  303. package/dist/cli/lisa-test-run-runtime.d.ts +0 -46
  304. package/dist/cli/lisa-test-run-runtime.d.ts.map +0 -1
  305. package/dist/cli/lisa-test-run-runtime.js +0 -123
  306. package/dist/cli/lisa-test-run-runtime.js.map +0 -1
  307. package/dist/cli/lisa-test-run-supervisor.d.ts +0 -13
  308. package/dist/cli/lisa-test-run-supervisor.d.ts.map +0 -1
  309. package/dist/cli/lisa-test-run-supervisor.js +0 -265
  310. package/dist/cli/lisa-test-run-supervisor.js.map +0 -1
  311. package/dist/configs/vitest/fleet-admission-global-setup.d.ts +0 -34
  312. package/dist/configs/vitest/fleet-admission-global-setup.d.ts.map +0 -1
  313. package/dist/configs/vitest/fleet-admission-global-setup.js +0 -123
  314. package/dist/configs/vitest/fleet-admission-global-setup.js.map +0 -1
  315. package/dist/configs/vitest/fleet-admission.d.ts +0 -129
  316. package/dist/configs/vitest/fleet-admission.d.ts.map +0 -1
  317. package/dist/configs/vitest/fleet-admission.js +0 -239
  318. package/dist/configs/vitest/fleet-admission.js.map +0 -1
  319. package/dist/configs/vitest/scratch-authority.d.ts +0 -25
  320. package/dist/configs/vitest/scratch-authority.d.ts.map +0 -1
  321. package/dist/configs/vitest/scratch-authority.js +0 -107
  322. package/dist/configs/vitest/scratch-authority.js.map +0 -1
  323. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts +0 -5
  324. package/dist/configs/vitest/scratch-bound-cleanup-programs.d.ts.map +0 -1
  325. package/dist/configs/vitest/scratch-bound-cleanup-programs.js +0 -219
  326. package/dist/configs/vitest/scratch-bound-cleanup-programs.js.map +0 -1
  327. package/dist/configs/vitest/scratch-bound-cleanup.d.ts +0 -28
  328. package/dist/configs/vitest/scratch-bound-cleanup.d.ts.map +0 -1
  329. package/dist/configs/vitest/scratch-bound-cleanup.js +0 -155
  330. package/dist/configs/vitest/scratch-bound-cleanup.js.map +0 -1
  331. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts +0 -17
  332. package/dist/configs/vitest/scratch-bound-root-cleanup.d.ts.map +0 -1
  333. package/dist/configs/vitest/scratch-bound-root-cleanup.js +0 -149
  334. package/dist/configs/vitest/scratch-bound-root-cleanup.js.map +0 -1
  335. package/dist/configs/vitest/scratch-global-setup.d.ts +0 -258
  336. package/dist/configs/vitest/scratch-global-setup.d.ts.map +0 -1
  337. package/dist/configs/vitest/scratch-global-setup.js +0 -505
  338. package/dist/configs/vitest/scratch-global-setup.js.map +0 -1
  339. package/dist/configs/vitest/scratch-leak-setup.d.ts +0 -2
  340. package/dist/configs/vitest/scratch-leak-setup.d.ts.map +0 -1
  341. package/dist/configs/vitest/scratch-leak-setup.js +0 -108
  342. package/dist/configs/vitest/scratch-leak-setup.js.map +0 -1
  343. package/dist/configs/vitest/scratch-namespace-authority.d.ts +0 -80
  344. package/dist/configs/vitest/scratch-namespace-authority.d.ts.map +0 -1
  345. package/dist/configs/vitest/scratch-namespace-authority.js +0 -291
  346. package/dist/configs/vitest/scratch-namespace-authority.js.map +0 -1
  347. package/dist/configs/vitest/scratch-owner.d.ts +0 -131
  348. package/dist/configs/vitest/scratch-owner.d.ts.map +0 -1
  349. package/dist/configs/vitest/scratch-owner.js +0 -297
  350. package/dist/configs/vitest/scratch-owner.js.map +0 -1
  351. package/dist/configs/vitest/scratch-route-profile.d.ts +0 -46
  352. package/dist/configs/vitest/scratch-route-profile.d.ts.map +0 -1
  353. package/dist/configs/vitest/scratch-route-profile.js +0 -233
  354. package/dist/configs/vitest/scratch-route-profile.js.map +0 -1
  355. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts +0 -33
  356. package/dist/configs/vitest/scratch-run-root-compatibility.d.ts.map +0 -1
  357. package/dist/configs/vitest/scratch-run-root-compatibility.js +0 -137
  358. package/dist/configs/vitest/scratch-run-root-compatibility.js.map +0 -1
  359. package/dist/configs/vitest/scratch-run-root-intent.d.ts +0 -66
  360. package/dist/configs/vitest/scratch-run-root-intent.d.ts.map +0 -1
  361. package/dist/configs/vitest/scratch-run-root-intent.js +0 -183
  362. package/dist/configs/vitest/scratch-run-root-intent.js.map +0 -1
  363. package/dist/configs/vitest/scratch-setup.d.ts +0 -46
  364. package/dist/configs/vitest/scratch-setup.d.ts.map +0 -1
  365. package/dist/configs/vitest/scratch-setup.js +0 -226
  366. package/dist/configs/vitest/scratch-setup.js.map +0 -1
  367. package/dist/configs/vitest/scratch-supervision-intent.d.ts +0 -8
  368. package/dist/configs/vitest/scratch-supervision-intent.d.ts.map +0 -1
  369. package/dist/configs/vitest/scratch-supervision-intent.js +0 -125
  370. package/dist/configs/vitest/scratch-supervision-intent.js.map +0 -1
  371. package/dist/configs/vitest/scratch-supervision-protocol.d.ts +0 -12
  372. package/dist/configs/vitest/scratch-supervision-protocol.d.ts.map +0 -1
  373. package/dist/configs/vitest/scratch-supervision-protocol.js +0 -230
  374. package/dist/configs/vitest/scratch-supervision-protocol.js.map +0 -1
  375. package/dist/configs/vitest/scratch-supervision.d.ts +0 -69
  376. package/dist/configs/vitest/scratch-supervision.d.ts.map +0 -1
  377. package/dist/configs/vitest/scratch-supervision.js +0 -244
  378. package/dist/configs/vitest/scratch-supervision.js.map +0 -1
  379. package/dist/configs/vitest/scratch-sweep.d.ts +0 -66
  380. package/dist/configs/vitest/scratch-sweep.d.ts.map +0 -1
  381. package/dist/configs/vitest/scratch-sweep.js +0 -82
  382. package/dist/configs/vitest/scratch-sweep.js.map +0 -1
  383. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts +0 -48
  384. package/dist/configs/vitest/scratch-tmpdir-trust.d.ts.map +0 -1
  385. package/dist/configs/vitest/scratch-tmpdir-trust.js +0 -194
  386. package/dist/configs/vitest/scratch-tmpdir-trust.js.map +0 -1
  387. package/dist/configs/vitest/scratch.d.ts +0 -19
  388. package/dist/configs/vitest/scratch.d.ts.map +0 -1
  389. package/dist/configs/vitest/scratch.js +0 -34
  390. package/dist/configs/vitest/scratch.js.map +0 -1
  391. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts +0 -86
  392. package/dist/configs/vitest/synthesis-scratch-reclaim.d.ts.map +0 -1
  393. package/dist/configs/vitest/synthesis-scratch-reclaim.js +0 -226
  394. package/dist/configs/vitest/synthesis-scratch-reclaim.js.map +0 -1
@@ -10,14 +10,11 @@
10
10
  * @module npm-updater
11
11
  */
12
12
  import { required, operatorRefusal } from "./npm-update-invariants.mjs";
13
+ import { backlinkBody } from "../lisa-work-item.mjs";
13
14
  import { verifyCurrentRun } from "./github-attestation-provider.mjs";
14
15
  import { JiraTracker } from "./npm-update-tracker-jira.mjs";
15
16
  import { LinearTracker } from "./npm-update-tracker-linear.mjs";
16
17
 
17
- /** The operator-approved sentence for every Jira/Linear phase that is not supported yet. */
18
- export const FOLLOWUP_SENTENCE =
19
- "The npm updater can file and claim Jira and Linear work items, but it cannot yet check their claims, publish the pull request or cancel them. That support is tracked in CodySwannGT/lisa#4873. Projects that track work in GitHub are fully supported today.";
20
-
21
18
  /** Today's GitHub calls, unchanged in endpoint, method, body and order. */
22
19
  export function githubTracker(api, repository) {
23
20
  const repo = () => repository ?? api.policy.repository;
@@ -110,6 +107,80 @@ export function trustedHumanActorIds(config) {
110
107
  return config.github.trustedHumanActorIds ?? [];
111
108
  }
112
109
 
110
+ /**
111
+ * A held Jira/Linear item whose project never named who may release holds can
112
+ * never be released, so say that instead of the generic hold refusal (#4873).
113
+ * The hold itself still stands: an absent list trusts no one.
114
+ */
115
+ export function refuseUnreleasableHold(config, held) {
116
+ const tracker = config.tracker;
117
+ if (
118
+ held &&
119
+ (tracker === "jira" || tracker === "linear") &&
120
+ !Array.isArray(config[tracker]?.trustedHumanActorIds)
121
+ )
122
+ throw operatorRefusal(
123
+ "tracker hold trust list is absent",
124
+ `This work item is held for a person, and ${tracker}.trustedHumanActorIds is not set in .lisa.config.json, so no release comment can lift the hold. List the ${tracker === "jira" ? "Jira accountIds" : "Linear user ids"} of the people allowed to release holds, then rerun.`
125
+ );
126
+ }
127
+
128
+ /**
129
+ * A synchronous test for "the automation wrote this". GitHub: the configured
130
+ * Bot. Jira/Linear: the credential's own account, already required to be the
131
+ * declared claimActorRef (#4873).
132
+ */
133
+ export async function managedActor(api) {
134
+ if (!api.tracker)
135
+ return user =>
136
+ user?.type === "Bot" && String(user.id) === api.policy.claimActorId;
137
+ const id = await api.tracker.actorId();
138
+ return user => typeof user?.id === "string" && user.id === id;
139
+ }
140
+
141
+ /** The one work item reference an allocation of this tracker may carry. */
142
+ export function allocationWorkItem(api, config, repository, number) {
143
+ return api.tracker
144
+ ? expectedWorkItem(config, number)
145
+ : `${repository}#${number}`;
146
+ }
147
+
148
+ /**
149
+ * The one closure check every cancellation path shares. GitHub: closed as
150
+ * not_planned by the configured Bot. Jira/Linear: closed into the canceled
151
+ * status or state, and the changelog or history shows the automation made that
152
+ * move (#4873). `reason` keeps each caller's original refusal.
153
+ */
154
+ export async function assertManagedClosure(api, issue, reason) {
155
+ required(
156
+ issue.state === "closed" &&
157
+ issue.state_reason === "not_planned" &&
158
+ (api.tracker ||
159
+ (issue.closed_by?.type === "Bot" &&
160
+ String(issue.closed_by.id) === api.policy.claimActorId)),
161
+ reason
162
+ );
163
+ if (api.tracker) await api.tracker.assertCancelled(issue.number);
164
+ }
165
+
166
+ /**
167
+ * Publish-time tracker authority for Jira/Linear (#4873): the live claim by the
168
+ * automation identity (returned for the origin chronology), one owner who is the
169
+ * maintainer, and that owner still assignable. GitHub hosts return undefined;
170
+ * their claim is read from GitHub by the provider proof.
171
+ */
172
+ export async function trackerPublishAuthority(api, descriptor, policy, issue) {
173
+ if (!api.tracker) return undefined;
174
+ const claim = await api.tracker.proveClaim(descriptor);
175
+ required(
176
+ issue.assignees.length === 1 &&
177
+ issue.assignees[0].login === policy.maintainer,
178
+ "current recovery leaf or owner differs"
179
+ );
180
+ await api.tracker.assignable(policy.maintainer);
181
+ return claim;
182
+ }
183
+
113
184
  /** An api without an attached adapter is a GitHub-tracked host, exactly as before. */
114
185
  export function trackerOf(api, repository) {
115
186
  return api.tracker ?? githubTracker(api, repository);
@@ -137,15 +208,6 @@ export function createTracker(config, env, transport = globalThis.fetch) {
137
208
  : new LinearTracker(config, env, transport);
138
209
  }
139
210
 
140
- /** Every unsupported Jira/Linear step stops before its first write, in words the operator can act on. */
141
- export function refuseUnlessGithub(config, step) {
142
- if (config.tracker !== "github")
143
- throw operatorRefusal(
144
- `${step} is not supported for this tracker yet`,
145
- FOLLOWUP_SENTENCE
146
- );
147
- }
148
-
149
211
  /** The one reference grammar a tracker's signed artifacts may carry. */
150
212
  export function expectedWorkItem(config, number) {
151
213
  required(Number.isSafeInteger(number) && number > 0, "invalid work item");
@@ -171,6 +233,22 @@ export function verifySignedWorkItem(config, allocation, preview) {
171
233
  );
172
234
  }
173
235
 
236
+ /**
237
+ * The managed PR backlink on a Jira/Linear work item, written by the declared
238
+ * automation identity and read back exactly. A rerun finds it and writes nothing.
239
+ */
240
+ export async function vendorBacklink(tracker, number, prUrl) {
241
+ const body = backlinkBody(prUrl);
242
+ const present = async () => {
243
+ for (const comment of await tracker.comments(number))
244
+ if (comment.body === body && (await tracker.isManagedActor(comment.user)))
245
+ return true;
246
+ return false;
247
+ };
248
+ if (!(await present())) await tracker.backlinkComment(number, body);
249
+ required(await present(), "work item backlink readback differs");
250
+ }
251
+
174
252
  /** Checkpoint authority for Jira/Linear: the live GitHub run plus the claim proved on the tracker. */
175
253
  export async function proveTrackerProvider(api, descriptor, config) {
176
254
  const tracker = trackerFor(api, api.policy, config);
@@ -0,0 +1,158 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /**
5
+ * Route the push gate's heavy steps through headroom admission
6
+ * (CodySwannGT/lisa#4596).
7
+ *
8
+ * When `.lisa.config.json` sets `pushGate.admission: true`, the gate runner
9
+ * runs `code-style-slow` (`lint:slow`), `type-correctness` (`typecheck`) and the
10
+ * build-once step through `lisa admit`, which starts them only when the machine
11
+ * has headroom for them and refuses — never silently starts — once the wait
12
+ * bound expires (5 minutes inside `git push`). Test suites are admitted by
13
+ * `lisa-test-run` itself, so test gates are not wrapped here.
14
+ *
15
+ * With the switch off nothing here changes a command, and heavy steps start
16
+ * immediately exactly as before.
17
+ *
18
+ * Windows is not wrapped: the admitted command is handed over as one
19
+ * POSIX-quoted shell string, and the gate runner's Windows route runs commands
20
+ * through `cmd.exe`. The gap is printed when the switch is on there.
21
+ * @module lib/push-admission
22
+ */
23
+ import { existsSync, readFileSync } from "node:fs";
24
+ import { join } from "node:path";
25
+
26
+ /** Gates, by id, that are heavy enough to admit, and the workers each declares. */
27
+ export const ADMITTED_GATES = Object.freeze({
28
+ "code-style-slow": 2,
29
+ "type-correctness": 1,
30
+ "build-once": 2,
31
+ });
32
+
33
+ /** Value of `LISA_ADMISSION_CONTEXT` that tells admission it is inside a push. */
34
+ export const PUSH_CONTEXT = "push";
35
+
36
+ /**
37
+ * Read and validate `pushGate.admission` from a parsed `.lisa.config.json`.
38
+ *
39
+ * Refused rather than defaulted on a wrong type, exactly as `lisa apply`
40
+ * refuses it, so apply and push cannot disagree.
41
+ * @param {Record<string, unknown>|null|undefined} config Parsed config.
42
+ * @returns {boolean} Whether admission is on (default `false`).
43
+ * @throws {Error} When `pushGate` or `pushGate.admission` has the wrong type.
44
+ */
45
+ export function admissionEnabled(config) {
46
+ const pushGate = config?.pushGate;
47
+ if (pushGate === undefined) return false;
48
+ if (
49
+ pushGate === null ||
50
+ typeof pushGate !== "object" ||
51
+ Array.isArray(pushGate)
52
+ ) {
53
+ throw new Error(
54
+ `pushGate is ${JSON.stringify(pushGate)}; expected an object such as ` +
55
+ `{ "admission": true }.`
56
+ );
57
+ }
58
+ const { admission } = pushGate;
59
+ if (admission === undefined) return false;
60
+ if (typeof admission !== "boolean") {
61
+ throw new Error(
62
+ `pushGate.admission is ${JSON.stringify(admission)}; expected true or false.`
63
+ );
64
+ }
65
+ return admission;
66
+ }
67
+
68
+ /**
69
+ * The installed Lisa CLI, as a shell prefix.
70
+ *
71
+ * Lisa itself runs its own build (`node dist/index.js`); a host runs the
72
+ * package it installed (`node_modules/.bin/lisa`).
73
+ * @param {string} cwd Project root.
74
+ * @returns {string|null} The prefix, or null when no CLI is installed.
75
+ */
76
+ export function lisaCliPrefix(cwd) {
77
+ try {
78
+ const manifest = JSON.parse(
79
+ readFileSync(join(cwd, "package.json"), "utf8")
80
+ );
81
+ if (
82
+ manifest?.name === "@codyswann/lisa" &&
83
+ existsSync(join(cwd, "dist", "index.js"))
84
+ ) {
85
+ return "node dist/index.js";
86
+ }
87
+ } catch {
88
+ // No readable manifest: fall through to the installed binary.
89
+ }
90
+ const bin = join(cwd, "node_modules", ".bin", "lisa");
91
+ return existsSync(bin) ? "node_modules/.bin/lisa" : null;
92
+ }
93
+
94
+ /**
95
+ * Quote one string for a POSIX shell.
96
+ * @param {string} text Text to quote.
97
+ * @returns {string} Single-quoted text.
98
+ */
99
+ export function shellQuote(text) {
100
+ const escaped = text.replaceAll("'", "'\\''");
101
+ return `'${escaped}'`;
102
+ }
103
+
104
+ /**
105
+ * The command a heavy gate runs under admission.
106
+ * @param {string} prefix Lisa CLI prefix.
107
+ * @param {number} workers Declared workers.
108
+ * @param {string} command The gate's own command.
109
+ * @returns {string} The admitted command.
110
+ */
111
+ export function admittedCommand(prefix, workers, command) {
112
+ return `${prefix} admit --workers ${workers} -- ${shellQuote(command)}`;
113
+ }
114
+
115
+ /**
116
+ * Wrap a gate executor so heavy gates run through `lisa admit`.
117
+ * @param {(command: string, gate?: {id?: string}) => object} exec Executor.
118
+ * @param {object} options Options.
119
+ * @param {boolean} options.enabled Whether `pushGate.admission` is on.
120
+ * @param {string} [options.cwd] Project root.
121
+ * @param {string} [options.platform] Platform, for the Windows gap.
122
+ * @param {(line: string) => void} [options.out] Where notices go.
123
+ * @param {(cwd: string) => string|null} [options.cli] CLI resolver.
124
+ * @returns {(command: string, gate?: {id?: string}) => object} The executor to use.
125
+ */
126
+ export function withAdmission(
127
+ exec,
128
+ {
129
+ enabled,
130
+ cwd = process.cwd(),
131
+ platform = process.platform,
132
+ out = line => console.log(line),
133
+ cli = lisaCliPrefix,
134
+ }
135
+ ) {
136
+ if (!enabled) return exec;
137
+ if (platform === "win32") {
138
+ out(
139
+ "⚠️ pushGate.admission is on, but the gate runner does not admit heavy " +
140
+ "steps on Windows; they start immediately."
141
+ );
142
+ return exec;
143
+ }
144
+ const prefix = cli(cwd);
145
+ if (prefix === null) {
146
+ out(
147
+ "⚠️ pushGate.admission is on, but no Lisa CLI is installed here " +
148
+ "(node_modules/.bin/lisa); heavy steps start without admission."
149
+ );
150
+ return exec;
151
+ }
152
+ return (command, gate) => {
153
+ const workers = ADMITTED_GATES[gate?.id ?? ""];
154
+ return workers === undefined || !command
155
+ ? exec(command, gate)
156
+ : exec(admittedCommand(prefix, workers, command), gate);
157
+ };
158
+ }
@@ -0,0 +1,34 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /** What a TypeScript project gets when it does not say. */
5
+ export declare const TYPESCRIPT_PUSH_GATE_DEFAULTS: Readonly<{
6
+ cache: true;
7
+ admission: true;
8
+ affectedTests: true;
9
+ affectedCoverage: "changed-files";
10
+ }>;
11
+ /** What a Rails project gets when it does not say. */
12
+ export declare const RAILS_PUSH_GATE_DEFAULTS: Readonly<{
13
+ cache: true;
14
+ admission: true;
15
+ affectedTests: true;
16
+ affectedCoverage: "changed-files";
17
+ }>;
18
+ export declare function isRailsProject(root: string): boolean;
19
+ export declare function isTypeScriptProject(root: string): boolean;
20
+ export declare function pushGateDefaultsFor(
21
+ root: string
22
+ ): Readonly<Record<string, unknown>>;
23
+ export declare function withPushGateDefaults<
24
+ T extends Readonly<Record<string, unknown>>,
25
+ >(
26
+ config: T | null | undefined,
27
+ root: string
28
+ ): T & { readonly pushGate?: unknown };
29
+ export declare function withDefaults<
30
+ T extends Readonly<Record<string, unknown>>,
31
+ >(
32
+ config: T | null | undefined,
33
+ defaults: Readonly<Record<string, unknown>>
34
+ ): T & { readonly pushGate?: unknown };
@@ -0,0 +1,147 @@
1
+ // This file is managed by Lisa and IS replaced on each `lisa` run.
2
+ // Do not edit directly — durable changes belong upstream in Lisa.
3
+
4
+ /**
5
+ * The `pushGate` defaults a project gets without writing them
6
+ * (CodySwannGT/lisa#4611).
7
+ *
8
+ * Lisa proved the smart push gate on itself behind explicit `pushGate`
9
+ * switches, all off by default. TypeScript hosts get it switched on through
10
+ * this file. The default depends on the project's stack and is worked out when
11
+ * the push runs, so `lisa apply` writes nothing into a host's
12
+ * `.lisa.config.json` and an existing host needs no migration. Anything the
13
+ * host sets explicitly wins, `false` included.
14
+ *
15
+ * TypeScript defaults:
16
+ *
17
+ * - `cache: true`: an unchanged tree re-pushes from remembered passes.
18
+ * - `admission: true`: heavy runs wait for machine headroom.
19
+ * - `affectedTests: true`: the unit run narrows to the tests a change can
20
+ * reach, and runs everything whenever that could be wrong.
21
+ * - `affectedCoverage: "changed-files"`: a narrowed run with coverage on
22
+ * holds every changed source file to the coverage floors on its own. That
23
+ * keeps coverage enforced at push. It falls back to the full measured suite
24
+ * when it cannot hold the files, for example when there is no
25
+ * `vitest.thresholds.json` or no test reaches a changed file.
26
+ * - `buildOnce` is NOT defaulted on. In Lisa a push built two or three times,
27
+ * and build-once removes the repeats. A host's push gates do not build at
28
+ * all, so a build-once step would add a full build to every push, a fully
29
+ * cached re-push included. A host whose push steps do build can still set
30
+ * `buildOnce: true`.
31
+ *
32
+ * Rails defaults (CodySwannGT/lisa#4612, #4613) are the same four switches:
33
+ * the pass cache and admission for `scripts/lisa-rails-gates.mjs`, and
34
+ * affected-spec selection with `changed-files` coverage for
35
+ * `scripts/lisa-rspec-select.mjs`. A Rails project is one with `bin/rails` or
36
+ * `config/application.rb`, as `src/detection/detectors/rails.ts` judges it.
37
+ * Rails is checked first, so a Rails app that also carries a `tsconfig.json`
38
+ * gets the Rails table; the two tables agree today.
39
+ *
40
+ * Other stacks get no defaults here. This file is the one place every stack's
41
+ * `pushGate` defaults live; the TypeScript and Rails runners, `lisa check` and
42
+ * `lisa-test-run`'s admission all read them through it.
43
+ *
44
+ * This file is plain `.mjs` and runs before any build, so it cannot import
45
+ * `src/detection/`. It mirrors `src/detection/detectors/typescript.ts`: a
46
+ * TypeScript project has a root `tsconfig.json`, or `typescript` in
47
+ * `package.json` dependencies or devDependencies. `src/core/push-gate-defaults.ts`
48
+ * holds the same table for the CLI, and a unit test keeps the two in step.
49
+ * @module push-gate-defaults
50
+ */
51
+ import { existsSync, readFileSync } from "node:fs";
52
+ import { join } from "node:path";
53
+
54
+ /** What a TypeScript project gets when it does not say. */
55
+ export const TYPESCRIPT_PUSH_GATE_DEFAULTS = Object.freeze({
56
+ cache: true,
57
+ admission: true,
58
+ affectedTests: true,
59
+ affectedCoverage: "changed-files",
60
+ });
61
+
62
+ /** What a Rails project gets when it does not say. */
63
+ export const RAILS_PUSH_GATE_DEFAULTS = Object.freeze({
64
+ cache: true,
65
+ admission: true,
66
+ affectedTests: true,
67
+ affectedCoverage: "changed-files",
68
+ });
69
+
70
+ /**
71
+ * Whether `root` is a Rails project: `bin/rails`, else `config/application.rb`.
72
+ * @param {string} root Project root.
73
+ * @returns {boolean} True for a Rails project.
74
+ */
75
+ export function isRailsProject(root) {
76
+ return (
77
+ existsSync(join(root, "bin", "rails")) ||
78
+ existsSync(join(root, "config", "application.rb"))
79
+ );
80
+ }
81
+
82
+ /**
83
+ * Whether `root` is a TypeScript project, judged as `src/detection` judges it.
84
+ * @param {string} root Project root.
85
+ * @returns {boolean} True for a TypeScript project.
86
+ */
87
+ export function isTypeScriptProject(root) {
88
+ if (existsSync(join(root, "tsconfig.json"))) return true;
89
+ let manifest;
90
+ try {
91
+ manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
92
+ } catch {
93
+ return false;
94
+ }
95
+ return (
96
+ manifest?.dependencies?.typescript !== undefined ||
97
+ manifest?.devDependencies?.typescript !== undefined
98
+ );
99
+ }
100
+
101
+ /**
102
+ * The defaults for the project at `root`.
103
+ * @param {string} root Project root.
104
+ * @returns {Readonly<Record<string, unknown>>} Defaults (empty when none apply).
105
+ */
106
+ export function pushGateDefaultsFor(root) {
107
+ if (isRailsProject(root)) return RAILS_PUSH_GATE_DEFAULTS;
108
+ return isTypeScriptProject(root) ? TYPESCRIPT_PUSH_GATE_DEFAULTS : {};
109
+ }
110
+
111
+ /**
112
+ * A parsed `.lisa.config.json` with the stack's `pushGate` defaults filled in
113
+ * under the project's own keys.
114
+ *
115
+ * A malformed `pushGate` (null, an array, a string) is returned untouched, so
116
+ * the readers still refuse it with their own message rather than having a
117
+ * default hide the typo. The input is never modified.
118
+ * @param {Record<string, unknown>|null|undefined} config Parsed config.
119
+ * @param {string} root Project root.
120
+ * @returns {Record<string, unknown>} The config the push gate should read.
121
+ */
122
+ export function withPushGateDefaults(config, root) {
123
+ return withDefaults(config, pushGateDefaultsFor(root));
124
+ }
125
+
126
+ /**
127
+ * A parsed `.lisa.config.json` with the given `pushGate` defaults filled in
128
+ * under the project's own keys, by the same rules as
129
+ * {@link withPushGateDefaults}. For a caller that already knows the stack.
130
+ * @param {Record<string, unknown>|null|undefined} config Parsed config.
131
+ * @param {Readonly<Record<string, unknown>>} defaults The stack's defaults.
132
+ * @returns {Record<string, unknown>} The config with defaults applied.
133
+ */
134
+ export function withDefaults(config, defaults) {
135
+ const base = config && typeof config === "object" ? config : {};
136
+ const declared = base.pushGate;
137
+ const malformed =
138
+ declared !== undefined &&
139
+ (declared === null ||
140
+ typeof declared !== "object" ||
141
+ Array.isArray(declared));
142
+ if (malformed) return base;
143
+ if (Object.keys(defaults).length === 0) return base;
144
+ // Spreading an absent block adds nothing, so no `?? {}` is needed (and the
145
+ // shipped fixer would strip one).
146
+ return { ...base, pushGate: { ...defaults, ...declared } };
147
+ }