@whaaaley/crush 0.0.0-stage → 0.2.7

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 (358) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +185 -2
  3. package/SKILL.md +187 -0
  4. package/THIRD_PARTY_NOTICES.md +277 -0
  5. package/dist/capture/capture.operations.d.ts +23 -0
  6. package/dist/capture/capture.operations.js +231 -0
  7. package/dist/capture/capture.schema.d.ts +73 -0
  8. package/dist/capture/capture.schema.js +28 -0
  9. package/dist/collapse/collapse.operations.d.ts +2 -0
  10. package/dist/collapse/collapse.operations.js +82 -0
  11. package/dist/collapse/collapse.schema.d.ts +40 -0
  12. package/dist/collapse/collapse.schema.js +35 -0
  13. package/dist/crush.tables.d.ts +3583 -0
  14. package/dist/crush.tables.js +456 -0
  15. package/dist/crushes/callback.crush.d.ts +2 -0
  16. package/dist/crushes/callback.crush.js +19 -0
  17. package/dist/crushes/crush.d.ts +36 -0
  18. package/dist/crushes/crush.js +12 -0
  19. package/dist/crushes/crush.names.d.ts +1 -0
  20. package/dist/crushes/crush.names.js +2 -0
  21. package/dist/crushes/crushes.d.ts +2 -0
  22. package/dist/crushes/crushes.js +9 -0
  23. package/dist/crushes/default-value.crush.d.ts +2 -0
  24. package/dist/crushes/default-value.crush.js +29 -0
  25. package/dist/crushes/drop-operand.crush.d.ts +2 -0
  26. package/dist/crushes/drop-operand.crush.js +37 -0
  27. package/dist/crushes/fold.d.ts +64 -0
  28. package/dist/crushes/fold.js +366 -0
  29. package/dist/crushes/force-fork.crush.d.ts +2 -0
  30. package/dist/crushes/force-fork.crush.js +79 -0
  31. package/dist/crushes/loop-once.crush.d.ts +2 -0
  32. package/dist/crushes/loop-once.crush.js +71 -0
  33. package/dist/crushes/optional-chain.crush.d.ts +2 -0
  34. package/dist/crushes/optional-chain.crush.js +30 -0
  35. package/dist/crushes/switch-case.crush.d.ts +2 -0
  36. package/dist/crushes/switch-case.crush.js +19 -0
  37. package/dist/decisions/decide.d.ts +61 -0
  38. package/dist/decisions/decide.js +161 -0
  39. package/dist/decisions/decisions.d.ts +24 -0
  40. package/dist/decisions/decisions.js +62 -0
  41. package/dist/decisions/forks.decision.d.ts +4 -0
  42. package/dist/decisions/forks.decision.js +32 -0
  43. package/dist/decisions/kinds.d.ts +101 -0
  44. package/dist/decisions/kinds.js +38 -0
  45. package/dist/decisions/loops.decision.d.ts +4 -0
  46. package/dist/decisions/loops.decision.js +39 -0
  47. package/dist/decisions/shorts.decision.d.ts +3 -0
  48. package/dist/decisions/shorts.decision.js +66 -0
  49. package/dist/decisions/switches.decision.d.ts +3 -0
  50. package/dist/decisions/switches.decision.js +20 -0
  51. package/dist/decisions/throws.decision.d.ts +3 -0
  52. package/dist/decisions/throws.decision.js +35 -0
  53. package/dist/decisions/values.decision.d.ts +3 -0
  54. package/dist/decisions/values.decision.js +67 -0
  55. package/dist/explore/edges/explore.d.ts +60 -0
  56. package/dist/explore/edges/explore.db.d.ts +22 -0
  57. package/dist/explore/edges/explore.db.js +55 -0
  58. package/dist/explore/edges/explore.js +305 -0
  59. package/dist/explore/edges/random.d.ts +2 -0
  60. package/dist/explore/edges/random.js +32 -0
  61. package/dist/explore/explore.operations.d.ts +30 -0
  62. package/dist/explore/explore.operations.js +117 -0
  63. package/dist/explore/limits.operations.d.ts +14 -0
  64. package/dist/explore/limits.operations.js +20 -0
  65. package/dist/explore/targets.operations.d.ts +36 -0
  66. package/dist/explore/targets.operations.js +32 -0
  67. package/dist/explore/utils/draws.d.ts +6 -0
  68. package/dist/explore/utils/draws.js +2 -0
  69. package/dist/explore/utils/edits.d.ts +15 -0
  70. package/dist/explore/utils/edits.js +151 -0
  71. package/dist/explore/utils/guide.d.ts +23 -0
  72. package/dist/explore/utils/guide.js +35 -0
  73. package/dist/explore/utils/keep.d.ts +10 -0
  74. package/dist/explore/utils/keep.js +61 -0
  75. package/dist/explore/utils/pools.d.ts +17 -0
  76. package/dist/explore/utils/pools.js +121 -0
  77. package/dist/explore/utils/reads.d.ts +19 -0
  78. package/dist/explore/utils/reads.js +118 -0
  79. package/dist/explore/utils/twin.d.ts +21 -0
  80. package/dist/explore/utils/twin.js +55 -0
  81. package/dist/forks/forks.operations.d.ts +32 -0
  82. package/dist/forks/forks.operations.js +134 -0
  83. package/dist/forks/forks.schema.d.ts +20 -0
  84. package/dist/forks/forks.schema.js +14 -0
  85. package/dist/graph/cfg/cfg.d.ts +28 -0
  86. package/dist/graph/cfg/cfg.js +31 -0
  87. package/dist/graph/cfg/code-paths/analyzer.d.ts +27 -0
  88. package/dist/graph/cfg/code-paths/analyzer.js +358 -0
  89. package/dist/graph/cfg/code-paths/segments.d.ts +44 -0
  90. package/dist/graph/cfg/code-paths/segments.js +105 -0
  91. package/dist/graph/cfg/code-paths/state.d.ts +121 -0
  92. package/dist/graph/cfg/code-paths/state.js +611 -0
  93. package/dist/graph/cfg/entries.d.ts +13 -0
  94. package/dist/graph/cfg/entries.js +120 -0
  95. package/dist/graph/cfg/functions.d.ts +6 -0
  96. package/dist/graph/cfg/functions.js +47 -0
  97. package/dist/graph/cfg/paths.d.ts +27 -0
  98. package/dist/graph/cfg/paths.js +91 -0
  99. package/dist/graph/cfg/scopes/scopes.d.ts +40 -0
  100. package/dist/graph/cfg/scopes/scopes.js +375 -0
  101. package/dist/graph/symbols/file.d.ts +90 -0
  102. package/dist/graph/symbols/file.js +427 -0
  103. package/dist/graph/symbols/keys.d.ts +13 -0
  104. package/dist/graph/symbols/keys.js +22 -0
  105. package/dist/graph/symbols/resolve.operations.d.ts +4 -0
  106. package/dist/graph/symbols/resolve.operations.js +33 -0
  107. package/dist/graph/symbols/symbols.d.ts +12 -0
  108. package/dist/graph/symbols/symbols.js +155 -0
  109. package/dist/graph/symbols/symbols.schema.d.ts +32 -0
  110. package/dist/graph/symbols/symbols.schema.js +19 -0
  111. package/dist/graph/unused/tests.d.ts +7 -0
  112. package/dist/graph/unused/tests.js +95 -0
  113. package/dist/graph/unused/unused.d.ts +53 -0
  114. package/dist/graph/unused/unused.js +319 -0
  115. package/dist/graph/walk/walk.d.ts +7 -0
  116. package/dist/graph/walk/walk.js +39 -0
  117. package/dist/instrument/instrument.operations.d.ts +72 -0
  118. package/dist/instrument/instrument.operations.js +786 -0
  119. package/dist/instrument/instrument.schema.d.ts +257 -0
  120. package/dist/instrument/instrument.schema.js +100 -0
  121. package/dist/judge/counters.d.ts +86 -0
  122. package/dist/judge/counters.js +402 -0
  123. package/dist/judge/edges/api.d.ts +14 -0
  124. package/dist/judge/edges/api.js +80 -0
  125. package/dist/judge/edges/completion.reporter.d.ts +9 -0
  126. package/dist/judge/edges/completion.reporter.js +51 -0
  127. package/dist/judge/edges/hints.reporter.d.ts +13 -0
  128. package/dist/judge/edges/hints.reporter.js +29 -0
  129. package/dist/judge/edges/judge.edges.d.ts +52 -0
  130. package/dist/judge/edges/judge.edges.js +59 -0
  131. package/dist/judge/edges/judge.fs.d.ts +8 -0
  132. package/dist/judge/edges/judge.fs.js +45 -0
  133. package/dist/judge/edges/merge.d.ts +11 -0
  134. package/dist/judge/edges/merge.js +60 -0
  135. package/dist/judge/edges/plugin.d.ts +132 -0
  136. package/dist/judge/edges/plugin.js +441 -0
  137. package/dist/judge/edges/reach.d.ts +68 -0
  138. package/dist/judge/edges/reach.js +132 -0
  139. package/dist/judge/edges/speed.d.ts +32 -0
  140. package/dist/judge/edges/speed.js +34 -0
  141. package/dist/judge/edges/strays.d.ts +1 -0
  142. package/dist/judge/edges/strays.js +14 -0
  143. package/dist/judge/edges/vitest.d.ts +20 -0
  144. package/dist/judge/edges/vitest.js +36 -0
  145. package/dist/judge/edges/vitest.schema.d.ts +14 -0
  146. package/dist/judge/edges/vitest.schema.js +16 -0
  147. package/dist/judge/explore.test.d.ts +1 -0
  148. package/dist/judge/explore.test.js +101 -0
  149. package/dist/judge/hints.d.ts +11 -0
  150. package/dist/judge/hints.js +44 -0
  151. package/dist/judge/judge.operations.d.ts +218 -0
  152. package/dist/judge/judge.operations.js +464 -0
  153. package/dist/judge/judge.schema.d.ts +135 -0
  154. package/dist/judge/judge.schema.js +129 -0
  155. package/dist/judge/judge.shard-1.test.d.ts +1 -0
  156. package/dist/judge/judge.shard-1.test.js +3 -0
  157. package/dist/judge/judge.shard-2.test.d.ts +1 -0
  158. package/dist/judge/judge.shard-2.test.js +3 -0
  159. package/dist/judge/judge.test.d.ts +1 -0
  160. package/dist/judge/judge.test.js +3 -0
  161. package/dist/judge/refusals.d.ts +14 -0
  162. package/dist/judge/refusals.js +10 -0
  163. package/dist/judge/report.test.d.ts +1 -0
  164. package/dist/judge/report.test.js +432 -0
  165. package/dist/judge/runner.d.ts +3 -0
  166. package/dist/judge/runner.js +1602 -0
  167. package/dist/judge/stresses.test.d.ts +1 -0
  168. package/dist/judge/stresses.test.js +12 -0
  169. package/dist/judge/task-meta.d.ts +14 -0
  170. package/dist/judge/task-meta.js +1 -0
  171. package/dist/justify/edges/load.d.ts +7 -0
  172. package/dist/justify/edges/load.js +40 -0
  173. package/dist/justify/edges/refresh.fs.d.ts +8 -0
  174. package/dist/justify/edges/refresh.fs.js +15 -0
  175. package/dist/justify/justify.operations.d.ts +46 -0
  176. package/dist/justify/justify.operations.js +80 -0
  177. package/dist/justify/justify.schema.d.ts +21 -0
  178. package/dist/justify/justify.schema.js +11 -0
  179. package/dist/mutators/arithmetic-operator.mutator.d.ts +2 -0
  180. package/dist/mutators/arithmetic-operator.mutator.js +22 -0
  181. package/dist/mutators/array-declaration.mutator.d.ts +2 -0
  182. package/dist/mutators/array-declaration.mutator.js +12 -0
  183. package/dist/mutators/arrow-function.mutator.d.ts +2 -0
  184. package/dist/mutators/arrow-function.mutator.js +10 -0
  185. package/dist/mutators/assignment-operator.mutator.d.ts +2 -0
  186. package/dist/mutators/assignment-operator.mutator.js +29 -0
  187. package/dist/mutators/await-expression.mutator.d.ts +2 -0
  188. package/dist/mutators/await-expression.mutator.js +7 -0
  189. package/dist/mutators/bitwise-operator.mutator.d.ts +2 -0
  190. package/dist/mutators/bitwise-operator.mutator.js +19 -0
  191. package/dist/mutators/block-statement.mutator.d.ts +2 -0
  192. package/dist/mutators/block-statement.mutator.js +30 -0
  193. package/dist/mutators/boolean-literal.mutator.d.ts +2 -0
  194. package/dist/mutators/boolean-literal.mutator.js +5 -0
  195. package/dist/mutators/coercion.mutator.d.ts +2 -0
  196. package/dist/mutators/coercion.mutator.js +28 -0
  197. package/dist/mutators/conditional-expression.mutator.d.ts +2 -0
  198. package/dist/mutators/conditional-expression.mutator.js +36 -0
  199. package/dist/mutators/disposal.mutator.d.ts +2 -0
  200. package/dist/mutators/disposal.mutator.js +13 -0
  201. package/dist/mutators/empty-destructuring.mutator.d.ts +2 -0
  202. package/dist/mutators/empty-destructuring.mutator.js +35 -0
  203. package/dist/mutators/empty-return.mutator.d.ts +2 -0
  204. package/dist/mutators/empty-return.mutator.js +35 -0
  205. package/dist/mutators/equality-operator.mutator.d.ts +2 -0
  206. package/dist/mutators/equality-operator.mutator.js +16 -0
  207. package/dist/mutators/loop-exit.mutator.d.ts +2 -0
  208. package/dist/mutators/loop-exit.mutator.js +5 -0
  209. package/dist/mutators/method-expression.mutator.d.ts +2 -0
  210. package/dist/mutators/method-expression.mutator.js +59 -0
  211. package/dist/mutators/missing-lookup.mutator.d.ts +2 -0
  212. package/dist/mutators/missing-lookup.mutator.js +25 -0
  213. package/dist/mutators/mutator.d.ts +40 -0
  214. package/dist/mutators/mutator.js +49 -0
  215. package/dist/mutators/mutator.names.d.ts +3 -0
  216. package/dist/mutators/mutator.names.js +43 -0
  217. package/dist/mutators/mutators.d.ts +8 -0
  218. package/dist/mutators/mutators.js +84 -0
  219. package/dist/mutators/nested-condition.mutator.d.ts +2 -0
  220. package/dist/mutators/nested-condition.mutator.js +16 -0
  221. package/dist/mutators/number-literal.mutator.d.ts +3 -0
  222. package/dist/mutators/number-literal.mutator.js +13 -0
  223. package/dist/mutators/object-literal.mutator.d.ts +2 -0
  224. package/dist/mutators/object-literal.mutator.js +6 -0
  225. package/dist/mutators/odd-number.mutator.d.ts +2 -0
  226. package/dist/mutators/odd-number.mutator.js +15 -0
  227. package/dist/mutators/operand-deletion.mutator.d.ts +2 -0
  228. package/dist/mutators/operand-deletion.mutator.js +9 -0
  229. package/dist/mutators/outcome.mutator.d.ts +3 -0
  230. package/dist/mutators/outcome.mutator.js +45 -0
  231. package/dist/mutators/plain-assignment.mutator.d.ts +2 -0
  232. package/dist/mutators/plain-assignment.mutator.js +7 -0
  233. package/dist/mutators/power-operator.mutator.d.ts +2 -0
  234. package/dist/mutators/power-operator.mutator.js +13 -0
  235. package/dist/mutators/private-brand.mutator.d.ts +2 -0
  236. package/dist/mutators/private-brand.mutator.js +7 -0
  237. package/dist/mutators/regex.mutator.d.ts +2 -0
  238. package/dist/mutators/regex.mutator.js +29 -0
  239. package/dist/mutators/short-iteration.mutator.d.ts +2 -0
  240. package/dist/mutators/short-iteration.mutator.js +8 -0
  241. package/dist/mutators/string-literal.mutator.d.ts +3 -0
  242. package/dist/mutators/string-literal.mutator.js +149 -0
  243. package/dist/mutators/switch-default.mutator.d.ts +2 -0
  244. package/dist/mutators/switch-default.mutator.js +13 -0
  245. package/dist/mutators/sync-iteration.mutator.d.ts +3 -0
  246. package/dist/mutators/sync-iteration.mutator.js +9 -0
  247. package/dist/mutators/thrown-call.mutator.d.ts +2 -0
  248. package/dist/mutators/thrown-call.mutator.js +7 -0
  249. package/dist/mutators/unary-operator.mutator.d.ts +2 -0
  250. package/dist/mutators/unary-operator.mutator.js +18 -0
  251. package/dist/mutators/unbound-call.mutator.d.ts +2 -0
  252. package/dist/mutators/unbound-call.mutator.js +14 -0
  253. package/dist/mutators/update-operator.mutator.d.ts +2 -0
  254. package/dist/mutators/update-operator.mutator.js +15 -0
  255. package/dist/mutators/yield-value.mutator.d.ts +2 -0
  256. package/dist/mutators/yield-value.mutator.js +7 -0
  257. package/dist/parity/compare.d.ts +27 -0
  258. package/dist/parity/compare.js +26 -0
  259. package/dist/parity/corpus.parity.d.ts +1 -0
  260. package/dist/parity/corpus.parity.js +97 -0
  261. package/dist/parity/edges/corpus.fs.d.ts +3 -0
  262. package/dist/parity/edges/corpus.fs.js +30 -0
  263. package/dist/parity/edges/ports.d.ts +2 -0
  264. package/dist/parity/edges/ports.js +21 -0
  265. package/dist/parity/edges/vitest.d.ts +2 -0
  266. package/dist/parity/edges/vitest.js +3 -0
  267. package/dist/parity/parity.operations.d.ts +33 -0
  268. package/dist/parity/parity.operations.js +60 -0
  269. package/dist/parity/parity.schema.d.ts +5 -0
  270. package/dist/parity/parity.schema.js +6 -0
  271. package/dist/parity/stryker/compare.d.ts +14 -0
  272. package/dist/parity/stryker/compare.js +52 -0
  273. package/dist/parity/stryker/edges/ports.d.ts +12 -0
  274. package/dist/parity/stryker/edges/ports.js +28 -0
  275. package/dist/parity/stryker/equivalence.d.ts +1 -0
  276. package/dist/parity/stryker/equivalence.js +42 -0
  277. package/dist/parity/stryker/intended.d.ts +29 -0
  278. package/dist/parity/stryker/intended.js +152 -0
  279. package/dist/parity/stryker/normalize.d.ts +27 -0
  280. package/dist/parity/stryker/normalize.js +181 -0
  281. package/dist/parity/stryker/rules.d.ts +6 -0
  282. package/dist/parity/stryker/rules.js +116 -0
  283. package/dist/parity/stryker/sides.d.ts +46 -0
  284. package/dist/parity/stryker/sides.js +199 -0
  285. package/dist/parity/stryker/stryker.parity.d.ts +1 -0
  286. package/dist/parity/stryker/stryker.parity.js +147 -0
  287. package/dist/parity/stryker/stryker.schema.d.ts +6 -0
  288. package/dist/parity/stryker/stryker.schema.js +7 -0
  289. package/dist/parity/views.d.ts +21 -0
  290. package/dist/parity/views.js +119 -0
  291. package/dist/questions/questions.operations.d.ts +110 -0
  292. package/dist/questions/questions.operations.js +446 -0
  293. package/dist/questions/questions.schema.d.ts +57 -0
  294. package/dist/questions/questions.schema.js +28 -0
  295. package/dist/record/edges/calls.db.d.ts +10 -0
  296. package/dist/record/edges/calls.db.js +91 -0
  297. package/dist/record/edges/hits.db.d.ts +3 -0
  298. package/dist/record/edges/hits.db.js +5 -0
  299. package/dist/record/edges/holds.db.d.ts +4 -0
  300. package/dist/record/edges/holds.db.js +31 -0
  301. package/dist/record/edges/judged-state.db.d.ts +5 -0
  302. package/dist/record/edges/judged-state.db.js +25 -0
  303. package/dist/record/edges/markers.db.d.ts +11 -0
  304. package/dist/record/edges/markers.db.js +55 -0
  305. package/dist/record/edges/merge.db.d.ts +7 -0
  306. package/dist/record/edges/merge.db.js +46 -0
  307. package/dist/record/edges/parts.db.d.ts +42 -0
  308. package/dist/record/edges/parts.db.js +389 -0
  309. package/dist/record/edges/parts.edges.d.ts +2 -0
  310. package/dist/record/edges/parts.edges.js +7 -0
  311. package/dist/record/edges/parts.fs.d.ts +1 -0
  312. package/dist/record/edges/parts.fs.js +11 -0
  313. package/dist/record/edges/parts.writer.d.ts +1 -0
  314. package/dist/record/edges/parts.writer.js +85 -0
  315. package/dist/record/edges/passes.db.d.ts +19 -0
  316. package/dist/record/edges/passes.db.js +31 -0
  317. package/dist/record/edges/plan.db.d.ts +21 -0
  318. package/dist/record/edges/plan.db.js +174 -0
  319. package/dist/record/edges/reach.db.d.ts +6 -0
  320. package/dist/record/edges/reach.db.js +62 -0
  321. package/dist/record/edges/record.db.d.ts +22 -0
  322. package/dist/record/edges/record.db.js +176 -0
  323. package/dist/record/edges/record.fs.d.ts +3 -0
  324. package/dist/record/edges/record.fs.js +7 -0
  325. package/dist/record/edges/site-verdicts.db.d.ts +11 -0
  326. package/dist/record/edges/site-verdicts.db.js +66 -0
  327. package/dist/record/edges/verified.db.d.ts +7 -0
  328. package/dist/record/edges/verified.db.js +71 -0
  329. package/dist/record/parts.operations.d.ts +26 -0
  330. package/dist/record/parts.operations.js +31 -0
  331. package/dist/record/path-checks.operations.d.ts +15 -0
  332. package/dist/record/path-checks.operations.js +84 -0
  333. package/dist/record/record.operations.d.ts +36 -0
  334. package/dist/record/record.operations.js +11 -0
  335. package/dist/stresses/edges/stresses.record.d.ts +4 -0
  336. package/dist/stresses/edges/stresses.record.js +37 -0
  337. package/dist/stresses/stresses.operations.d.ts +28 -0
  338. package/dist/stresses/stresses.operations.js +22 -0
  339. package/dist/utils/ast.d.ts +55 -0
  340. package/dist/utils/ast.js +181 -0
  341. package/dist/utils/errors.d.ts +8 -0
  342. package/dist/utils/errors.js +12 -0
  343. package/dist/utils/faults.d.ts +6 -0
  344. package/dist/utils/faults.js +10 -0
  345. package/dist/utils/lookup.d.ts +4 -0
  346. package/dist/utils/lookup.js +27 -0
  347. package/dist/utils/order.d.ts +2 -0
  348. package/dist/utils/order.js +17 -0
  349. package/dist/utils/retry.d.ts +14 -0
  350. package/dist/utils/retry.js +15 -0
  351. package/dist/utils/safe.d.ts +11 -0
  352. package/dist/utils/safe.js +31 -0
  353. package/migrations/main/20261129123324_initial/migration.sql +418 -0
  354. package/migrations/main/20261129123324_initial/snapshot.json +3641 -0
  355. package/package.json +89 -4
  356. package/references/consumer-setup.md +92 -0
  357. package/src/graph/cfg/code-paths/LICENSE +21 -0
  358. package/src/graph/cfg/scopes/LICENSE +24 -0
