@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
@@ -0,0 +1,537 @@
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
+ * Remember a push gate's pass by the content it proved (CodySwannGT/lisa#4594).
6
+ *
7
+ * A retry, or a re-push of an identical tree, used to pay every push gate
8
+ * again — minutes to hours each — for content that had already passed. A pass
9
+ * is remembered under a key derived from everything its verdict can depend on,
10
+ * and a later run with the SAME key reports `CACHED PASS (<key>)` instead of
11
+ * running the gate.
12
+ *
13
+ * ## The cache must never prove what it did not see
14
+ *
15
+ * Every rule here fails toward running the gate:
16
+ *
17
+ * - The working tree must be exactly the tree being pushed: nothing
18
+ * uncommitted or untracked, and `HEAD^{tree}` equal to the tree of every
19
+ * non-deletion ref in the push. Otherwise a green would describe a different
20
+ * tree than the one pushed (CodySwannGT/lisa#3874).
21
+ * - Only a full PASS is recorded — never a failure, a kill, an unprovable or
22
+ * not-run outcome, or a pass inherited from a shared prover that did not
23
+ * itself pass — and only after the run, once the tree is re-read unchanged.
24
+ * - A gate whose verdict depends on anything outside the key (the tracker,
25
+ * live machine state, history beyond the tree) declares `"cache": false` on
26
+ * its moment entry and always runs.
27
+ * - CI never reads or writes it, and `LISA_GATE_CACHE=off` disables it.
28
+ * - It is off unless `.lisa.config.json` sets `pushGate.cache: true`, so a
29
+ * host behaves exactly as before until its template turns it on.
30
+ *
31
+ * The store is machine-local — one JSON file per passing key under
32
+ * `${XDG_CACHE_HOME:-~/.cache}/lisa/gate-passes/` — shared by every worktree,
33
+ * and pruned of entries older than 30 days whenever it is written.
34
+ *
35
+ * ## The store never holds an environment value
36
+ *
37
+ * `LISA_*` variables enter the key because some of them change a verdict, but
38
+ * that family also carries credentials — `LISA_SECRETS_BOOTSTRAP` and its key
39
+ * hold the secrets-provider bootstrap credential. The key therefore takes one
40
+ * digest of the relevant environment, and a stored record keeps only that
41
+ * digest plus the NAMES of the variables that are not secret-looking. No value
42
+ * is ever written. The directory is created (and re-tightened) 0700 and every
43
+ * entry 0600, so even the names and digests are private to the user, and an
44
+ * entry not written under the current schema is deleted on the next write —
45
+ * an earlier schema stored raw values (CodySwannGT/lisa#4594 review).
46
+ * @module lib/gate-pass-cache
47
+ */
48
+ import { spawnSync } from "node:child_process";
49
+ import { createHash } from "node:crypto";
50
+ import {
51
+ chmodSync,
52
+ existsSync,
53
+ mkdirSync,
54
+ readdirSync,
55
+ readFileSync,
56
+ renameSync,
57
+ rmSync,
58
+ statSync,
59
+ writeFileSync,
60
+ } from "node:fs";
61
+ import { homedir } from "node:os";
62
+ import { join } from "node:path";
63
+
64
+ /** The environment variable that switches the cache off for one run. */
65
+ export const CACHE_ENV = "LISA_GATE_CACHE";
66
+
67
+ /** The per-moment gate field that opts a gate out of the cache. */
68
+ export const CACHE_FIELD = "cache";
69
+
70
+ /** Version of the key derivation; bumping it invalidates every entry. */
71
+ export const KEY_SCHEMA = "lisa.gate-pass/v2";
72
+
73
+ /**
74
+ * Name fragments that mark a variable as possibly holding a credential. Such a
75
+ * name stays out of every stored record; its value still enters the digest.
76
+ */
77
+ export const SECRET_NAME_PATTERN =
78
+ /KEY|TOKEN|SECRET|PASSWORD|PASSWD|BOOTSTRAP|CREDENTIAL|AUTH|PRIVATE/i;
79
+
80
+ /** Mode of the store directory: only the user may list or enter it. */
81
+ export const STORE_DIR_MODE = 0o700;
82
+
83
+ /** Mode of every stored entry: only the user may read it. */
84
+ export const STORE_FILE_MODE = 0o600;
85
+
86
+ /** Entries older than this are ignored on read and pruned on write. */
87
+ export const MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
88
+
89
+ /** Lockfiles whose bytes enter the key whenever they are present. */
90
+ export const LOCKFILES = Object.freeze([
91
+ "bun.lock",
92
+ "bun.lockb",
93
+ "package-lock.json",
94
+ "yarn.lock",
95
+ "pnpm-lock.yaml",
96
+ "Gemfile.lock",
97
+ ]);
98
+
99
+ /** Non-`LISA_*` variables that change how a gate behaves. */
100
+ export const ENV_ALLOWLIST = Object.freeze(["NODE_OPTIONS", "NODE_ENV", "TZ"]);
101
+
102
+ /**
103
+ * `LISA_*` variables left out of the key because they differ on every run
104
+ * without changing a verdict: the switch itself, the hook's temp file of
105
+ * pushed refs, and the cleanup sweep's ownership marker. Left in, each would
106
+ * make every lookup miss.
107
+ *
108
+ * The admission wait bounds are excluded too, by the `LISA_ADMISSION` prefix
109
+ * rule in `relevantEnvironment`: `lisa check` sets `LISA_ADMISSION_MAX_WAIT`
110
+ * so it can wait longer for machine headroom than a push may, and the push
111
+ * that follows does not. A wait bound decides when a gate STARTS, never what
112
+ * it proves, so keying on it would only make the push miss every pass
113
+ * `lisa check` recorded (CodySwannGT/lisa#4601).
114
+ */
115
+ export const VOLATILE_LISA_ENV = Object.freeze([
116
+ CACHE_ENV,
117
+ "LISA_PUSHED_REFS_FILE",
118
+ "LISA_CLEANUP_SWEPT",
119
+ // The test-run owner marker (`<pid>:0`) a Rails pre-push command exports
120
+ // before its payload (CodySwannGT/lisa#4603, #4613): a new pid every run.
121
+ "LISA_TEST_RUN_OWNER",
122
+ // Headroom admission (CodySwannGT/lisa#4596): a grant and a holder pid
123
+ // describe the machine at that moment, not the content being proved.
124
+ "LISA_ADMITTED_WORKERS",
125
+ "LISA_ADMISSION_HOLDER",
126
+ ]);
127
+
128
+ const ZERO_SHA = /^0+$/;
129
+
130
+ /**
131
+ * Read `pushGate.cache` from the project config.
132
+ * @param {object|null|undefined} config Parsed `.lisa.config.json`.
133
+ * @returns {{enabled: boolean, problem: string|null}} Whether the cache is on,
134
+ * and why the declaration was refused when it is malformed.
135
+ */
136
+ export function cacheSetting(config) {
137
+ const block = config?.pushGate;
138
+ if (block === undefined) return { enabled: false, problem: null };
139
+ if (block === null || typeof block !== "object" || Array.isArray(block)) {
140
+ return {
141
+ enabled: false,
142
+ problem: `pushGate is ${JSON.stringify(block)}; expected an object such as {"cache": true}`,
143
+ };
144
+ }
145
+ if (block.cache === undefined) return { enabled: false, problem: null };
146
+ if (typeof block.cache !== "boolean") {
147
+ return {
148
+ enabled: false,
149
+ problem: `pushGate.cache is ${JSON.stringify(block.cache)}; expected true or false`,
150
+ };
151
+ }
152
+ return { enabled: block.cache, problem: null };
153
+ }
154
+
155
+ /**
156
+ * Where passes are stored.
157
+ * @param {Record<string, string|undefined>} env Process environment.
158
+ * @returns {string} Absolute directory path.
159
+ */
160
+ export function cacheDirectory(env) {
161
+ const base = env.XDG_CACHE_HOME || join(homedir(), ".cache");
162
+ return join(base, "lisa", "gate-passes");
163
+ }
164
+
165
+ /**
166
+ * The environment variables that enter the key, sorted by name.
167
+ * @param {Record<string, string|undefined>} env Process environment.
168
+ * @returns {Record<string, string>} The allowlisted, defined variables.
169
+ */
170
+ export function relevantEnvironment(env) {
171
+ const names = Object.keys(env)
172
+ .filter(
173
+ name =>
174
+ ENV_ALLOWLIST.includes(name) ||
175
+ (name.startsWith("LISA_") &&
176
+ !VOLATILE_LISA_ENV.includes(name) &&
177
+ // Every headroom-admission knob (CodySwannGT/lisa#4596) changes
178
+ // only WHEN a step starts, never what it proves.
179
+ !name.startsWith("LISA_ADMISSION"))
180
+ )
181
+ .filter(name => env[name] !== undefined)
182
+ .sort();
183
+ return Object.fromEntries(names.map(name => [name, env[name]]));
184
+ }
185
+
186
+ /**
187
+ * The relevant environment reduced to what may be stored: one digest of every
188
+ * relevant name and value, and the names that do not look like credentials.
189
+ * @param {Record<string, string|undefined>} env Process environment.
190
+ * @returns {{digest: string, names: string[]}} The digest enters the key, so
191
+ * changing any relevant value — secret-looking or not — still misses.
192
+ */
193
+ export function environmentFingerprint(env) {
194
+ const relevant = relevantEnvironment(env);
195
+ return {
196
+ digest: createHash("sha256").update(canonicalJson(relevant)).digest("hex"),
197
+ names: Object.keys(relevant).filter(
198
+ name => !SECRET_NAME_PATTERN.test(name)
199
+ ),
200
+ };
201
+ }
202
+
203
+ /**
204
+ * JSON with object keys sorted at every depth, so equal inputs hash equally.
205
+ * @param {unknown} value Any JSON value.
206
+ * @returns {string} Canonical JSON text.
207
+ */
208
+ export function canonicalJson(value) {
209
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
210
+ if (value !== null && typeof value === "object") {
211
+ const keys = Object.keys(value)
212
+ .filter(key => value[key] !== undefined)
213
+ .sort();
214
+ return `{${keys
215
+ .map(key => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)
216
+ .join(",")}}`;
217
+ }
218
+ return JSON.stringify(value ?? null);
219
+ }
220
+
221
+ /**
222
+ * The cache key for one gate.
223
+ * @param {object} inputs Everything the verdict can depend on.
224
+ * @returns {string} sha256 hex digest.
225
+ */
226
+ export function gateKey(inputs) {
227
+ return createHash("sha256")
228
+ .update(canonicalJson({ schema: KEY_SCHEMA, ...inputs }))
229
+ .digest("hex");
230
+ }
231
+
232
+ /**
233
+ * Run git and return trimmed stdout, or null when it failed.
234
+ * @param {string[]} args Git arguments.
235
+ * @param {string} cwd Directory to run in.
236
+ * @returns {string|null} Output.
237
+ */
238
+ function defaultGit(args, cwd) {
239
+ const child = spawnSync("git", args, { cwd, encoding: "utf8" });
240
+ return child.status === 0 ? String(child.stdout).trim() : null;
241
+ }
242
+
243
+ /**
244
+ * The tree this run proves, or why the cache cannot be used for it.
245
+ * @param {object} options Inputs.
246
+ * @param {string} options.cwd Repository directory.
247
+ * @param {Record<string, string|undefined>} options.env Process environment.
248
+ * @param {(args: string[], cwd: string) => (string|null)} options.git Git runner.
249
+ * @returns {{tree: string}|{skip: string}} The proved tree, or a reason.
250
+ */
251
+ export function provedTree({ cwd, env, git }) {
252
+ const status = git(["status", "--porcelain"], cwd);
253
+ if (status === null) return { skip: "git could not read the working tree" };
254
+ if (status !== "") {
255
+ return {
256
+ skip: "the working tree differs from the pushed commit (uncommitted or untracked changes)",
257
+ };
258
+ }
259
+ const tree = git(["rev-parse", "HEAD^{tree}"], cwd);
260
+ if (!tree) return { skip: "HEAD has no tree to prove" };
261
+ const refsFile = env.LISA_PUSHED_REFS_FILE;
262
+ if (!refsFile) return { tree };
263
+ let lines;
264
+ try {
265
+ lines = readFileSync(refsFile, "utf8").split("\n").filter(Boolean);
266
+ } catch {
267
+ return { skip: "the list of pushed refs could not be read" };
268
+ }
269
+ const shas = lines
270
+ .map(line => line.trim().split(/\s+/)[1] ?? "")
271
+ .filter(sha => /^[0-9a-f]+$/.test(sha) && !ZERO_SHA.test(sha));
272
+ if (shas.length === 0) return { skip: "nothing pushed has a tree" };
273
+ for (const sha of shas) {
274
+ if (git(["rev-parse", `${sha}^{tree}`], cwd) !== tree) {
275
+ return {
276
+ skip: "the working tree differs from the pushed commit (a pushed ref's tree is not HEAD's tree)",
277
+ };
278
+ }
279
+ }
280
+ return { tree };
281
+ }
282
+
283
+ /**
284
+ * Read one JSON file's `gates` block; absent file reads as null.
285
+ * @param {string} path File path.
286
+ * @returns {unknown} The block, or null.
287
+ * @throws {Error} When the file exists but is not JSON.
288
+ */
289
+ function gatesBlockOf(path) {
290
+ if (!existsSync(path)) return null;
291
+ return JSON.parse(readFileSync(path, "utf8")).gates ?? null;
292
+ }
293
+
294
+ /**
295
+ * Key inputs shared by every gate in one run.
296
+ * @param {string} cwd Repository directory.
297
+ * @param {Record<string, string|undefined>} env Process environment.
298
+ * @param {() => (string|null)} bunVersion Reads the bun version.
299
+ * @param {Record<string, string|null>} [extraTools] Further toolchain
300
+ * versions a caller's gates depend on — a Rails host adds `ruby -v` and
301
+ * `bundle -v` (CodySwannGT/lisa#4613). Empty for the gate runner, so its
302
+ * keys are unchanged.
303
+ * @param {Record<string, unknown>} [extraConfig] Further configuration a
304
+ * caller's verdicts depend on — a Rails host adds its effective `pushGate`,
305
+ * which decides whether RSpec runs a selection. Empty for the gate runner,
306
+ * so its keys are unchanged.
307
+ * @returns {{lockfiles: Record<string, string>, tools: {node: string, bun: string|null}, gatesConfig: {project: unknown, local: unknown}, environment: {digest: string, names: string[]}, extraConfig?: Record<string, unknown>}}
308
+ * Lockfile digests, tool versions, config and the environment fingerprint
309
+ * (never raw values — see `environmentFingerprint`).
310
+ */
311
+ export function sharedInputs(
312
+ cwd,
313
+ env,
314
+ bunVersion,
315
+ extraTools = {},
316
+ extraConfig = {}
317
+ ) {
318
+ const lockfiles = Object.fromEntries(
319
+ LOCKFILES.filter(name => existsSync(join(cwd, name))).map(name => [
320
+ name,
321
+ createHash("sha256")
322
+ .update(readFileSync(join(cwd, name)))
323
+ .digest("hex"),
324
+ ])
325
+ );
326
+ return {
327
+ lockfiles,
328
+ tools: { node: process.versions.node, bun: bunVersion(), ...extraTools },
329
+ gatesConfig: {
330
+ project: gatesBlockOf(join(cwd, ".lisa.config.json")),
331
+ local: gatesBlockOf(join(cwd, ".lisa.config.local.json")),
332
+ },
333
+ environment: environmentFingerprint(env),
334
+ ...(Object.keys(extraConfig).length > 0 ? { extraConfig } : {}),
335
+ };
336
+ }
337
+
338
+ /**
339
+ * `bun --version`, or null when bun is not installed.
340
+ * @returns {string|null} Version.
341
+ */
342
+ function defaultBunVersion() {
343
+ const child = spawnSync("bun", ["--version"], { encoding: "utf8" });
344
+ return child.status === 0 ? String(child.stdout).trim() : null;
345
+ }
346
+
347
+ /**
348
+ * Why this run may not use the cache at all, or null when it may.
349
+ * @param {object} config Parsed `.lisa.config.json`.
350
+ * @param {Record<string, string|undefined>} env Process environment.
351
+ * @returns {{silent: boolean, reason: string}|null} The refusal.
352
+ */
353
+ function refusal(config, env) {
354
+ const setting = cacheSetting(config);
355
+ if (setting.problem) {
356
+ return { silent: false, reason: `${setting.problem}, so it is off` };
357
+ }
358
+ if (!setting.enabled) return { silent: true, reason: "" };
359
+ if (String(env[CACHE_ENV] ?? "").toLowerCase() === "off") {
360
+ return { silent: false, reason: `the cache is off (${CACHE_ENV}=off)` };
361
+ }
362
+ if (env.CI || env.GITHUB_ACTIONS) {
363
+ return { silent: false, reason: "CI never reads or writes the cache" };
364
+ }
365
+ return null;
366
+ }
367
+
368
+ /**
369
+ * Whether a stored file was written under the current schema. An entry from an
370
+ * earlier schema may hold raw environment values, so it is never kept.
371
+ * @param {string} path Entry path.
372
+ * @returns {boolean} True for a current entry.
373
+ */
374
+ function isCurrentEntry(path) {
375
+ try {
376
+ return JSON.parse(readFileSync(path, "utf8")).schema === KEY_SCHEMA;
377
+ } catch {
378
+ return false;
379
+ }
380
+ }
381
+
382
+ /**
383
+ * Create the store private to the user, or tighten one an earlier run left
384
+ * readable. Throws when it cannot, so nothing is written to an open directory.
385
+ * @param {string} dir Store directory.
386
+ */
387
+ function preparePrivateStore(dir) {
388
+ mkdirSync(dir, { recursive: true, mode: STORE_DIR_MODE });
389
+ chmodSync(dir, STORE_DIR_MODE);
390
+ }
391
+
392
+ /**
393
+ * Delete entries older than the retention window or from an earlier schema,
394
+ * and tighten any left readable. Best effort.
395
+ * @param {string} dir Store directory.
396
+ * @param {number} now Epoch milliseconds.
397
+ */
398
+ function prune(dir, now) {
399
+ for (const name of readdirSync(dir)) {
400
+ const path = join(dir, name);
401
+ try {
402
+ const stale = now - statSync(path).mtimeMs > MAX_AGE_MS;
403
+ const current = name.endsWith(".json") && isCurrentEntry(path);
404
+ if (stale || (name.endsWith(".json") && !current))
405
+ rmSync(path, { force: true });
406
+ else chmodSync(path, STORE_FILE_MODE);
407
+ } catch {
408
+ // Another run pruned it first.
409
+ }
410
+ }
411
+ }
412
+
413
+ /**
414
+ * Open the cache for one run, or return null when it may not be used.
415
+ *
416
+ * Prints one line saying why it was skipped, except when the project never
417
+ * turned it on — that path stays silent and touches nothing, so a host is
418
+ * unaffected until its template opts in.
419
+ * @param {object} options Inputs.
420
+ * @param {object} options.config Parsed `.lisa.config.json`.
421
+ * @param {object} options.gates The gates block, for per-moment `cache` flags.
422
+ * @param {string} options.moment The moment being run.
423
+ * @param {(line: string) => void} options.out Line sink.
424
+ * @param {string} [options.cwd] Repository directory.
425
+ * @param {Record<string, string|undefined>} [options.env] Environment.
426
+ * @param {() => number} [options.now] Clock.
427
+ * @param {(args: string[], cwd: string) => (string|null)} [options.git] Git runner.
428
+ * @param {() => (string|null)} [options.bunVersion] Bun version reader.
429
+ * @param {Record<string, string|null>} [options.extraTools] Further toolchain
430
+ * versions that enter every key (see `sharedInputs`).
431
+ * @param {Record<string, unknown>} [options.extraConfig] Further configuration
432
+ * that enters every key (see `sharedInputs`).
433
+ * @returns {{lookup: Function, remember: Function, commit: Function}|null} The cache.
434
+ */
435
+ export function openGatePassCache({
436
+ config,
437
+ gates,
438
+ moment,
439
+ out,
440
+ cwd = process.cwd(),
441
+ env = process.env,
442
+ now = Date.now,
443
+ git = defaultGit,
444
+ bunVersion = defaultBunVersion,
445
+ extraTools = {},
446
+ extraConfig = {},
447
+ }) {
448
+ const refused = refusal(config, env);
449
+ if (refused) {
450
+ if (!refused.silent)
451
+ out(`🗃️ Gate pass cache not used: ${refused.reason}.`);
452
+ return null;
453
+ }
454
+ const proved = provedTree({ cwd, env, git });
455
+ if ("skip" in proved) {
456
+ out(`🗃️ Gate pass cache skipped: ${proved.skip}. Every gate runs.`);
457
+ return null;
458
+ }
459
+ let shared;
460
+ try {
461
+ shared = sharedInputs(cwd, env, bunVersion, extraTools, extraConfig);
462
+ } catch (err) {
463
+ out(`🗃️ Gate pass cache skipped: ${err.message}. Every gate runs.`);
464
+ return null;
465
+ }
466
+ const dir = cacheDirectory(env);
467
+ const keyFor = gate =>
468
+ gateKey({
469
+ ...shared,
470
+ tree: proved.tree,
471
+ moment,
472
+ gate: gate.id,
473
+ command: gate.command,
474
+ });
475
+ const eligible = gate =>
476
+ Boolean(gate.command) &&
477
+ gates?.[gate.id]?.[moment]?.[CACHE_FIELD] !== false;
478
+ const pending = [];
479
+ out(`🗃️ Gate pass cache on for tree ${proved.tree.slice(0, 12)}.`);
480
+ return {
481
+ lookup(gate) {
482
+ if (!eligible(gate)) return null;
483
+ const key = keyFor(gate);
484
+ try {
485
+ const entry = JSON.parse(
486
+ readFileSync(join(dir, `${key}.json`), "utf8")
487
+ );
488
+ const age = now() - Date.parse(entry.passedAt);
489
+ return entry.key === key && age >= 0 && age <= MAX_AGE_MS
490
+ ? { key }
491
+ : null;
492
+ } catch {
493
+ return null;
494
+ }
495
+ },
496
+ remember(gate, durationMs) {
497
+ if (eligible(gate)) pending.push({ gate, durationMs });
498
+ },
499
+ commit() {
500
+ if (pending.length === 0) return;
501
+ const after = provedTree({ cwd, env, git });
502
+ if (!("tree" in after) || after.tree !== proved.tree) {
503
+ out(
504
+ "🗃️ Gate passes not recorded: the working tree changed during the run."
505
+ );
506
+ return;
507
+ }
508
+ try {
509
+ preparePrivateStore(dir);
510
+ prune(dir, now());
511
+ for (const { gate, durationMs } of pending) {
512
+ const key = keyFor(gate);
513
+ const entry = {
514
+ schema: KEY_SCHEMA,
515
+ key,
516
+ gate: gate.id,
517
+ inputs: {
518
+ ...shared,
519
+ tree: proved.tree,
520
+ moment,
521
+ command: gate.command,
522
+ },
523
+ passedAt: new Date(now()).toISOString(),
524
+ durationMs,
525
+ };
526
+ const temp = join(dir, `.${key}.${process.pid}.tmp`);
527
+ writeFileSync(temp, `${JSON.stringify(entry, null, 2)}\n`, {
528
+ mode: STORE_FILE_MODE,
529
+ });
530
+ renameSync(temp, join(dir, `${key}.json`));
531
+ }
532
+ } catch (err) {
533
+ out(`🗃️ Gate passes not recorded: ${err.message}.`);
534
+ }
535
+ },
536
+ };
537
+ }
@@ -110,6 +110,21 @@ function providerOrigin(policy, descriptor, historical, execute) {
110
110
  };
111
111
  }
112
112
 
113
+ /**
114
+ * Historical origin without the GitHub claim read: a Jira/Linear claim is proved
115
+ * by its tracker adapter, which supplies the claim time separately (#4873).
116
+ */
117
+ export function verifyHistoricalRun(
118
+ policy,
119
+ descriptor,
120
+ execute = boundedSpawnSync
121
+ ) {
122
+ const read = endpoint =>
123
+ ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
124
+ repositoryState(read, policy, descriptor.parent, targetBranch(descriptor));
125
+ return runState(read, policy, descriptor, true);
126
+ }
127
+
113
128
  /** Prove the trusted human remains assignable using the actual documented status. */
114
129
  export function verifyAssignable(
115
130
  policy,
@@ -204,6 +219,28 @@ export function verifyStaleOriginProvider(
204
219
  };
205
220
  }
206
221
 
222
+ /**
223
+ * The repository and historical-run half of stale-origin authority, for a Jira
224
+ * or Linear host whose claim is proved by its own tracker adapter (#4873).
225
+ */
226
+ export function verifyStaleOriginRun(
227
+ policy,
228
+ descriptor,
229
+ currentParent,
230
+ execute = boundedSpawnSync
231
+ ) {
232
+ requireProof(
233
+ typeof currentParent === "string" &&
234
+ /^[a-f0-9]{40}$/.test(currentParent) &&
235
+ currentParent !== descriptor.parent,
236
+ "cancellation requires a distinct current parent"
237
+ );
238
+ const read = endpoint =>
239
+ ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
240
+ repositoryState(read, policy, currentParent, targetBranch(descriptor));
241
+ return runState(read, policy, descriptor, true);
242
+ }
243
+
207
244
  /** Fresh permission checks its own invocation and the exact observed destination. */
208
245
  export function verifyRecoveryProvider(
209
246
  policy,
@@ -219,6 +256,33 @@ export function verifyRecoveryProvider(
219
256
  );
220
257
  const read = endpoint =>
221
258
  ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
259
+ recoveryLeaf(read, policy, descriptor, recovery, maintainer);
260
+ recoveryDestination(read, policy, descriptor, recovery);
261
+ }
262
+
263
+ /**
264
+ * The code-host half of fresh recovery for a Jira/Linear host: its own live run
265
+ * and the exact observed destination. The leaf body, owner and claim live on the
266
+ * tracker and are proved by the adapter (#4873).
267
+ */
268
+ export function verifyRecoveryDestination(
269
+ policy,
270
+ descriptor,
271
+ recovery,
272
+ execute = boundedSpawnSync
273
+ ) {
274
+ verifyCurrentRun(
275
+ policy,
276
+ { ...descriptor, runId: recovery.runId, runAttempt: recovery.runAttempt },
277
+ execute
278
+ );
279
+ const read = endpoint =>
280
+ ghJson(policy, [API, HOST_FLAG, PUBLIC_HOST, endpoint], execute);
281
+ recoveryDestination(read, policy, descriptor, recovery);
282
+ }
283
+
284
+ /** The GitHub leaf is unchanged and owned by the one trusted maintainer. */
285
+ function recoveryLeaf(read, policy, descriptor, recovery, maintainer) {
222
286
  const number = descriptor.workItem.slice(
223
287
  descriptor.workItem.lastIndexOf("#") + 1
224
288
  );
@@ -233,6 +297,10 @@ export function verifyRecoveryProvider(
233
297
  issue.assignees[0].type === "User",
234
298
  "current recovery leaf or owner differs"
235
299
  );
300
+ }
301
+
302
+ /** The recovery branch and PR are exactly the observed ones, or absent. */
303
+ function recoveryDestination(read, policy, descriptor, recovery) {
236
304
  const refs = read(
237
305
  `repos/${policy.repository}/git/matching-refs/heads/${recovery.branch}`
238
306
  );
@@ -4,7 +4,9 @@
4
4
  /** Fixed historical-origin and fresh-recovery roles preserve ordinary v1 authority. */
5
5
  import {
6
6
  verifyHistoricalProvider,
7
+ verifyHistoricalRun,
7
8
  verifyRecoveryProvider,
9
+ verifyRecoveryDestination,
8
10
  verifyAssignable,
9
11
  } from "./github-attestation-provider.mjs";
10
12
  import { boundedSpawnSync } from "./bounded-spawn.mjs";
@@ -53,9 +55,11 @@ export function assertHistoricalAttestation(
53
55
  "descriptor.json"
54
56
  );
55
57
  const chronology = observedRunChronology(run, now);
56
- const claimed = Date.parse(claim.created_at);
58
+ // Only a Jira/Linear hook passes null: its claim time is proved by the adapter
59
+ // in the credentialed checkpoint and publish phases instead (#4873).
60
+ const claimed = claim === null ? -Infinity : Date.parse(claim.created_at);
57
61
  requireProof(
58
- chronology && Number.isFinite(claimed),
62
+ chronology && (claim === null || Number.isFinite(claimed)),
59
63
  "missing/invalid historical provider chronology"
60
64
  );
61
65
  const { start, end } = chronology;
@@ -281,8 +285,16 @@ export function verifyRecoveryOrigin(
281
285
  "recovery replayed into different current invocation"
282
286
  );
283
287
  });
