@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,69 @@
1
+ /** File name of the decision lock. */
2
+ export declare const LOCK_FILE = "admission.sock";
3
+ /**
4
+ * Longest Unix socket path every supported platform can bind. macOS caps
5
+ * `sun_path` at 104 bytes and, past it, binds a silently TRUNCATED path, so a
6
+ * lock at the full path is never visible and `takeLock` would retry until its bound.
7
+ */
8
+ export declare const UNIX_SOCKET_PATH_LIMIT = 103;
9
+ /** Mode of the per-user fallback lock directory. */
10
+ export declare const PRIVATE_DIR_MODE = 448;
11
+ /**
12
+ * Where the decision lock listens.
13
+ *
14
+ * A state directory deep enough to push `admission.sock` past the socket limit
15
+ * (a long `XDG_CACHE_HOME`, a nested test scratch root) moves the lock to
16
+ * `<tmp>/lisa-admission-<uid>/<digest>.sock`, named by the state directory so
17
+ * every process sharing that directory still meets on one lock. The directory
18
+ * is per user and created 0700 (see `privateLockDirProblem`): a predictable
19
+ * name straight in a world-writable `/tmp` let another local user listen there,
20
+ * or plant a file, and hang or break every push. The user's own temp directory
21
+ * is preferred; `/tmp` is the fallback when that is too deep to fit.
22
+ * @param stateDir - State directory
23
+ * @param platform - Platform to decide for
24
+ * @param tmp - The user's temp directory
25
+ * @param uid - The user's uid
26
+ * @returns Socket path, or a named pipe on Windows
27
+ */
28
+ export declare function lockAddress(stateDir: string, platform?: NodeJS.Platform, tmp?: string, uid?: number | undefined): string;
29
+ /**
30
+ * Why a path may not be used as this user's lock, or null when it may: it is
31
+ * absent, or it is a socket this user owns.
32
+ * @param path - Lock address
33
+ * @param uid - The user's uid; undefined skips the check (Windows)
34
+ * @returns The problem, or null
35
+ */
36
+ export declare function lockPathProblem(path: string, uid?: number | undefined): string | null;
37
+ /**
38
+ * Why a fallback lock directory may not be used, or null when it may. It must
39
+ * be a real directory (not a symlink) this user owns; one left group- or
40
+ * world-accessible is tightened to 0700.
41
+ * @param dir - Directory
42
+ * @param uid - The user's uid
43
+ * @returns The problem, or null
44
+ */
45
+ export declare function privateLockDirProblem(dir: string, uid?: number | undefined): string | null;
46
+ /** How long, and on which clock, taking the lock may wait. */
47
+ export interface LockWait {
48
+ /** Wait between attempts. */
49
+ readonly sleep: (ms: number) => Promise<void>;
50
+ /** Wall clock. */
51
+ readonly now: () => number;
52
+ /** Epoch milliseconds after which the lock counts as unavailable. */
53
+ readonly until: number;
54
+ }
55
+ /** The lock, or why it could not be taken within the bound. */
56
+ export type DecisionLock = {
57
+ readonly release: () => Promise<void>;
58
+ } | {
59
+ readonly unavailable: string;
60
+ };
61
+ /**
62
+ * Take the decision lock, replacing a socket file its dead holder left behind,
63
+ * or report it unavailable when it cannot be ours within the bound.
64
+ * @param stateDir - State directory
65
+ * @param wait - Sleep, clock and deadline
66
+ * @returns The lock, or why it is unavailable
67
+ */
68
+ export declare function acquireDecisionLock(stateDir: string, wait: LockWait): Promise<DecisionLock>;
69
+ //# sourceMappingURL=admission-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission-lock.d.ts","sourceRoot":"","sources":["../../src/core/admission-lock.ts"],"names":[],"mappings":"AAoCA,sCAAsC;AACtC,eAAO,MAAM,SAAS,mBAAmB,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,oDAAoD;AACpD,eAAO,MAAM,gBAAgB,MAAQ,CAAC;AAqCtC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,GAAG,GAAE,MAAuB,EAC5B,GAAG,GAAE,MAAM,GAAG,SAAwB,GACrC,MAAM,CAaR;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,GAAG,GAAE,MAAM,GAAG,SAAwB,GACrC,MAAM,GAAG,IAAI,CAOf;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,GAAG,SAAwB,GACrC,MAAM,GAAG,IAAI,CASf;AAwED,8DAA8D;AAC9D,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,kBAAkB;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GACzC;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,YAAY,CAAC,CAcvB"}
@@ -0,0 +1,278 @@
1
+ /**
2
+ * The headroom-admission decision lock (CodySwannGT/lisa#4596).
3
+ *
4
+ * ## The lock
5
+ *
6
+ * Held only while deciding. It is a listening Unix-domain socket at
7
+ * `admission.sock`: the OS closes it when the holder dies, so a crashed holder
8
+ * leaves at most a socket FILE nobody listens on. A connect that fails with
9
+ * `ECONNREFUSED` proves that, and the file is replaced. Before replacing it the
10
+ * file's inode is read twice around the probe, so a socket another process
11
+ * created in between is never unlinked. Windows uses a named pipe, which the OS
12
+ * removes with its owner.
13
+ *
14
+ * Taking the lock is bounded by the caller's remaining wait. A holder that
15
+ * never lets go — one suspended with Ctrl-Z, or another local user listening
16
+ * at the address — used to make every acquirer retry forever. Past the bound,
17
+ * or when the address cannot be ours (it belongs to another user, it is not a
18
+ * socket, it cannot be opened), `acquireDecisionLock` reports the lock
19
+ * unavailable instead, and admission starts the run without deciding rather
20
+ * than block it (CodySwannGT/lisa#4596 review). Nothing at the address is
21
+ * deleted unless it is a socket this user owns.
22
+ * @module core/admission-lock
23
+ */
24
+ import { createHash } from "node:crypto";
25
+ import { chmodSync, lstatSync, mkdirSync, rmSync, statSync, } from "node:fs";
26
+ import { tmpdir as systemTmpdir } from "node:os";
27
+ import { createConnection, createServer } from "node:net";
28
+ import { dirname, join } from "node:path";
29
+ /** File name of the decision lock. */
30
+ export const LOCK_FILE = "admission.sock";
31
+ /**
32
+ * Longest Unix socket path every supported platform can bind. macOS caps
33
+ * `sun_path` at 104 bytes and, past it, binds a silently TRUNCATED path, so a
34
+ * lock at the full path is never visible and `takeLock` would retry until its bound.
35
+ */
36
+ export const UNIX_SOCKET_PATH_LIMIT = 103;
37
+ /** Mode of the per-user fallback lock directory. */
38
+ export const PRIVATE_DIR_MODE = 0o700;
39
+ /** The longest a probe of the lock holder may take before it counts as held. */
40
+ const PROBE_TIMEOUT_MS = 1_000;
41
+ /**
42
+ * This process's uid, or undefined where the platform has none (Windows).
43
+ * @returns The uid
44
+ */
45
+ function currentUid() {
46
+ return process.getuid?.();
47
+ }
48
+ /**
49
+ * `lstat` of a path, or the error code when it cannot be read.
50
+ * @param path - Path
51
+ * @returns Stats, or the code
52
+ */
53
+ function lstatOrCode(path) {
54
+ try {
55
+ return lstatSync(path);
56
+ }
57
+ catch (error) {
58
+ return codeOf(error);
59
+ }
60
+ }
61
+ /**
62
+ * Why an error happened, as its errno code when it has one.
63
+ * @param error - Thrown value
64
+ * @returns Code or message
65
+ */
66
+ function codeOf(error) {
67
+ return String(error.code ?? error.message);
68
+ }
69
+ /**
70
+ * Where the decision lock listens.
71
+ *
72
+ * A state directory deep enough to push `admission.sock` past the socket limit
73
+ * (a long `XDG_CACHE_HOME`, a nested test scratch root) moves the lock to
74
+ * `<tmp>/lisa-admission-<uid>/<digest>.sock`, named by the state directory so
75
+ * every process sharing that directory still meets on one lock. The directory
76
+ * is per user and created 0700 (see `privateLockDirProblem`): a predictable
77
+ * name straight in a world-writable `/tmp` let another local user listen there,
78
+ * or plant a file, and hang or break every push. The user's own temp directory
79
+ * is preferred; `/tmp` is the fallback when that is too deep to fit.
80
+ * @param stateDir - State directory
81
+ * @param platform - Platform to decide for
82
+ * @param tmp - The user's temp directory
83
+ * @param uid - The user's uid
84
+ * @returns Socket path, or a named pipe on Windows
85
+ */
86
+ export function lockAddress(stateDir, platform = process.platform, tmp = systemTmpdir(), uid = currentUid()) {
87
+ const digest = createHash("sha256")
88
+ .update(stateDir)
89
+ .digest("hex")
90
+ .slice(0, 16);
91
+ if (platform === "win32")
92
+ return `\\\\.\\pipe\\lisa-admission-${digest}`;
93
+ const beside = join(stateDir, LOCK_FILE);
94
+ if (Buffer.byteLength(beside) <= UNIX_SOCKET_PATH_LIMIT)
95
+ return beside;
96
+ const name = `lisa-admission-${String(uid ?? "user")}`;
97
+ const preferred = join(tmp, name, `${digest}.sock`);
98
+ return Buffer.byteLength(preferred) <= UNIX_SOCKET_PATH_LIMIT
99
+ ? preferred
100
+ : join("/tmp", name, `${digest}.sock`);
101
+ }
102
+ /**
103
+ * Why a path may not be used as this user's lock, or null when it may: it is
104
+ * absent, or it is a socket this user owns.
105
+ * @param path - Lock address
106
+ * @param uid - The user's uid; undefined skips the check (Windows)
107
+ * @returns The problem, or null
108
+ */
109
+ export function lockPathProblem(path, uid = currentUid()) {
110
+ const stat = lstatOrCode(path);
111
+ if (uid === undefined || typeof stat === "string")
112
+ return null;
113
+ if (stat.uid !== uid)
114
+ return `${path} belongs to another user (uid ${String(stat.uid)})`;
115
+ if (!stat.isSocket())
116
+ return `${path} is not a socket`;
117
+ return null;
118
+ }
119
+ /**
120
+ * Why a fallback lock directory may not be used, or null when it may. It must
121
+ * be a real directory (not a symlink) this user owns; one left group- or
122
+ * world-accessible is tightened to 0700.
123
+ * @param dir - Directory
124
+ * @param uid - The user's uid
125
+ * @returns The problem, or null
126
+ */
127
+ export function privateLockDirProblem(dir, uid = currentUid()) {
128
+ const stat = lstatOrCode(dir);
129
+ if (uid === undefined)
130
+ return null;
131
+ if (typeof stat === "string")
132
+ return `${dir} could not be read (${stat})`;
133
+ if (!stat.isDirectory())
134
+ return `${dir} is not a directory`;
135
+ if (stat.uid !== uid)
136
+ return `${dir} belongs to another user (uid ${String(stat.uid)})`;
137
+ if ((stat.mode & 0o077) !== 0)
138
+ chmodSync(dir, PRIVATE_DIR_MODE);
139
+ return null;
140
+ }
141
+ /**
142
+ * Inode of a path, or null when it is absent.
143
+ * @param path - Path to stat
144
+ * @returns Inode number
145
+ */
146
+ function inodeOf(path) {
147
+ try {
148
+ return statSync(path).ino;
149
+ }
150
+ catch {
151
+ return null;
152
+ }
153
+ }
154
+ /**
155
+ * Whether anything is listening on the lock address. A probe that does not
156
+ * finish within `timeoutMs` counts as held, so the probe itself cannot hang.
157
+ * @param address - Socket path
158
+ * @param timeoutMs - Longest the probe may take
159
+ * @returns Held when a holder answered (or the probe timed out), stale on
160
+ * `ECONNREFUSED`/`ENOENT`, denied when the address refuses this user
161
+ */
162
+ function probeHolder(address, timeoutMs) {
163
+ return new Promise(resolve => {
164
+ const socket = createConnection(address);
165
+ socket.setTimeout(timeoutMs, () => {
166
+ socket.destroy();
167
+ resolve({ kind: "held" });
168
+ });
169
+ socket.once("connect", () => {
170
+ socket.destroy();
171
+ resolve({ kind: "held" });
172
+ });
173
+ socket.once("error", error => {
174
+ const code = String(error.code);
175
+ if (code === "ECONNREFUSED" || code === "ENOENT") {
176
+ resolve({ kind: "stale" });
177
+ }
178
+ else if (code === "EACCES" || code === "EPERM") {
179
+ resolve({ kind: "denied", code });
180
+ }
181
+ else {
182
+ resolve({ kind: "held" });
183
+ }
184
+ });
185
+ });
186
+ }
187
+ /**
188
+ * Try once to take the decision lock.
189
+ * @param address - Socket path
190
+ * @returns The listening server, null when somebody else holds it, or the
191
+ * error code when the address cannot be opened at all
192
+ */
193
+ function tryListen(address) {
194
+ return new Promise(resolve => {
195
+ const server = createServer(connection => connection.destroy());
196
+ server.once("error", error => {
197
+ // macOS answers a bind through a symlinked directory (`/tmp`) with
198
+ // EEXIST rather than EADDRINUSE; both mean the address is taken.
199
+ const code = codeOf(error);
200
+ resolve(code === "EADDRINUSE" || code === "EEXIST" ? null : code);
201
+ });
202
+ server.listen(address, () => resolve(server));
203
+ });
204
+ }
205
+ /**
206
+ * Take the decision lock, replacing a socket file its dead holder left behind,
207
+ * or report it unavailable when it cannot be ours within the bound.
208
+ * @param stateDir - State directory
209
+ * @param wait - Sleep, clock and deadline
210
+ * @returns The lock, or why it is unavailable
211
+ */
212
+ export async function acquireDecisionLock(stateDir, wait) {
213
+ const address = lockAddress(stateDir);
214
+ const dir = dirname(address);
215
+ mkdirSync(stateDir, { recursive: true });
216
+ if (process.platform !== "win32" && dir !== stateDir) {
217
+ try {
218
+ mkdirSync(dir, { recursive: true, mode: PRIVATE_DIR_MODE });
219
+ }
220
+ catch (error) {
221
+ return { unavailable: `${dir} could not be created (${codeOf(error)})` };
222
+ }
223
+ const problem = privateLockDirProblem(dir);
224
+ if (problem !== null)
225
+ return { unavailable: problem };
226
+ }
227
+ return takeLock(address, wait);
228
+ }
229
+ /**
230
+ * Listen on the lock address, retrying until it is ours or the bound passes.
231
+ * @param address - Socket path
232
+ * @param wait - Sleep, clock and deadline
233
+ * @returns The lock, or why it is unavailable
234
+ */
235
+ async function takeLock(address, wait) {
236
+ const problem = lockPathProblem(address);
237
+ if (problem !== null)
238
+ return { unavailable: problem };
239
+ const server = await tryListen(address);
240
+ if (typeof server === "string") {
241
+ return { unavailable: `${address} could not be opened (${server})` };
242
+ }
243
+ if (server !== null) {
244
+ return {
245
+ release: () => new Promise(resolve => server.close(() => resolve())),
246
+ };
247
+ }
248
+ const remaining = wait.until - wait.now();
249
+ const before = inodeOf(address);
250
+ const probe = await probeHolder(address, Math.max(1, Math.min(PROBE_TIMEOUT_MS, remaining)));
251
+ if (probe.kind === "denied") {
252
+ return { unavailable: `${address} refused this user (${probe.code})` };
253
+ }
254
+ if (probe.kind === "stale" &&
255
+ before !== null &&
256
+ inodeOf(address) === before) {
257
+ try {
258
+ rmSync(address, { force: true });
259
+ }
260
+ catch (error) {
261
+ return {
262
+ unavailable: `${address} could not be replaced (${codeOf(error)})`,
263
+ };
264
+ }
265
+ return takeLock(address, wait);
266
+ }
267
+ const left = wait.until - wait.now();
268
+ if (left <= 0) {
269
+ return {
270
+ unavailable: `another process held ${address} for the whole wait`,
271
+ };
272
+ }
273
+ // Jitter only spreads retries apart; nothing depends on its quality.
274
+ // eslint-disable-next-line sonarjs/pseudo-random -- retry jitter, not a secret
275
+ await wait.sleep(Math.min(left, 25 + Math.floor(Math.random() * 75)));
276
+ return takeLock(address, wait);
277
+ }
278
+ //# sourceMappingURL=admission-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission-lock.js","sourceRoot":"","sources":["../../src/core/admission-lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,EAEN,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAe,MAAM,UAAU,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,sCAAsC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAE1C,oDAAoD;AACpD,MAAM,CAAC,MAAM,gBAAgB,GAAG,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QAC5B,OAAO,EAAE,WAAW,EAAE,GAAG,OAAO,uBAAuB,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC;IACzE,CAAC;IACD,IACE,KAAK,CAAC,IAAI,KAAK,OAAO;QACtB,MAAM,KAAK,IAAI;QACf,OAAO,CAAC,OAAO,CAAC,KAAK,MAAM,EAC3B,CAAC;QACD,IAAI,CAAC;YACH,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,WAAW,EAAE,GAAG,OAAO,2BAA2B,MAAM,CAAC,KAAK,CAAC,GAAG;aACnE,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACrC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACd,OAAO;YACL,WAAW,EAAE,wBAAwB,OAAO,qBAAqB;SAClE,CAAC;IACJ,CAAC;IACD,qEAAqE;IACrE,+EAA+E;IAC/E,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { type HeadroomThresholds } from "./admission-decision.js";
2
+ /** Wait bound for a standalone run. */
3
+ export declare const DEFAULT_MAX_WAIT_MS: number;
4
+ /** Wait bound inside `git push`. */
5
+ export declare const DEFAULT_PUSH_MAX_WAIT_MS: number;
6
+ /** How often a waiting run re-checks the machine. */
7
+ export declare const DEFAULT_POLL_MS = 3000;
8
+ /** Value of `LISA_ADMISSION_CONTEXT` a push sets for its children. */
9
+ export declare const PUSH_CONTEXT = "push";
10
+ /** Granted worker count handed to an admitted run. */
11
+ export declare const ADMITTED_WORKERS_ENV = "LISA_ADMITTED_WORKERS";
12
+ /** Pid of the process holding the reservation an admitted run lives under. */
13
+ export declare const ADMISSION_HOLDER_ENV = "LISA_ADMISSION_HOLDER";
14
+ /** Everything admission needs to run once. */
15
+ export interface AdmissionSettings {
16
+ /** Why admission is skipped, or null when it is armed. */
17
+ readonly skipped: string | null;
18
+ /** Decision thresholds. */
19
+ readonly thresholds: HeadroomThresholds;
20
+ /** How long a run may wait before it is refused. */
21
+ readonly maxWaitMs: number;
22
+ /** Re-check interval while waiting. */
23
+ readonly pollMs: number;
24
+ /** Whether this run is inside `git push`. */
25
+ readonly push: boolean;
26
+ /** Machine-wide state directory shared by every repository of this user. */
27
+ readonly stateDir: string;
28
+ }
29
+ /** The `admission` block of `.lisa.config.local.json`. */
30
+ interface LocalAdmissionConfig {
31
+ readonly maxLoadPerCore?: number | undefined;
32
+ readonly minFreeMemoryMb?: number | undefined;
33
+ readonly maxWaitSeconds?: number | undefined;
34
+ readonly pushMaxWaitSeconds?: number | undefined;
35
+ }
36
+ /**
37
+ * Parse a duration: a bare number is seconds; `ms`, `s`, `m`, `h` also work.
38
+ * @param raw - Text such as `300`, `90s`, `5m`
39
+ * @param name - Setting name shown in the error
40
+ * @returns Milliseconds
41
+ */
42
+ export declare function parseDuration(raw: string, name: string): number;
43
+ /**
44
+ * Whether `.lisa.config.json` in `cwd` switches admission on.
45
+ * @param cwd - Project root
46
+ * @returns The validated switch (default false)
47
+ */
48
+ export declare function admissionSwitchOn(cwd: string): boolean;
49
+ /**
50
+ * Read `.lisa.config.local.json` → `admission`.
51
+ * @param cwd - Project root
52
+ * @returns Validated block (empty when absent)
53
+ */
54
+ export declare function readLocalAdmissionConfig(cwd: string): LocalAdmissionConfig;
55
+ /**
56
+ * Resolve every admission setting for one run.
57
+ * @param options - Inputs
58
+ * @param options.environment - Environment
59
+ * @param options.cwd - Project root holding `.lisa.config.local.json`
60
+ * @param options.maxWaitOverride - `--max-wait` from the command line
61
+ * @returns Settings
62
+ */
63
+ export declare function resolveAdmissionSettings(options: {
64
+ readonly environment: NodeJS.ProcessEnv;
65
+ readonly cwd: string;
66
+ readonly maxWaitOverride?: string;
67
+ }): AdmissionSettings;
68
+ export {};
69
+ //# sourceMappingURL=admission-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission-settings.d.ts","sourceRoot":"","sources":["../../src/core/admission-settings.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,kBAAkB,EAExB,MAAM,yBAAyB,CAAC;AAIjC,uCAAuC;AACvC,eAAO,MAAM,mBAAmB,QAAc,CAAC;AAE/C,oCAAoC;AACpC,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAEnD,qDAAqD;AACrD,eAAO,MAAM,eAAe,OAAQ,CAAC;AAErC,sEAAsE;AACtE,eAAO,MAAM,YAAY,SAAS,CAAC;AAEnC,sDAAsD;AACtD,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,2BAA2B;IAC3B,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,0DAA0D;AAC1D,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClD;AAUD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/D;AAYD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOtD;AAsBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAkB1E;AAqED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC,GAAG,iBAAiB,CA6BpB"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * Where headroom admission's switch, thresholds and wait bounds come from.
3
+ *
4
+ * - **The switch** is `pushGate.admission` in the committed `.lisa.config.json`
5
+ * (default off). Callers that route work through admission — the gate runner
6
+ * and `lisa-test-run` — consult it; `lisa admit` itself always admits, since
7
+ * calling it is the decision.
8
+ * - **Thresholds** are machine-local: `.lisa.config.local.json` → `admission`
9
+ * (never committed), overridden by `LISA_ADMISSION_*` environment variables,
10
+ * with code defaults underneath.
11
+ * - **The wait bound** is short inside `git push` (5 minutes, well below the
12
+ * ~35-minute remote timeout) and 30 minutes elsewhere. It always ends in a
13
+ * refusal; nothing ever starts anyway once it expires.
14
+ * @module core/admission-settings
15
+ */
16
+ import { existsSync, readFileSync } from "node:fs";
17
+ import { homedir } from "node:os";
18
+ import { join } from "node:path";
19
+ import { DEFAULT_MAX_LOAD_PER_CORE, DEFAULT_MIN_FREE_MEMORY_MB, RECENT_RESERVATION_WINDOW_MS, } from "./admission-decision.js";
20
+ import { withPushGateDefaults } from "../../all/copy-overwrite/scripts/lib/push-gate-defaults.mjs";
21
+ import { validatePushGateConfig } from "./project-config-push-gate.js";
22
+ /** Wait bound for a standalone run. */
23
+ export const DEFAULT_MAX_WAIT_MS = 30 * 60_000;
24
+ /** Wait bound inside `git push`. */
25
+ export const DEFAULT_PUSH_MAX_WAIT_MS = 5 * 60_000;
26
+ /** How often a waiting run re-checks the machine. */
27
+ export const DEFAULT_POLL_MS = 3_000;
28
+ /** Value of `LISA_ADMISSION_CONTEXT` a push sets for its children. */
29
+ export const PUSH_CONTEXT = "push";
30
+ /** Granted worker count handed to an admitted run. */
31
+ export const ADMITTED_WORKERS_ENV = "LISA_ADMITTED_WORKERS";
32
+ /** Pid of the process holding the reservation an admitted run lives under. */
33
+ export const ADMISSION_HOLDER_ENV = "LISA_ADMISSION_HOLDER";
34
+ const DURATION = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/u;
35
+ const UNIT_MS = {
36
+ ms: 1,
37
+ s: 1000,
38
+ m: 60_000,
39
+ h: 3_600_000,
40
+ };
41
+ /**
42
+ * Parse a duration: a bare number is seconds; `ms`, `s`, `m`, `h` also work.
43
+ * @param raw - Text such as `300`, `90s`, `5m`
44
+ * @param name - Setting name shown in the error
45
+ * @returns Milliseconds
46
+ */
47
+ export function parseDuration(raw, name) {
48
+ const match = DURATION.exec(raw.trim());
49
+ if (match?.[1] === undefined) {
50
+ throw new Error(`${name} is ${JSON.stringify(raw)}; expected a duration such as 300, 90s or 5m.`);
51
+ }
52
+ return Math.round(Number(match[1]) * (UNIT_MS[match[2] ?? "s"] ?? 1000));
53
+ }
54
+ /**
55
+ * Read a JSON file, or undefined when it does not exist.
56
+ * @param path - File to read
57
+ * @returns Parsed value
58
+ */
59
+ function readJson(path) {
60
+ if (!existsSync(path))
61
+ return undefined;
62
+ return JSON.parse(readFileSync(path, "utf8"));
63
+ }
64
+ /**
65
+ * Whether `.lisa.config.json` in `cwd` switches admission on.
66
+ * @param cwd - Project root
67
+ * @returns The validated switch (default false)
68
+ */
69
+ export function admissionSwitchOn(cwd) {
70
+ const path = join(cwd, ".lisa.config.json");
71
+ const config = readJson(path);
72
+ // The stack's defaults under the project's own keys (CodySwannGT/lisa#4611),
73
+ // read through the same module the push gate runner reads.
74
+ const effective = withPushGateDefaults(config ?? {}, cwd);
75
+ return validatePushGateConfig(effective.pushGate, path)?.admission === true;
76
+ }
77
+ /**
78
+ * Check one optional positive number in the local block.
79
+ * @param block - Untrusted block
80
+ * @param key - Key to read
81
+ * @returns The number, or undefined when absent
82
+ */
83
+ function positiveNumber(block, key) {
84
+ const value = block[key];
85
+ if (value === undefined)
86
+ return undefined;
87
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
88
+ throw new Error(`Invalid admission.${key} in .lisa.config.local.json: expected a positive number`);
89
+ }
90
+ return value;
91
+ }
92
+ /**
93
+ * Read `.lisa.config.local.json` → `admission`.
94
+ * @param cwd - Project root
95
+ * @returns Validated block (empty when absent)
96
+ */
97
+ export function readLocalAdmissionConfig(cwd) {
98
+ const local = readJson(join(cwd, ".lisa.config.local.json"));
99
+ const block = local?.admission;
100
+ if (block === undefined)
101
+ return {};
102
+ if (block === null || typeof block !== "object" || Array.isArray(block)) {
103
+ throw new Error("Invalid admission in .lisa.config.local.json: expected an object");
104
+ }
105
+ const record = block;
106
+ return {
107
+ maxLoadPerCore: positiveNumber(record, "maxLoadPerCore"),
108
+ minFreeMemoryMb: positiveNumber(record, "minFreeMemoryMb"),
109
+ maxWaitSeconds: positiveNumber(record, "maxWaitSeconds"),
110
+ pushMaxWaitSeconds: positiveNumber(record, "pushMaxWaitSeconds"),
111
+ };
112
+ }
113
+ /**
114
+ * Read a positive numeric environment variable.
115
+ * @param environment - Environment
116
+ * @param name - Variable name
117
+ * @returns The number, or undefined when unset
118
+ */
119
+ function envNumber(environment, name) {
120
+ const raw = environment[name]?.trim();
121
+ if (raw === undefined || raw === "")
122
+ return undefined;
123
+ const value = Number(raw);
124
+ if (!Number.isFinite(value) || value < 0) {
125
+ throw new Error(`${name} is ${JSON.stringify(raw)}; expected a number.`);
126
+ }
127
+ return value;
128
+ }
129
+ /**
130
+ * Why admission is skipped for this process, or null when it is armed.
131
+ * @param environment - Environment
132
+ * @returns Operator-readable reason, or null
133
+ */
134
+ function skipReason(environment) {
135
+ const mode = environment.LISA_ADMISSION?.trim();
136
+ if (mode === "off")
137
+ return "admission is off (LISA_ADMISSION=off)";
138
+ if (mode === "on")
139
+ return null;
140
+ const ci = environment.CI?.trim().toLowerCase();
141
+ return ci === "true" || ci === "1"
142
+ ? "admission is skipped on CI, where one job owns the runner (set LISA_ADMISSION=on to use it)"
143
+ : null;
144
+ }
145
+ /**
146
+ * The wait bound, in precedence order.
147
+ * @param environment - Environment
148
+ * @param local - Local config block
149
+ * @param push - Whether this run is inside `git push`
150
+ * @param override - `--max-wait` from the command line
151
+ * @returns Milliseconds
152
+ */
153
+ function maxWait(environment, local, push, override) {
154
+ const general = environment.LISA_ADMISSION_MAX_WAIT;
155
+ const pushOnly = environment.LISA_ADMISSION_PUSH_MAX_WAIT;
156
+ if (override !== undefined)
157
+ return parseDuration(override, "--max-wait");
158
+ if (general !== undefined && general.trim() !== "") {
159
+ return parseDuration(general, "LISA_ADMISSION_MAX_WAIT");
160
+ }
161
+ if (!push) {
162
+ return local.maxWaitSeconds === undefined
163
+ ? DEFAULT_MAX_WAIT_MS
164
+ : local.maxWaitSeconds * 1000;
165
+ }
166
+ if (pushOnly !== undefined && pushOnly.trim() !== "") {
167
+ return parseDuration(pushOnly, "LISA_ADMISSION_PUSH_MAX_WAIT");
168
+ }
169
+ return local.pushMaxWaitSeconds === undefined
170
+ ? DEFAULT_PUSH_MAX_WAIT_MS
171
+ : local.pushMaxWaitSeconds * 1000;
172
+ }
173
+ /**
174
+ * Resolve every admission setting for one run.
175
+ * @param options - Inputs
176
+ * @param options.environment - Environment
177
+ * @param options.cwd - Project root holding `.lisa.config.local.json`
178
+ * @param options.maxWaitOverride - `--max-wait` from the command line
179
+ * @returns Settings
180
+ */
181
+ export function resolveAdmissionSettings(options) {
182
+ const { environment } = options;
183
+ const local = readLocalAdmissionConfig(options.cwd);
184
+ const push = environment.LISA_ADMISSION_CONTEXT?.trim() === PUSH_CONTEXT;
185
+ const cache = environment.XDG_CACHE_HOME?.trim();
186
+ return {
187
+ skipped: skipReason(environment),
188
+ thresholds: {
189
+ maxLoadPerCore: envNumber(environment, "LISA_ADMISSION_MAX_LOAD_PER_CORE") ??
190
+ local.maxLoadPerCore ??
191
+ DEFAULT_MAX_LOAD_PER_CORE,
192
+ minFreeMemoryMb: envNumber(environment, "LISA_ADMISSION_MIN_FREE_MEMORY_MB") ??
193
+ local.minFreeMemoryMb ??
194
+ DEFAULT_MIN_FREE_MEMORY_MB,
195
+ recentWindowMs: RECENT_RESERVATION_WINDOW_MS,
196
+ },
197
+ maxWaitMs: maxWait(environment, local, push, options.maxWaitOverride),
198
+ pollMs: envNumber(environment, "LISA_ADMISSION_POLL_MS") ?? DEFAULT_POLL_MS,
199
+ push,
200
+ stateDir: environment.LISA_ADMISSION_STATE_DIR?.trim() ||
201
+ join(cache === undefined || cache === "" ? join(homedir(), ".cache") : cache, "lisa", "admission"),
202
+ };
203
+ }
204
+ //# sourceMappingURL=admission-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission-settings.js","sourceRoot":"","sources":["../../src/core/admission-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,yBAAyB,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