@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,143 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One build for every integration-test shard leg (CodySwannGT/lisa#4599).
4
+ *
5
+ * `quality.yml`'s `🏗️ Build Once for Integration-Test Shards` job runs `build`:
6
+ * it runs `bun run build` once through the build-once marker
7
+ * (`all/copy-overwrite/scripts/lib/build-marker.mjs`, #4595) and packs `dist/`,
8
+ * every file the build changed or added in the tree, and the marker into one
9
+ * archive. Each leg runs `use`: it unpacks that archive over its checkout and
10
+ * checks the marker, so `lisa-test-run` (`scripts/build-unless-marked.mjs`)
11
+ * skips its own build for that exact tree and logs why. A leg whose tree,
12
+ * lockfile or toolchain differs only warns here, and builds as before.
13
+ *
14
+ * Lisa-only: callers' gate tasks run no Lisa build.
15
+ *
16
+ * Usage:
17
+ * node scripts/integration-shard-build.mjs build <archive>
18
+ * node scripts/integration-shard-build.mjs use <archive> [--github-output <file>]
19
+ * @module integration-shard-build
20
+ */
21
+ import { execSync, spawnSync } from "node:child_process";
22
+ import * as fs from "node:fs";
23
+
24
+ import {
25
+ BUILD_MARKER_ENV,
26
+ BUILD_MARKER_PATH,
27
+ checkBuildMarker,
28
+ runBuildOnce,
29
+ } from "../all/copy-overwrite/scripts/lib/build-marker.mjs";
30
+ import { invokedAsScript } from "./lib/invoked-as-script.mjs";
31
+
32
+ /**
33
+ * @typedef {object} Deps
34
+ * @property {(command: string) => { code: number | null }} exec - Run a shell command with inherited output
35
+ * @property {(command: string, args: ReadonlyArray<string>, input?: string) => { status: number | null, stdout: string }} spawn - Run a command
36
+ * @property {typeof checkBuildMarker} check - Marker check
37
+ * @property {typeof runBuildOnce} buildOnce - Build-once runner
38
+ * @property {(line: string) => void} out - Standard output
39
+ * @property {NodeJS.ProcessEnv} env - Environment
40
+ */
41
+
42
+ /**
43
+ * Build once, record the marker, and pack what the legs need.
44
+ * @param {string} archive - Archive to write
45
+ * @param {Deps} deps - Effects
46
+ * @returns {number} Exit code
47
+ */
48
+ function build(archive, deps) {
49
+ const { scripts } = JSON.parse(fs.readFileSync("package.json", "utf8"));
50
+ const entry = deps.buildOnce({
51
+ config: { pushGate: { buildOnce: true } },
52
+ runner: "bun run",
53
+ scripts,
54
+ exec: deps.exec,
55
+ env: deps.env,
56
+ });
57
+ if (entry?.state !== "passed") return 1;
58
+ // dist/ is ignored and the build may regenerate tracked files: ship both,
59
+ // because the marker matches only the tree the build left behind.
60
+ const changed = deps.spawn("git", [
61
+ "ls-files",
62
+ "-m",
63
+ "-o",
64
+ "--exclude-standard",
65
+ "-z",
66
+ ]);
67
+ if (changed.status !== 0) return 1;
68
+ const files = `${changed.stdout}dist\0${BUILD_MARKER_PATH}\0`;
69
+ const packed = deps.spawn(
70
+ "tar",
71
+ ["--null", "-T", "-", "-czf", archive],
72
+ files
73
+ );
74
+ if (packed.status !== 0) return 1;
75
+ deps.out(
76
+ `::notice title=Shared integration build::Built once in ${Math.round(entry.durationMs / 1000)} s; every integration-test shard reuses ${archive}.`
77
+ );
78
+ return 0;
79
+ }
80
+
81
+ /**
82
+ * Unpack the shared build and report whether the marker matches this tree.
83
+ * @param {string} archive - Archive the build job uploaded
84
+ * @param {string | undefined} githubOutput - Step output file
85
+ * @param {Deps} deps - Effects
86
+ * @returns {number} Exit code
87
+ */
88
+ function use(archive, githubOutput, deps) {
89
+ if (deps.spawn("tar", ["-xzf", archive]).status !== 0) return 1;
90
+ const { match, reason } = deps.check({
91
+ env: { ...deps.env, [BUILD_MARKER_ENV]: BUILD_MARKER_PATH },
92
+ });
93
+ deps.out(
94
+ match
95
+ ? `::notice title=Shared integration build::Using the shared build (${reason}); this shard does not run bun run build.`
96
+ : `::warning title=Shared integration build not used::${reason}, so lisa-test-run builds this shard itself.`
97
+ );
98
+ if (githubOutput !== undefined)
99
+ fs.appendFileSync(githubOutput, `marker=${BUILD_MARKER_PATH}\n`);
100
+ return 0;
101
+ }
102
+
103
+ /**
104
+ * CLI entry.
105
+ * @param {ReadonlyArray<string>} argv - Arguments after the script name
106
+ * @param {Deps} deps - Effects
107
+ * @returns {number} Exit code
108
+ */
109
+ export function main(argv, deps) {
110
+ const [command, archive] = argv;
111
+ const at = argv.indexOf("--github-output");
112
+ if (archive === undefined || archive.startsWith("--")) return 2;
113
+ if (command === "build") return build(archive, deps);
114
+ if (command === "use")
115
+ return use(archive, at === -1 ? undefined : argv[at + 1], deps);
116
+ return 2;
117
+ }
118
+
119
+ if (invokedAsScript(import.meta.url)) {
120
+ process.exitCode = main(process.argv.slice(2), {
121
+ exec: command => {
122
+ try {
123
+ execSync(command, { stdio: "inherit" });
124
+ return { code: 0 };
125
+ } catch (error) {
126
+ return { code: error?.status ?? 1 };
127
+ }
128
+ },
129
+ spawn: (command, args, input) => {
130
+ const child = spawnSync(command, [...args], {
131
+ encoding: "utf8",
132
+ input,
133
+ stdio: [input === undefined ? "ignore" : "pipe", "pipe", "inherit"],
134
+ maxBuffer: 64 * 1024 * 1024,
135
+ });
136
+ return { status: child.status, stdout: child.stdout ?? "" };
137
+ },
138
+ check: checkBuildMarker,
139
+ buildOnce: runBuildOnce,
140
+ out: line => console.log(line),
141
+ env: process.env,
142
+ });
143
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The suites that run the genuine pinned history scanner (#4618).
3
+ *
4
+ * `vitest.config.local.ts` puts them in the `history-scanner` project, whose
5
+ * global setup downloads and verifies the pinned scanner once per Vitest
6
+ * invocation that selects one of them. The integration shard planner
7
+ * (`scripts/plan-integration-shards.mjs`, #4599) keeps them in ONE leg, so a
8
+ * sharded run downloads the scanner at most once. One list, read by both, so a
9
+ * suite added to the project cannot be missed by the planner.
10
+ * @module history-scanner-suites
11
+ */
12
+
13
+ /** Repository-relative paths, in no meaningful order. */
14
+ export const HISTORY_SCANNER_SUITES = Object.freeze([
15
+ "tests/integration/history-secret-evidence.test.ts",
16
+ "tests/integration/history-secret-private-report.test.ts",
17
+ "tests/integration/history-secret-scanner-path.test.ts",
18
+ "tests/integration/history-secret-scanner-preparation.test.ts",
19
+ ]);
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Classify one Markdown assertion as STRUCTURAL, MACHINE-TOKEN or WORDING
3
+ * (CodySwannGT/lisa#4867).
4
+ *
5
+ * An assertion is a (file, polarity, kind, value) check — a required or
6
+ * forbidden substring or pattern in a Markdown document. The classes, tried
7
+ * in this order, and every doubt resolves AWAY from WORDING:
8
+ *
9
+ * - STRUCTURAL
10
+ * - frontmatter: the phrase is a `key:` line inside the document's YAML
11
+ * frontmatter;
12
+ * - reference: the phrase is (essentially only) a reference to a skill,
13
+ * command, agent or repository path — required when the target exists
14
+ * (the document's wiring), forbidden when it does not (a stale-
15
+ * reference guard).
16
+ * - MACHINE-TOKEN: the phrase, a heading it names, or a token-shaped part
17
+ * of it (`tokens.mjs`) occurs in the literal text of shipped code
18
+ * (`corpus.mjs`). The first such code file is recorded as the parser.
19
+ * - STRUCTURAL (identifier): failing that, an identifier-shaped token in it
20
+ * (`parseLearningsFile`, `mergeDriver`) is a name shipped code declares —
21
+ * the document points an agent at a real API or config key.
22
+ * - WORDING: everything else — prose an agent reads, which no script or
23
+ * hook consumes. Only this class is deleted.
24
+ * @module scripts/lib/markdown-assertions/classify
25
+ */
26
+ import { existsSync, readdirSync } from "node:fs";
27
+ import path from "node:path";
28
+
29
+ import { patternLiteral, tokenCandidates } from "./tokens.mjs";
30
+
31
+ /** Shortest whole phrase looked up in code verbatim. */
32
+ const MIN_WHOLE_PHRASE = 12;
33
+
34
+ /** Most extra words a reference phrase may carry and still be a reference. */
35
+ const MAX_REFERENCE_EXTRA_WORDS = 3;
36
+
37
+ /** A skill, command or agent reference. */
38
+ const NAME_REFERENCE =
39
+ /(?:^|[\s`"'(/$])[/$]?(lisa[-:][a-z0-9][a-z0-9:-]*[a-z0-9])/gu;
40
+
41
+ /** Repository path references: a directory path, or a bare file name. */
42
+ const PATH_REFERENCES = Object.freeze([
43
+ /(?:^|[\s`"'(])((?:\.?[\w-]+\/)+[\w.-]*\w\/?)(?=$|[\s`"'),.:;])/gu,
44
+ /(?:^|[\s`"'(])([\w-]+\.(?:md|mjs|ts|json|sh|yml|yaml))(?=$|[\s`"'),.:;])/gu,
45
+ ]);
46
+
47
+ /**
48
+ * @typedef {object} Check
49
+ * @property {string} file - Repository-relative Markdown file.
50
+ * @property {"required" | "forbidden"} polarity - Must it be present?
51
+ * @property {"string" | "pattern"} kind - Substring or regular expression.
52
+ * @property {string | { source: string, flags: string }} value - The phrase.
53
+ */
54
+
55
+ /**
56
+ * @typedef {object} Verdict
57
+ * @property {"STRUCTURAL" | "MACHINE-TOKEN" | "WORDING"} class - The class.
58
+ * @property {string} why - One-line reason.
59
+ * @property {string} [parser] - For MACHINE-TOKEN, the code file that reads it.
60
+ * @property {string} [literal] - For MACHINE-TOKEN, the code literal it matched.
61
+ */
62
+
63
+ /**
64
+ * Every skill, command and agent name the repository defines, in the
65
+ * spellings a document may use (`lisa-x`, `lisa:x`, `lisa:a:b`).
66
+ * @param {string} root - Repository root.
67
+ * @returns {Set<string>} Known names.
68
+ */
69
+ export function knownNames(root) {
70
+ const names = new Set();
71
+ const pluginsSrc = path.join(root, "plugins", "src");
72
+ const stacks = existsSync(pluginsSrc) ? readdirSync(pluginsSrc) : [];
73
+ const roots = [
74
+ ...stacks.map(stack => path.join(pluginsSrc, stack)),
75
+ path.join(root, ".claude"),
76
+ path.join(root, ".agents"),
77
+ ];
78
+ for (const base of roots) {
79
+ for (const kind of ["skills", "commands", "agents"]) {
80
+ const dir = path.join(base, kind);
81
+ if (existsSync(dir)) collectNames(dir, "", names);
82
+ }
83
+ }
84
+ return names;
85
+ }
86
+
87
+ /**
88
+ * Add the names under one skills/commands/agents directory.
89
+ * @param {string} dir - Directory.
90
+ * @param {string} prefix - Colon-joined namespace so far.
91
+ * @param {Set<string>} names - Collects names.
92
+ */
93
+ function collectNames(dir, prefix, names) {
94
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
95
+ const stem = entry.name.replace(/\.(?:md|agent\.md|toml)$/u, "");
96
+ const name = prefix ? `${prefix}:${stem}` : stem;
97
+ names.add(name);
98
+ names.add(name.replaceAll(":", "-"));
99
+ names.add(`lisa:${name}`);
100
+ names.add(`lisa-${name.replaceAll(":", "-")}`);
101
+ if (name.startsWith("lisa-")) names.add(`lisa:${name.slice(5)}`);
102
+ if (entry.isDirectory())
103
+ collectNames(path.join(dir, entry.name), name, names);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * The text a check's value spells, for token search.
109
+ * @param {Check} check - The check.
110
+ * @returns {string} Literal text.
111
+ */
112
+ export function literalText(check) {
113
+ return typeof check.value === "string"
114
+ ? check.value
115
+ : patternLiteral(check.value.source);
116
+ }
117
+
118
+ /**
119
+ * The YAML frontmatter block of a document, or undefined.
120
+ * @param {string | undefined} text - Document text.
121
+ * @returns {string | undefined} The block between the `---` fences.
122
+ */
123
+ function frontmatter(text) {
124
+ const match = text
125
+ ? /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(text)
126
+ : null;
127
+ return match?.[1];
128
+ }
129
+
130
+ /**
131
+ * STRUCTURAL by frontmatter, or undefined.
132
+ * @param {Check} check - The check.
133
+ * @param {string | undefined} text - The document's text.
134
+ * @returns {Verdict | undefined} The verdict.
135
+ */
136
+ function frontmatterVerdict(check, text) {
137
+ const block = frontmatter(text);
138
+ if (block === undefined) return undefined;
139
+ const literal = literalText(check).trim();
140
+ if (literal === "---") {
141
+ return { class: "STRUCTURAL", why: "frontmatter fence" };
142
+ }
143
+ const keyLine = /^[\w-]+:/u.test(literal);
144
+ if (!keyLine) return undefined;
145
+ const inBlock =
146
+ typeof check.value === "string"
147
+ ? block.includes(check.value)
148
+ : new RegExp(check.value.source, check.value.flags.replace("g", "")).test(
149
+ block
150
+ );
151
+ return inBlock || check.polarity === "forbidden"
152
+ ? { class: "STRUCTURAL", why: `frontmatter key ${literal.split(":")[0]}` }
153
+ : undefined;
154
+ }
155
+
156
+ /**
157
+ * Words left in a phrase once one reference is taken out.
158
+ * @param {string} literal - The phrase.
159
+ * @param {string} reference - The reference it contains.
160
+ * @returns {number} Remaining word count.
161
+ */
162
+ function extraWords(literal, reference) {
163
+ return literal
164
+ .replace(reference, " ")
165
+ .replaceAll(/[`"'()[\]{}*_.,:;/$\\-]+/gu, " ")
166
+ .trim()
167
+ .split(/\s+/u)
168
+ .filter(Boolean).length;
169
+ }
170
+
171
+ /**
172
+ * STRUCTURAL by reference, or undefined.
173
+ * @param {Check} check - The check.
174
+ * @param {{ root: string, names: Set<string> }} context - Repository facts.
175
+ * @returns {Verdict | undefined} The verdict.
176
+ */
177
+ function referenceVerdict(check, { root, names }) {
178
+ const literal = literalText(check);
179
+ const references = [
180
+ ...[...literal.matchAll(NAME_REFERENCE)].map(m => ({
181
+ text: m[1] ?? "",
182
+ exists: names.has(m[1] ?? ""),
183
+ kind: "name",
184
+ })),
185
+ ...PATH_REFERENCES.flatMap(shape => [...literal.matchAll(shape)]).map(
186
+ m => ({
187
+ text: m[1] ?? "",
188
+ exists: existsSync(path.join(root, m[1] ?? "")),
189
+ kind: "path",
190
+ })
191
+ ),
192
+ ];
193
+ const reference = references.find(
194
+ ref =>
195
+ ref.text && extraWords(literal, ref.text) <= MAX_REFERENCE_EXTRA_WORDS
196
+ );
197
+ if (!reference) return undefined;
198
+ if (check.polarity === "required" && reference.exists) {
199
+ return {
200
+ class: "STRUCTURAL",
201
+ why: `references ${reference.kind} ${reference.text}`,
202
+ };
203
+ }
204
+ if (check.polarity === "forbidden" && !reference.exists) {
205
+ return {
206
+ class: "STRUCTURAL",
207
+ why: `guards a stale ${reference.kind} reference ${reference.text}`,
208
+ };
209
+ }
210
+ return undefined;
211
+ }
212
+
213
+ /**
214
+ * MACHINE-TOKEN by code occurrence, or undefined.
215
+ * @param {Check} check - The check.
216
+ * @param {import("./corpus.mjs").Corpus} corpus - The code corpus.
217
+ * @returns {Verdict | undefined} The verdict.
218
+ */
219
+ function machineTokenVerdict(check, corpus) {
220
+ const literal = literalText(check);
221
+ const heading = /^#{1,6}\s+(.+)$/mu.exec(literal)?.[1]?.trim();
222
+ const wholes = [
223
+ typeof check.value === "string" ? check.value.trim() : undefined,
224
+ heading,
225
+ ].filter(
226
+ /** @returns {whole is string} */ whole =>
227
+ typeof whole === "string" && whole.length >= MIN_WHOLE_PHRASE
228
+ );
229
+ for (const whole of wholes) {
230
+ const parser = corpus.find(whole);
231
+ if (parser)
232
+ return {
233
+ class: "MACHINE-TOKEN",
234
+ why: "phrase is a literal in shipped code",
235
+ parser,
236
+ literal: whole,
237
+ };
238
+ }
239
+ for (const token of tokenCandidates(literal)) {
240
+ const parser = corpus.find(token);
241
+ if (parser)
242
+ return {
243
+ class: "MACHINE-TOKEN",
244
+ why: "token is a literal in shipped code",
245
+ parser,
246
+ literal: token,
247
+ };
248
+ }
249
+ return undefined;
250
+ }
251
+
252
+ /**
253
+ * Classify one check.
254
+ * @param {Check} check - The check.
255
+ * @param {{ root: string, names: Set<string>, corpus: import("./corpus.mjs").Corpus, readText: (file: string) => string | undefined }} context - Repository facts.
256
+ * @returns {Verdict} The verdict.
257
+ */
258
+ export function classifyCheck(check, context) {
259
+ return (
260
+ frontmatterVerdict(check, context.readText(check.file)) ??
261
+ referenceVerdict(check, context) ??
262
+ machineTokenVerdict(check, context.corpus) ??
263
+ identifierVerdict(check, context.corpus) ?? {
264
+ class: "WORDING",
265
+ why: "prose no shipped code reads",
266
+ }
267
+ );
268
+ }
269
+
270
+ /**
271
+ * STRUCTURAL by naming a declared code identifier, or undefined.
272
+ * @param {Check} check - The check.
273
+ * @param {import("./corpus.mjs").Corpus} corpus - The code corpus.
274
+ * @returns {Verdict | undefined} The verdict.
275
+ */
276
+ function identifierVerdict(check, corpus) {
277
+ for (const token of tokenCandidates(literalText(check))) {
278
+ if (!/^[A-Za-z_$][\w$]*$/u.test(token)) continue;
279
+ const declarer = corpus.declares(token);
280
+ if (declarer) {
281
+ return {
282
+ class: "STRUCTURAL",
283
+ why: `names code identifier ${token}`,
284
+ parser: declarer,
285
+ };
286
+ }
287
+ }
288
+ return undefined;
289
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Repository facts the Markdown-assertion classifier needs, built once per
3
+ * run (CodySwannGT/lisa#4867).
4
+ * @module scripts/lib/markdown-assertions/context
5
+ */
6
+ import { readFileSync } from "node:fs";
7
+ import path from "node:path";
8
+
9
+ import { classifyCheck, knownNames } from "./classify.mjs";
10
+ import { buildCorpus } from "./corpus.mjs";
11
+
12
+ /** Document extensions whose assertions are in scope. */
13
+ const MARKDOWN = /\.(?:md|mdc|mdx)$/u;
14
+
15
+ /**
16
+ * Whether a file is a Markdown document (the scope of the cull).
17
+ * @param {string} file - Repository-relative path.
18
+ * @returns {boolean} True for Markdown.
19
+ */
20
+ export function isMarkdown(file) {
21
+ return MARKDOWN.test(file);
22
+ }
23
+
24
+ /**
25
+ * A classifier bound to one checkout. Checks against a non-Markdown file
26
+ * (a hook script, a workflow) pin executable text and are out of the cull's
27
+ * scope; they classify as MACHINE-TOKEN with the file itself as the parser.
28
+ * @param {string} root - Repository root.
29
+ * @returns {(check: import("./classify.mjs").Check) => import("./classify.mjs").Verdict} The classifier.
30
+ */
31
+ export function createClassifier(root) {
32
+ const context = {
33
+ root,
34
+ names: knownNames(root),
35
+ corpus: buildCorpus(root),
36
+ /** @param {string} file - Repository-relative path. */
37
+ readText: file => {
38
+ try {
39
+ return readFileSync(path.join(root, file), "utf8");
40
+ } catch {
41
+ return undefined;
42
+ }
43
+ },
44
+ };
45
+ return check =>
46
+ isMarkdown(check.file)
47
+ ? classifyCheck(check, context)
48
+ : {
49
+ class: "MACHINE-TOKEN",
50
+ why: "target is executable code, not Markdown",
51
+ parser: check.file,
52
+ };
53
+ }