@@ -0,0 +1,456 @@
1
+ import { sql } from 'drizzle-orm';
2
+ import { check, index, integer, primaryKey, sqliteTableCreator, text, uniqueIndex } from 'drizzle-orm/sqlite-core';
3
+ import { crushNames } from './crushes/crush.names.js';
4
+ import { kinds } from './decisions/kinds.js';
5
+ import { mutatorNames, pluginMutatorName } from './mutators/mutator.names.js';
6
+ // The values each enum column holds, which its check constraint and any zod schema both build from.
7
+ export const forkSides = ['true', 'false'];
8
+ export const sides = ['true', 'false', 'repeat', 'case', 'default', 'absent', 'present', 'reached'];
9
+ // An unjudged site was reached after a mutant left the module state broken or under a plan a changed source made stale, so no rerun there could be trusted.
10
+ export const statuses = ['caught', 'survived', 'unjudged', 'unreached'];
11
+ export const forcings = ['true', 'false', 'once'];
12
+ const decisionKinds = kinds.map(({ kind }) => kind);
13
+ export const reachKinds = ['file', 'export', 'binding', 'function'];
14
+ export const reachAsks = ['none', 'remove', 'unexport', 'test', 'tests'];
15
+ export const callOutcomes = ['returned', 'threw', 'promised'];
16
+ // The judge command's passes, each of which every shard ends before any shard starts the next.
17
+ export const judgePasses = ['plan', 'judge', 'parts', 'merge', 'verify'];
18
+ // Drizzle 1.0 sets column casing per table builder, so property names become snake_case columns.
19
+ const sqliteTable = sqliteTableCreator((name) => name, 'snake_case');
20
+ const enumConstraint = (name, column, values) => {
21
+ const formattedValues = `'${values.join("', '")}'`;
22
+ return check(name, sql `${column} in (${sql.raw(formattedValues)})`);
23
+ };
24
+ // One row: the record version, so a record of another version is deleted and rebuilt, never migrated.
25
+ export const meta = sqliteTable('meta', {
26
+ version: text().primaryKey(),
27
+ createdAt: integer({ mode: 'timestamp_ms' }).notNull(),
28
+ });
29
+ // Every site and fork point the plan names, by an id each row about it references, so its long key is stored once.
30
+ // A plan row never outlives its site, since `setPlan` deletes every plan row with its source before it deletes a site, so plan rows reference sites without a cascade.
31
+ // A plan drops the sites it no longer names, and their hits, verdicts, candidates and holds go with them.
32
+ export const sites = sqliteTable('sites', {
33
+ id: integer().primaryKey(),
34
+ siteKey: text().notNull().unique(),
35
+ });
36
+ // Each source the plugin planned, in the path order its counters are numbered in.
37
+ export const sources = sqliteTable('sources', {
38
+ id: integer().primaryKey(),
39
+ path: text().notNull().unique(),
40
+ hash: text().notNull(),
41
+ // The sites planning left out of the source: those the settings exclude, and those repeating another site or a crush.
42
+ excluded: integer().notNull(),
43
+ overlap: integer().notNull(),
44
+ });
45
+ // Each fork counter of a planned source.
46
+ export const planPoints = sqliteTable('plan_points', {
47
+ id: integer().primaryKey(),
48
+ source: integer().notNull().references(() => sources.id, { onDelete: 'cascade' }),
49
+ site: integer().notNull().references(() => sites.id),
50
+ counter: integer().notNull(),
51
+ decision: text().notNull(),
52
+ kind: text().notNull(),
53
+ }, (table) => [
54
+ enumConstraint('plan_points_kind_check', table.kind, decisionKinds),
55
+ uniqueIndex('plan_points_source_counter_unique').on(table.source, table.counter),
56
+ index('plan_points_site_idx').on(table.site),
57
+ ]);
58
+ // Each mutator switch of a planned source.
59
+ export const planSwitches = sqliteTable('plan_switches', {
60
+ id: integer().primaryKey(),
61
+ source: integer().notNull().references(() => sources.id, { onDelete: 'cascade' }),
62
+ site: integer().notNull().references(() => sites.id),
63
+ counter: integer().notNull(),
64
+ mutator: text().notNull(),
65
+ owner: text().notNull(),
66
+ code: text().notNull(),
67
+ replacement: text().notNull(),
68
+ startAt: integer().notNull(),
69
+ line: integer().notNull(),
70
+ }, (table) => [
71
+ enumConstraint('plan_switches_mutator_check', table.mutator, [...mutatorNames, pluginMutatorName]),
72
+ index('plan_switches_source_idx').on(table.source),
73
+ uniqueIndex('plan_switches_site_unique').on(table.site),
74
+ ]);
75
+ // Each crush site of a planned source.
76
+ export const planCrushes = sqliteTable('plan_crushes', {
77
+ id: integer().primaryKey(),
78
+ source: integer().notNull().references(() => sources.id, { onDelete: 'cascade' }),
79
+ site: integer().notNull().references(() => sites.id),
80
+ crush: text().notNull(),
81
+ decision: text().notNull(),
82
+ side: text({ enum: sides }).notNull(),
83
+ point: integer().notNull(),
84
+ startAt: integer().notNull(),
85
+ endAt: integer().notNull(),
86
+ forced: text({ enum: forcings }).notNull(),
87
+ skips: integer({ mode: 'boolean' }).notNull(),
88
+ forcedEffect: text({ mode: 'json' }).$type(),
89
+ owner: text().notNull(),
90
+ code: text().notNull(),
91
+ line: integer().notNull(),
92
+ }, (table) => [
93
+ enumConstraint('plan_crushes_crush_check', table.crush, crushNames),
94
+ enumConstraint('plan_crushes_side_check', table.side, sides),
95
+ enumConstraint('plan_crushes_forced_check', table.forced, forcings),
96
+ index('plan_crushes_source_idx').on(table.source),
97
+ uniqueIndex('plan_crushes_site_unique').on(table.site),
98
+ ]);
99
+ // Each edit a planned crush makes at the source's original offsets.
100
+ export const planCrushEdits = sqliteTable('plan_crush_edits', {
101
+ id: integer().primaryKey(),
102
+ crush: integer().notNull().references(() => planCrushes.id, { onDelete: 'cascade' }),
103
+ startAt: integer().notNull(),
104
+ endAt: integer().notNull(),
105
+ replacement: text().notNull(),
106
+ }, (table) => [
107
+ index('plan_crush_edits_crush_idx').on(table.crush),
108
+ ]);
109
+ // Each dedent a planned crush's edits leave: the lines it spans and the columns it takes off them.
110
+ export const planCrushDedents = sqliteTable('plan_crush_dedents', {
111
+ id: integer().primaryKey(),
112
+ crush: integer().notNull().references(() => planCrushes.id, { onDelete: 'cascade' }),
113
+ startAt: integer().notNull(),
114
+ endAt: integer().notNull(),
115
+ width: integer().notNull(),
116
+ }, (table) => [
117
+ index('plan_crush_dedents_crush_idx').on(table.crush),
118
+ ]);
119
+ // Each test file the plugin planned, which marks its functions entered but is never mutated.
120
+ export const planTests = sqliteTable('plan_tests', {
121
+ path: text().primaryKey(),
122
+ hash: text().notNull(),
123
+ metadataHash: text(),
124
+ });
125
+ // Each planned file's instrumented code under the key of the whole plan it came from, so a record of an unchanged project serves the code without planning again.
126
+ export const planCodes = sqliteTable('plan_codes', {
127
+ path: text().primaryKey(),
128
+ planKey: text().notNull(),
129
+ hash: text().notNull(),
130
+ code: text().notNull(),
131
+ });
132
+ // Each unit of a planned source or test file, by the counter its entry mark answers to: its top level, named '', or one of its functions, with the hash of its own text.
133
+ export const planUnits = sqliteTable('plan_units', {
134
+ counter: integer().primaryKey(),
135
+ path: text().notNull(),
136
+ name: text().notNull(),
137
+ hash: text().notNull(),
138
+ });
139
+ // The units one test file's run entered, in the order first entered, under the generation of the run that entered them; a verdict reads a first stretch of one generation.
140
+ // The file is named by path, as a saved-as-it-goes verdict names it before its part exists, and a part's write removes every generation its verdicts no longer read.
141
+ export const readSequences = sqliteTable('read_sequences', {
142
+ testFile: text().notNull(),
143
+ generation: integer().notNull(),
144
+ position: integer().notNull(),
145
+ unit: text().notNull(),
146
+ }, (table) => [
147
+ primaryKey({ columns: [table.testFile, table.generation, table.position] }),
148
+ ]);
149
+ // Each test file still working in a phase, which the next phase waits on.
150
+ export const working = sqliteTable('working', {
151
+ name: text().primaryKey(),
152
+ });
153
+ // Each shard of the judge command that ended a pass, with why it failed, so the other shards wait for it and stop with its failure.
154
+ export const passesEnded = sqliteTable('passes_ended', {
155
+ pass: text({ enum: judgePasses }).notNull(),
156
+ shard: integer().notNull(),
157
+ failure: text(),
158
+ }, (table) => [
159
+ enumConstraint('passes_ended_pass_check', table.pass, judgePasses),
160
+ primaryKey({ columns: [table.pass, table.shard] }),
161
+ ]);
162
+ // Each test file its worker last judged: its hash, the basis of staleness and verdict reuse, and how many verdicts it reused.
163
+ export const testFiles = sqliteTable('test_files', {
164
+ id: integer().primaryKey(),
165
+ path: text().notNull().unique(),
166
+ hash: text().notNull(),
167
+ reused: integer().notNull(),
168
+ // Why the file failed outside its tests.
169
+ failure: text(),
170
+ justifications: text({ mode: 'json' }).$type(),
171
+ });
172
+ // Each source a test file's last run loaded, with the hash of the text it loaded, so a partial record reruns that file once any of them changed.
173
+ export const testFileReads = sqliteTable('test_file_reads', {
174
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
175
+ path: text().notNull(),
176
+ hash: text().notNull(),
177
+ }, (table) => [
178
+ primaryKey({ columns: [table.testFile, table.path] }),
179
+ ]);
180
+ // The test file judging each source a test file's last run reached, as that run found it, which a partial record compares with the assignment now.
181
+ export const partAssignees = sqliteTable('part_assignees', {
182
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
183
+ source: text().notNull(),
184
+ assignee: text().notNull(),
185
+ }, (table) => [
186
+ primaryKey({ columns: [table.testFile, table.source] }),
187
+ ]);
188
+ // Each site's one verdict from every test file's riders, with the basis it rests on, which a later judge reuses while the basis holds.
189
+ export const siteVerdicts = sqliteTable('site_verdicts', {
190
+ site: integer().primaryKey().references(() => sites.id, { onDelete: 'cascade' }),
191
+ status: text({ enum: statuses }).notNull(),
192
+ catcherKey: text(),
193
+ backupKey: text(),
194
+ reruns: integer().notNull(),
195
+ basisHash: text().notNull(),
196
+ // The test file whose part holds the verdict, its catcher's or, where none caught it, its first rider's, or null for a site no test reached.
197
+ ownerFile: text(),
198
+ // Every function and source top level the verdict's reruns and its riders' baselines read, by unit key, and the hash of their text when it was judged, so an edit to any other code keeps it.
199
+ readUnits: text().notNull(),
200
+ readsHash: text().notNull(),
201
+ // Whether this run reused the verdict rather than judging it, which its part reports.
202
+ isReused: integer({ mode: 'boolean' }).notNull(),
203
+ // Whether the backups command searched a caught verdict's other groups for a backup, so a missing one means none rather than not yet looked for.
204
+ isBackupSearched: integer({ mode: 'boolean' }).notNull(),
205
+ }, (table) => [enumConstraint('site_verdicts_status_check', table.status, statuses)]);
206
+ // Each test's baseline run, by its file and the titles Vitest names it by.
207
+ export const testRuns = sqliteTable('test_runs', {
208
+ id: integer().primaryKey(),
209
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
210
+ testKey: text().notNull().unique(),
211
+ name: text({ mode: 'json' }).$type(),
212
+ passed: integer({ mode: 'boolean' }).notNull(),
213
+ failure: text(),
214
+ steps: integer().notNull(),
215
+ // The count and reason the test's `{ meta: { steps, stepsReason } }` states, null where it states none.
216
+ statedSteps: integer(),
217
+ stepsReason: text(),
218
+ // Whether two of the test's reruns with nothing forced did the same work, which a step count needs to hold.
219
+ isSteady: integer({ mode: 'boolean' }).notNull(),
220
+ ticks: integer().notNull(),
221
+ ns: integer().notNull(),
222
+ answers: text(),
223
+ keeps: text(),
224
+ // Whether a test that passed failed its rerun with nothing forced, so it judges no site.
225
+ rerunFailed: integer({ mode: 'boolean' }).notNull(),
226
+ }, (table) => [
227
+ index('test_runs_test_file_idx').on(table.testFile),
228
+ ]);
229
+ // Which test took which side of which site, keyed test first so a part's rewrite deletes its hits by the one key it keeps.
230
+ // The site holds no foreign key, since one would need a second index on the largest table, so `setPlan` deletes a dropped site's hits itself.
231
+ export const hits = sqliteTable('hits', {
232
+ test: integer().notNull().references(() => testRuns.id, { onDelete: 'cascade' }),
233
+ site: integer().notNull(),
234
+ side: text({ enum: sides }).notNull(),
235
+ }, (table) => [
236
+ enumConstraint('hits_side_check', table.side, sides),
237
+ primaryKey({ columns: [table.test, table.site, table.side] }),
238
+ ]);
239
+ // Which test's baseline entered which function of a source, by its unit key, keyed test first as hits are, so a part's rewrite deletes them with its tests.
240
+ export const entries = sqliteTable('entries', {
241
+ test: integer().notNull().references(() => testRuns.id, { onDelete: 'cascade' }),
242
+ unit: text().notNull(),
243
+ }, (table) => [
244
+ primaryKey({ columns: [table.test, table.unit] }),
245
+ ]);
246
+ // Each site's verdict from one test file's tests under the basis it was judged on, reused while the basis holds.
247
+ // Its catcher and backup are tests of its own file, whose rewrite or removal deletes the verdict with them, so neither needs a cascade.
248
+ export const verdicts = sqliteTable('verdicts', {
249
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
250
+ site: integer().notNull().references(() => sites.id, { onDelete: 'cascade' }),
251
+ status: text({ enum: statuses }).notNull(),
252
+ catcher: integer().references(() => testRuns.id),
253
+ backup: integer().references(() => testRuns.id),
254
+ // How many tests reran against the site when it was judged, the cost a reused verdict saves.
255
+ reruns: integer().notNull(),
256
+ basisHash: text().notNull(),
257
+ readHash: text(),
258
+ // The units the basis read: the first `read_count` of the file's read sequence of `read_generation`.
259
+ readGeneration: integer().notNull(),
260
+ readCount: integer().notNull(),
261
+ // Whether the run took the verdict from the record rather than judging it again.
262
+ isReused: integer({ mode: 'boolean' }).notNull(),
263
+ // The test file this one left the site to, since that file caught it last run; such a verdict reads as unreached and the merge leaves it out.
264
+ deferredTo: text(),
265
+ }, (table) => [
266
+ enumConstraint('verdicts_status_check', table.status, statuses),
267
+ primaryKey({ columns: [table.testFile, table.site] }),
268
+ index('verdicts_site_idx').on(table.site),
269
+ index('verdicts_catcher_idx').on(table.catcher),
270
+ index('verdicts_backup_idx').on(table.backup),
271
+ ]);
272
+ // How many times one test file's tests passed through each side of a fork, which ranks the hottest sides.
273
+ export const sidePasses = sqliteTable('side_passes', {
274
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
275
+ site: integer().notNull().references(() => sites.id, { onDelete: 'cascade' }),
276
+ side: text({ enum: forkSides }).notNull(),
277
+ passes: integer().notNull(),
278
+ }, (table) => [
279
+ enumConstraint('side_passes_side_check', table.side, forkSides),
280
+ primaryKey({ columns: [table.testFile, table.site, table.side] }),
281
+ index('side_passes_site_idx').on(table.site),
282
+ ]);
283
+ // Each project file a test file's run loaded that crush leaves uninstrumented, where no step counts.
284
+ export const testFileOutside = sqliteTable('test_file_outside', {
285
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
286
+ path: text().notNull(),
287
+ }, (table) => [
288
+ primaryKey({ columns: [table.testFile, table.path] }),
289
+ ]);
290
+ // Each property a test file's tests declare for explore, by the export name its `meta.explores` gives, which a clean record reads to credit an answer to it.
291
+ export const testFileProperties = sqliteTable('test_file_properties', {
292
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
293
+ name: text().notNull(),
294
+ }, (table) => [
295
+ primaryKey({ columns: [table.testFile, table.name] }),
296
+ ]);
297
+ // Each source a test file's run loaded that changed during it, whose stale plan left the file's sites unjudged.
298
+ export const testFileChanged = sqliteTable('test_file_changed', {
299
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
300
+ path: text().notNull(),
301
+ }, (table) => [
302
+ primaryKey({ columns: [table.testFile, table.path] }),
303
+ ]);
304
+ // Each test file's part of the joint check: the hash of the candidate set it checked.
305
+ export const verifiedFiles = sqliteTable('verified_files', {
306
+ testFile: integer().primaryKey().references(() => testFiles.id, { onDelete: 'cascade' }),
307
+ candidatesHash: text().notNull(),
308
+ });
309
+ // Each crush a verified file dropped from the joint check.
310
+ export const verifiedDrops = sqliteTable('verified_drops', {
311
+ id: integer().primaryKey(),
312
+ testFile: integer().notNull().references(() => verifiedFiles.testFile, { onDelete: 'cascade' }),
313
+ site: integer().notNull().references(() => sites.id, { onDelete: 'cascade' }),
314
+ }, (table) => [
315
+ index('verified_drops_test_file_idx').on(table.testFile),
316
+ index('verified_drops_site_idx').on(table.site),
317
+ ]);
318
+ // Each test that failed with a dropped crush, a pillar a removal must keep.
319
+ export const verifiedDropTests = sqliteTable('verified_drop_tests', {
320
+ id: integer().primaryKey(),
321
+ dropped: integer().notNull().references(() => verifiedDrops.id, { onDelete: 'cascade' }),
322
+ test: integer().notNull().references(() => testRuns.id, { onDelete: 'cascade' }),
323
+ }, (table) => [
324
+ index('verified_drop_tests_dropped_idx').on(table.dropped),
325
+ index('verified_drop_tests_test_idx').on(table.test),
326
+ ]);
327
+ // Each crush the merge names for collapse to apply together, widest first.
328
+ export const candidates = sqliteTable('candidates', {
329
+ id: integer().primaryKey(),
330
+ site: integer().notNull().references(() => sites.id, { onDelete: 'cascade' }),
331
+ point: integer().notNull(),
332
+ forced: text({ enum: forcings }).notNull(),
333
+ startAt: integer().notNull(),
334
+ }, (table) => [
335
+ enumConstraint('candidates_forced_check', table.forced, forcings),
336
+ uniqueIndex('candidates_site_unique').on(table.site),
337
+ ]);
338
+ // Each span a candidate's edits reach.
339
+ export const candidateEdits = sqliteTable('candidate_edits', {
340
+ id: integer().primaryKey(),
341
+ candidate: integer().notNull().references(() => candidates.id, { onDelete: 'cascade' }),
342
+ startAt: integer().notNull(),
343
+ endAt: integer().notNull(),
344
+ }, (table) => [
345
+ index('candidate_edits_candidate_idx').on(table.candidate),
346
+ ]);
347
+ // One row: the basis the merge chose candidates under, which the report rests its holds on.
348
+ export const mergeBasis = sqliteTable('merge_basis', {
349
+ hash: text().primaryKey(),
350
+ });
351
+ // What the last judge that finished cleanly judged: crush's rules, the plan's files and tests by hash, and the test files it ran, as one hash.
352
+ // Writing any test file's part clears it, so a judge finding it unchanged knows no part, source or setting moved since, and judges nothing again.
353
+ export const judgedState = sqliteTable('judged_state', {
354
+ hash: text().primaryKey(),
355
+ // Whether a whole record has run every test file since and kept each part as that judge wrote it, which only a rerun of every baseline can show.
356
+ isRecorded: integer({ mode: 'boolean' }).notNull(),
357
+ });
358
+ // Each crush held back, with what the hold rests on.
359
+ export const holds = sqliteTable('holds', {
360
+ site: integer().primaryKey().references(() => sites.id, { onDelete: 'cascade' }),
361
+ basisHash: text().notNull(),
362
+ });
363
+ // Each test that held a crush back, by key, since a pillar outlives the run that named it while its file's test runs are rewritten.
364
+ export const holdTests = sqliteTable('hold_tests', {
365
+ id: integer().primaryKey(),
366
+ site: integer().notNull().references(() => holds.site, { onDelete: 'cascade' }),
367
+ testKey: text().notNull(),
368
+ }, (table) => [
369
+ index('hold_tests_site_idx').on(table.site),
370
+ ]);
371
+ // Each file, export, binding and function of the whole-project graph the plan step built, whether its file parsed, what the report asks of it, the imports a removal of it leaves unread, for code only tests reach the tests that go with it and those that only drop it, and for an exported pattern the tests that read it.
372
+ export const reachNodes = sqliteTable('reach_nodes', {
373
+ nodeKey: text().primaryKey(),
374
+ file: text().notNull(),
375
+ kind: text({ enum: reachKinds }).notNull(),
376
+ name: text().notNull(),
377
+ line: integer().notNull(),
378
+ parsed: integer({ mode: 'boolean' }).notNull(),
379
+ ask: text({ enum: reachAsks }).notNull(),
380
+ alongside: text().notNull(),
381
+ onlyTests: text().notNull(),
382
+ sharedTests: text().notNull(),
383
+ unnamedTests: text().notNull(),
384
+ patternTests: text().notNull(),
385
+ }, (table) => [
386
+ enumConstraint('reach_nodes_kind_check', table.kind, reachKinds),
387
+ enumConstraint('reach_nodes_ask_check', table.ask, reachAsks),
388
+ ]);
389
+ // Each load, read or call from one graph node to another, keyed from first, which the report walks from a test file to check the test's answer.
390
+ export const reachEdges = sqliteTable('reach_edges', {
391
+ fromKey: text().notNull().references(() => reachNodes.nodeKey, { onDelete: 'cascade' }),
392
+ toKey: text().notNull().references(() => reachNodes.nodeKey, { onDelete: 'cascade' }),
393
+ }, (table) => [
394
+ primaryKey({ columns: [table.fromKey, table.toKey] }),
395
+ index('reach_edges_to_key_idx').on(table.toKey),
396
+ ]);
397
+ export const findingKinds = ['throw', 'property'];
398
+ // When explore last ran each export or property and how long it spent, which orders the next budget and leaves the rest of the cap to the throw-only pass.
399
+ export const exploreRuns = sqliteTable('explore_runs', {
400
+ targetKey: text().primaryKey(),
401
+ ms: integer().notNull(),
402
+ exploredAt: integer({ mode: 'timestamp_ms' }).notNull(),
403
+ // Why the target's search stopped short, as a call past its tick limit, null for a search that ran its course.
404
+ stopped: text(),
405
+ });
406
+ // Each finding: a throw site no test covered, or a property a varied input failed, with the input that showed it and where to ask.
407
+ export const exploreFindings = sqliteTable('explore_findings', {
408
+ findingKey: text().notNull(),
409
+ kind: text({ enum: findingKinds }).notNull(),
410
+ file: text().notNull(),
411
+ line: integer().notNull(),
412
+ function: text().notNull(),
413
+ input: text().notNull(),
414
+ // The export or property whose explore found it, whose next explore replaces it; two targets reaching one site each keep their own row.
415
+ target: text().notNull(),
416
+ // The hash of the file the finding asks at when explore found it, so an edit to that file drops the finding until an explore finds it again.
417
+ sourceHash: text().notNull(),
418
+ }, (table) => [
419
+ enumConstraint('explore_findings_kind_check', table.kind, findingKinds),
420
+ primaryKey({ columns: [table.target, table.findingKey] }),
421
+ ]);
422
+ // Each call a test file's baseline made to an exported function, up to the counters' limit per test and export, in the order the calls began: the test that made it, the kept call it ran inside and how many it ran under, its arguments, how it ended and with what, and where a throw came from.
423
+ // Arguments and result are JSON, each value no JSON could hold, as a callback or a class instance, tagged uncloned; a null `parent` and `depth` 0 mark a call straight from the test.
424
+ export const exportCalls = sqliteTable('export_calls', {
425
+ id: integer().primaryKey(),
426
+ testFile: integer().notNull().references(() => testFiles.id, { onDelete: 'cascade' }),
427
+ position: integer().notNull(),
428
+ exportKey: text().notNull(),
429
+ testKey: text().notNull(),
430
+ parent: integer().references(() => exportCalls.id, { onDelete: 'cascade' }),
431
+ depth: integer().notNull(),
432
+ args: text().notNull(),
433
+ outcome: text({ enum: callOutcomes }).notNull(),
434
+ result: text().notNull(),
435
+ // A throw's first frame in the project as `path:line`, null for a call that threw nothing or none from the project.
436
+ thrownAt: text(),
437
+ isPathCut: integer({ mode: 'boolean' }).notNull(),
438
+ }, (table) => [
439
+ enumConstraint('export_calls_outcome_check', table.outcome, callOutcomes),
440
+ uniqueIndex('export_calls_test_file_position_unique').on(table.testFile, table.position),
441
+ index('export_calls_export_key_idx').on(table.exportKey),
442
+ index('export_calls_parent_idx').on(table.parent),
443
+ ]);
444
+ // Each step one captured call took itself, numbered in its file's one sequence of steps: a fork side, and how many times running it was taken there.
445
+ // A step inside a call the call made belongs to that call alone, so a call's whole path is its own steps merged with its descendants' by step.
446
+ export const exportCallSteps = sqliteTable('export_call_steps', {
447
+ call: integer().notNull().references(() => exportCalls.id, { onDelete: 'cascade' }),
448
+ step: integer().notNull(),
449
+ site: integer().notNull().references(() => sites.id, { onDelete: 'cascade' }),
450
+ side: text({ enum: forkSides }).notNull(),
451
+ passes: integer().notNull(),
452
+ }, (table) => [
453
+ enumConstraint('export_call_steps_side_check', table.side, forkSides),
454
+ primaryKey({ columns: [table.call, table.step] }),
455
+ index('export_call_steps_site_idx').on(table.site),
456
+ ]);
@@ -0,0 +1,2 @@
1
+ import { type Crush } from './crush.ts';
2
+ export declare const callback: Crush;
@@ -0,0 +1,19 @@
1
+ import { present } from '../utils/ast.js';
2
+ import { forksFor, replaced } from './crush.js';
3
+ // Forces a per-item callback to always answer true, or always false.
4
+ export const callback = {
5
+ name: 'callback',
6
+ decisionKinds: ['callback'],
7
+ sitesIn: ({ forks }) => {
8
+ return forksFor(callback, forks).flatMap((decision) => {
9
+ // An async callback answers a promise, which every deciding method reads as true, so forcing it to false changes nothing a fold could show.
10
+ // A callback decision is only ever made for an arrow or function handed to a deciding method, each with a body.
11
+ const { node } = decision;
12
+ if ((node.type !== 'ArrowFunctionExpression' && node.type !== 'FunctionExpression') || node.async)
13
+ return [];
14
+ const body = present(node.body);
15
+ const answer = (value) => (body.type === 'BlockStatement' ? `{ return ${value} }` : String(value));
16
+ return [true, false].map((value) => replaced(decision, String(!value), value, body, answer(value)));
17
+ });
18
+ },
19
+ };
@@ -0,0 +1,36 @@
1
+ import type { Fork } from '../decisions/decisions.ts';
2
+ import type { Node, Parsed } from '../utils/ast.ts';
3
+ import type { Shape } from './fold.ts';
4
+ export type Edit = {
5
+ start: number;
6
+ end: number;
7
+ text: string;
8
+ };
9
+ export type Dedent = {
10
+ start: number;
11
+ end: number;
12
+ by: number;
13
+ };
14
+ export type Forced = boolean | 'once';
15
+ export type Site = {
16
+ decision: string;
17
+ start: number;
18
+ end: number;
19
+ side: string;
20
+ forced: Forced;
21
+ edits: Edit[];
22
+ dedents: Dedent[];
23
+ };
24
+ export type CrushInput = {
25
+ source: string;
26
+ parsed: Parsed;
27
+ forks: Fork[];
28
+ shape: Shape;
29
+ };
30
+ export type Crush = {
31
+ name: string;
32
+ decisionKinds: readonly string[];
33
+ sitesIn: (input: CrushInput) => Site[];
34
+ };
35
+ export declare const forksFor: (crush: Pick<Crush, 'decisionKinds'>, forks: Fork[]) => Fork[];
36
+ export declare const replaced: (decision: Fork, side: string, forced: Forced, span: Pick<Node, 'start' | 'end'>, text: string) => Site;
@@ -0,0 +1,12 @@
1
+ // The forks of a crush's kinds, so no crush walks the tree to find a fork on its own.
2
+ export const forksFor = (crush, forks) => forks.filter((fork) => crush.decisionKinds.includes(fork.kind));
3
+ // A site whose removal is one span replaced, the shape of every removal that folds nothing around it.
4
+ export const replaced = (decision, side, forced, span, text) => ({
5
+ decision: decision.id,
6
+ start: span.start,
7
+ end: span.end,
8
+ side,
9
+ forced,
10
+ edits: [{ start: span.start, end: span.end, text }],
11
+ dedents: [],
12
+ });
@@ -0,0 +1 @@
1
+ export declare const crushNames: readonly ['force-fork', 'loop-once', 'drop-operand', 'switch-case', 'default-value', 'optional-chain', 'callback'];
@@ -0,0 +1,2 @@
1
+ // Every crush's name in the order `crushes` lists them, apart from the registry so the record's check reads it without loading a crush.
2
+ export const crushNames = ['force-fork', 'loop-once', 'drop-operand', 'switch-case', 'default-value', 'optional-chain', 'callback'];
@@ -0,0 +1,2 @@
1
+ import type { Crush } from './crush.ts';
2
+ export declare const crushes: readonly Crush[];
@@ -0,0 +1,9 @@
1
+ import { callback } from './callback.crush.js';
2
+ import { defaultValue } from './default-value.crush.js';
3
+ import { dropOperand } from './drop-operand.crush.js';
4
+ import { forceFork } from './force-fork.crush.js';
5
+ import { loopOnce } from './loop-once.crush.js';
6
+ import { optionalChain } from './optional-chain.crush.js';
7
+ import { switchCase } from './switch-case.crush.js';
8
+ // Every crush kind collapse iterates, each claiming the decision kinds it removes.
9
+ export const crushes = [forceFork, loopOnce, dropOperand, switchCase, defaultValue, optionalChain, callback];
@@ -0,0 +1,2 @@
1
+ import { type Crush } from './crush.ts';
2
+ export declare const defaultValue: Crush;
@@ -0,0 +1,29 @@
1
+ import { ofType } from '../utils/ast.js';
2
+ import { forksFor, replaced } from './crush.js';
3
+ const isOptional = (param) => {
4
+ const held = param.type === 'TSParameterProperty' ? param.parameter : param;
5
+ return 'optional' in held && held.optional === true;
6
+ };
7
+ // Whether a default fills a parameter written after an optional one, which TypeScript refuses to leave required.
8
+ const followsOptional = (shape, node) => {
9
+ const place = shape.placeOf(node);
10
+ const param = place.parent.type === 'TSParameterProperty' ? place.parent : node;
11
+ const { parent, key } = shape.placeOf(param);
12
+ if (key !== 'params')
13
+ return false;
14
+ const params = 'params' in parent ? parent.params : [];
15
+ return params.slice(0, params.indexOf(param)).some(isOptional);
16
+ };
17
+ // Drops a default value from a parameter or a destructured binding, leaving its name.
18
+ export const defaultValue = {
19
+ name: 'default-value',
20
+ decisionKinds: ['valueDefault'],
21
+ sitesIn: ({ source, forks, shape }) => {
22
+ return forksFor(defaultValue, forks).flatMap((decision) => {
23
+ const node = ofType(decision.node, 'AssignmentPattern');
24
+ if (followsOptional(shape, node))
25
+ return [];
26
+ return [replaced(decision, 'default', false, node, source.slice(node.left.start, node.left.end))];
27
+ });
28
+ },
29
+ };
@@ -0,0 +1,2 @@
1
+ import { type Crush } from './crush.ts';
2
+ export declare const dropOperand: Crush;
@@ -0,0 +1,37 @@
1
+ import { ofType } from '../utils/ast.js';
2
+ import { forksFor } from './crush.js';
3
+ import { keptLeft, keptRight } from './fold.js';
4
+ // Each part of a test's chain beside the value that leaves the chain unchanged when it is dropped: true under `&&`, false under `||`.
5
+ // A `??` is no link of the chain, and nothing inside one is an operand, so its parts never meet an operand decision.
6
+ const neutralsOf = (node, into) => {
7
+ if (node.type !== 'LogicalExpression')
8
+ return;
9
+ for (const side of [node.left, node.right]) {
10
+ into.set(side, node.operator === '&&');
11
+ neutralsOf(side, into);
12
+ }
13
+ };
14
+ // Drops one operand of a test's && or || chain, forcing it to the value that leaves the chain unchanged, which leaves the link's other side alone.
15
+ export const dropOperand = {
16
+ name: 'drop-operand',
17
+ decisionKinds: ['if', 'ternary', 'while', 'doWhile', 'for', 'callback'],
18
+ sitesIn: ({ forks, shape }) => {
19
+ const neutrals = new Map();
20
+ // A callback's test is its body, which a braced body splits into nothing.
21
+ for (const decision of forksFor(dropOperand, forks)) {
22
+ const { node } = decision;
23
+ const tested = decision.kind === 'callback' ? (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression' ? node.body : null) : 'test' in node ? node.test : null;
24
+ if (tested)
25
+ neutralsOf(tested, neutrals);
26
+ }
27
+ return forks.flatMap((decision) => {
28
+ const neutral = decision.kind === 'operand' ? neutrals.get(decision.node) : undefined;
29
+ if (neutral === undefined)
30
+ return [];
31
+ const { start, end } = decision.node;
32
+ const link = ofType(shape.placeOf(decision.node).parent, 'LogicalExpression');
33
+ const fold = link.left === decision.node ? keptRight(shape, link) : keptLeft(shape, link);
34
+ return [{ decision: decision.id, start, end, side: String(neutral), forced: neutral, ...fold }];
35
+ });
36
+ },
37
+ };