288
+ // Jira/Linear (`scope.tracker`): the code host proves repository, runs and
289
+ // destination; the adapter proves claim, leaf body and owner (#4873).
290
+ const vendor = scope.tracker === true;
284
291
  const origin = withProvenancePhase("historical-provider", () =>
285
- verifyHistoricalProvider(policy, descriptor, execute)
292
+ vendor
293
+ ? {
294
+ run: verifyHistoricalRun(policy, descriptor, execute),
295
+ claim: scope.claim ?? null,
296
+ }
297
+ : verifyHistoricalProvider(policy, descriptor, execute)
286
298
  );
287
299
  withProvenancePhase("historical-signature", () =>
288
300
  verifyHistoricalDescriptor(
@@ -305,14 +317,17 @@ export function verifyRecoveryOrigin(
305
317
  )
306
318
  );
307
319
  withProvenancePhase("recovery-provider", () =>
308
- verifyRecoveryProvider(
309
- policy,
310
- descriptor,
311
- recovery,
312
- scope.maintainer,
313
- execute
314
- )
320
+ vendor
321
+ ? verifyRecoveryDestination(policy, descriptor, recovery, execute)
322
+ : verifyRecoveryProvider(
323
+ policy,
324
+ descriptor,
325
+ recovery,
326
+ scope.maintainer,
327
+ execute
328
+ )
315
329
  );
330
+ if (vendor) return;
316
331
  withProvenancePhase("assignable", () =>
317
332
  verifyAssignable(policy, scope.maintainer, execute)
318
333
  );