@whaaaley/crush 0.0.0-stage → 0.2.6

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 +51 -0
  170. package/dist/judge/task-meta.js +3 -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,117 @@
1
+ import { editsOf } from './utils/edits.js';
2
+ import { readPathsOf, sizeLimitOf, twinReadsOf } from './utils/guide.js';
3
+ import { keptInputsOf } from './utils/keep.js';
4
+ import { poolsOf } from './utils/pools.js';
5
+ import { twinOf } from './utils/twin.js';
6
+ import { fieldOf, holderKeyOf, withAt } from './utils/reads.js';
7
+ import { itemAt } from '../utils/lookup.js';
8
+ // The settings crush+fable's were frozen at, from generic.ts.
9
+ // `most` is the most second sides one edited input gets, `tries` how often an edit the property discards is drawn again.
10
+ const settings = { most: 12, tries: 16 };
11
+ // A port of generic.ts, crush+fable with nothing of one target in it: every name, value and shape it uses is read off the seeds and the inputs it keeps.
12
+ export const searchOf = ({ target, random: r }) => {
13
+ const { counts } = target;
14
+ // A target with no seed has nothing to vary, so the search finds nothing.
15
+ if (!target.seeds.length)
16
+ return () => undefined;
17
+ // Every call of the target counts against the budget, its relation's and the seeds' first runs included, so the clock starts before any and is read before each; a spent budget or a stopped target calls neither again.
18
+ let isSpent = false;
19
+ let isDone = false;
20
+ let take = () => false;
21
+ // An input a run on the plain input failed on, whichever step ran it, a seed's path, an edit's discard check or its test, so no failure seen is lost; once one is seen the target runs no more, and the search returns it.
22
+ let failedOn = null;
23
+ // Guidance runs the target on a proxy that tracks its reads, which the target may refuse where it accepts the plain input, as `structuredClone` does, so only a plain run's failure is kept as a finding.
24
+ // Run on a copy so writes cannot change the corpus or the input saved with a finding.
25
+ const runOn = (input, isPlain) => {
26
+ if (isDone || failedOn || !take())
27
+ return 'stopped';
28
+ const verdict = target.property(isPlain ? structuredClone(input) : input);
29
+ if (verdict === 'stopped')
30
+ isDone = true;
31
+ if (isPlain && verdict === 'failed')
32
+ failedOn = input;
33
+ return verdict;
34
+ };
35
+ const property = (input) => runOn(input, true);
36
+ const guided = (input) => runOn(input, false);
37
+ const ownTwin = target.twin;
38
+ const twin = ownTwin && { ...ownTwin, related: (input) => !isDone && !failedOn && take() && ownTwin.related(input) };
39
+ // An input without its second side, which is what gets kept and edited, and the same with its first side standing on both.
40
+ const baseOf = (input) => (twin ? withAt(input, [twin.second], 0, () => null) : input);
41
+ const mirrored = (base) => (twin ? withAt(base, [twin.second], 0, (holder) => fieldOf(holder, twin.first)) : base);
42
+ const forRead = (base) => structuredClone(mirrored(base));
43
+ const pools = poolsOf(r);
44
+ const { learnInput } = pools;
45
+ const seedBases = target.seeds.map(baseOf);
46
+ const kept = keptInputsOf(r, learnInput, sizeLimitOf(seedBases));
47
+ const { queue, groupList, join } = kept;
48
+ const check = (base) => {
49
+ counts.clear();
50
+ return property(mirrored(base));
51
+ };
52
+ // The seeds are learned twice, since which fields are tags is known only once every seed has been seen.
53
+ for (const base of seedBases)
54
+ learnInput(base);
55
+ pools.forget();
56
+ // Only the seeds teach lengths, since a kept input repeats its seed's arrays and would make every list look fixed.
57
+ for (const base of seedBases) {
58
+ learnInput(base);
59
+ pools.learnLengths(base);
60
+ }
61
+ let nextSeed = 0;
62
+ const pathsOf = readPathsOf({ property: guided, mirrored: forRead, twin });
63
+ // A two-run input's sides and what its relation read of them, together, so one check stands for both.
64
+ const twinned = twin ? { twin, readsOf: twinReadsOf({ twin, mirrored: forRead }) } : null;
65
+ const { edit, resized } = editsOf({ r, pools, readPathsOf: pathsOf, kept: () => queue });
66
+ const { planOf, vary } = twinOf({ r, pools, resized });
67
+ const canContinue = () => !isSpent && !isDone && !failedOn;
68
+ return ({ limitMs, now, takeRun }) => {
69
+ const start = now();
70
+ isSpent = false;
71
+ take = () => {
72
+ if (isSpent || now() - start >= limitMs || (takeRun && !takeRun()))
73
+ isSpent = true;
74
+ return !isSpent;
75
+ };
76
+ while (nextSeed < seedBases.length && canContinue()) {
77
+ const base = itemAt(seedBases, nextSeed);
78
+ check(base);
79
+ if (isSpent)
80
+ break;
81
+ nextSeed++;
82
+ join(base, kept.pathOf(counts.keys()), true);
83
+ queue.push(base);
84
+ }
85
+ // A failure ends the search at once, before any more guidance or relation calls, so nothing run after it can replace it.
86
+ while (canContinue()) {
87
+ const parent = r.pick(r.pick(groupList));
88
+ // A discarded edit is redrawn up to the retry limit. The last check also supplies the base's path and verdict.
89
+ let base = edit(parent);
90
+ let verdict = check(base);
91
+ for (let tries = 0; tries < settings.tries && verdict === 'discarded'; tries++) {
92
+ base = edit(parent);
93
+ verdict = check(base);
94
+ }
95
+ if (!canContinue())
96
+ break;
97
+ const path = kept.pathOf(counts.keys());
98
+ const plan = twinned && planOf(fieldOf(base, twinned.twin.first), twinned.readsOf(base), holderKeyOf([twinned.twin.first]), [twinned.twin.first]);
99
+ if (!twinned || !plan) {
100
+ kept.keep(base, path, counts);
101
+ continue;
102
+ }
103
+ const { first, second } = twinned.twin;
104
+ const variants = Math.min(settings.most, 1 + plan.free);
105
+ for (let index = 0; index < variants && canContinue(); index++) {
106
+ const input = withAt(base, [second], 0, (holder) => vary(fieldOf(holder, first), plan, holderKeyOf([first]), holder));
107
+ counts.clear();
108
+ property(input);
109
+ if (canContinue())
110
+ kept.keep(base, path, counts);
111
+ }
112
+ }
113
+ return failedOn ? { input: failedOn } : undefined;
114
+ };
115
+ };
116
+ // One target's share of what is left, split evenly over the `count` targets still to search, so a target stopped at once leaves its time to the rest.
117
+ export const shareOf = ({ leftMs, count }) => Math.floor(leftMs / count);
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export declare const exploreLimitsInput: z.ZodObject<{
3
+ maxTotalTime: z.ZodDefault<z.ZodInt>;
4
+ runs: z.ZodDefault<z.ZodInt>;
5
+ }, z.core.$strict>;
6
+ export type ExploreLimits = z.input<typeof exploreLimitsInput>;
7
+ type ExploreBudget = {
8
+ remainingMs: () => number;
9
+ isLeft: () => boolean;
10
+ used: () => number;
11
+ takeRun: () => boolean;
12
+ };
13
+ export declare const exploreBudgetOf: ({ maxTotalTime, runs }: z.output<typeof exploreLimitsInput>, now: () => number) => ExploreBudget;
14
+ export {};
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ const maximumSeconds = Math.floor(Number.MAX_SAFE_INTEGER / 1000);
3
+ export const exploreLimitsInput = z.strictObject({ maxTotalTime: z.int().min(0).max(maximumSeconds).default(0), runs: z.int().min(-1).default(-1) });
4
+ export const exploreBudgetOf = ({ maxTotalTime, runs }, now) => {
5
+ const deadline = maxTotalTime === 0 ? Infinity : now() + maxTotalTime * 1000;
6
+ let used = 0;
7
+ const remainingMs = () => Math.max(0, deadline - now());
8
+ const isLeft = () => (runs < 0 || used < runs) && remainingMs() > 0;
9
+ return {
10
+ remainingMs,
11
+ isLeft,
12
+ used: () => used,
13
+ takeRun: () => {
14
+ if (!isLeft())
15
+ return false;
16
+ used++;
17
+ return true;
18
+ },
19
+ };
20
+ };
@@ -0,0 +1,36 @@
1
+ export declare const edgesPathPattern: RegExp;
2
+ type Graph = {
3
+ out: ReadonlyMap<string, Iterable<string>>;
4
+ fileOf: ReadonlyMap<string, string>;
5
+ };
6
+ export declare const graphOf: ({ nodes, edges }: {
7
+ nodes: readonly {
8
+ key: string;
9
+ file: string;
10
+ }[];
11
+ edges: readonly {
12
+ fromKey: string;
13
+ toKey: string;
14
+ }[];
15
+ }) => Graph;
16
+ type ExplorableInput = Graph & {
17
+ keys: readonly string[];
18
+ paths: ReadonlySet<string> | null;
19
+ };
20
+ type Reaching = {
21
+ key: string;
22
+ files: string[];
23
+ };
24
+ export declare const explorableOf: ({ keys, out, fileOf, paths }: ExplorableInput) => Reaching[];
25
+ type UnexploredInput = {
26
+ unreplayable: readonly string[];
27
+ unexplorable: readonly string[];
28
+ stopped: readonly {
29
+ key: string;
30
+ reason: string;
31
+ }[];
32
+ unsearched: readonly string[];
33
+ };
34
+ export declare const skippedOf: ({ unreplayable, unexplorable, stopped, unsearched }: UnexploredInput) => string[];
35
+ export declare const unexploredOf: (skipped: UnexploredInput) => string;
36
+ export {};
@@ -0,0 +1,32 @@
1
+ import { encodeReachKey } from '../graph/symbols/keys.js';
2
+ import { unitFieldsOf } from '../record/record.operations.js';
3
+ import { reachedFrom } from '../graph/symbols/symbols.js';
4
+ // Matches an edges folder, which Explore excludes from search.
5
+ export const edgesPathPattern = /(^|\/)edges\//;
6
+ export const graphOf = ({ nodes, edges }) => ({
7
+ out: new Map([...Map.groupBy(edges, ({ fromKey }) => fromKey)].map(([from, each]) => [from, each.map(({ toKey }) => toKey)])),
8
+ fileOf: new Map(nodes.map(({ key, file }) => [key, file])),
9
+ });
10
+ // The exports and test-declared properties explore may call, by the whole-project graph: none whose calls reach an edges file, and for a related explore only those that sit in a given path or reach one.
11
+ export const explorableOf = ({ keys, out, fileOf, paths }) => {
12
+ return keys.flatMap((key) => {
13
+ const [path, name] = unitFieldsOf(key);
14
+ const files = [...new Set([path, ...[...reachedFrom(out, [encodeReachKey(['export', path, name])])].flatMap((node) => fileOf.get(node) ?? [])])];
15
+ if (files.some((file) => edgesPathPattern.test(file)))
16
+ return [];
17
+ if (paths && !files.some((file) => paths.has(file)))
18
+ return [];
19
+ return [{ key, files }];
20
+ });
21
+ };
22
+ // Each export explore left out, with why, as the report lists them.
23
+ export const skippedOf = ({ unreplayable, unexplorable, stopped, unsearched }) => [
24
+ ...unreplayable.map((key) => `${key}: a call passed an argument the record could not keep`),
25
+ ...unexplorable.map((key) => `${key}: its calls reach an edges file, or no path the related explore names`),
26
+ ...stopped.map(({ key, reason }) => `${key}: ${reason}`),
27
+ ...unsearched.map((key) => `${key}: the cap left it no call`),
28
+ ];
29
+ export const unexploredOf = (skipped) => {
30
+ const reasons = skippedOf(skipped);
31
+ return reasons.length ? `explore explored no target:\n${reasons.join('\n')}` : 'explore explored no target: the tests called no export';
32
+ };
@@ -0,0 +1,6 @@
1
+ export type Draw = (min: number, max: number) => number;
2
+ export type Random = {
3
+ int: Draw;
4
+ pick: <T>(items: readonly T[]) => T;
5
+ };
6
+ export declare const drawsOf: (int: Draw) => Random;
@@ -0,0 +1,2 @@
1
+ import { itemAt } from '../../utils/lookup.js';
2
+ export const drawsOf = (int) => ({ int, pick: (items) => itemAt(items, int(0, items.length - 1)) });
@@ -0,0 +1,15 @@
1
+ import { type Pools } from './pools.ts';
2
+ import type { Random } from './draws.ts';
3
+ import { type Path } from './reads.ts';
4
+ type EditsInput = {
5
+ r: Random;
6
+ pools: Pools;
7
+ readPathsOf: (base: object) => Path[];
8
+ kept: () => object[];
9
+ };
10
+ export type Edits = {
11
+ resized: (array: unknown[], key: string, holder?: unknown) => unknown[];
12
+ edit: (base: object) => object;
13
+ };
14
+ export declare const editsOf: ({ r, pools, readPathsOf, kept }: EditsInput) => Edits;
15
+ export {};
@@ -0,0 +1,151 @@
1
+ import { present } from '../../utils/lookup.js';
2
+ import { holderShapeOf } from './pools.js';
3
+ import { fieldOf, holderKeyOf, isHolder, keysOf, valueAtPath, withAt } from './reads.js';
4
+ // The share of each edit kind, out of their sum: a blind redraw, a redraw aimed at what the run read, a splice from a kept input, and an array resized.
5
+ const weights = { blind: 3, aimed: 6, splice: 2, resize: 1 };
6
+ // The most edits one input takes.
7
+ const stackLimit = 3;
8
+ // Of ten aimed edits, how many redraw every string the run read; the next two redraw each read field by a coin, the rest one read field.
9
+ const aimedStrings = 4;
10
+ export const editsOf = ({ r, pools, readPathsOf, kept }) => {
11
+ const { donorsOf, elementsOf, isTag, isTuple } = pools;
12
+ const redrawn = (holder, at, holderKey) => {
13
+ const current = fieldOf(holder, at);
14
+ return typeof current === 'number' ? pools.drawNumber(at, current) : pools.drawString(at, current, holderKey);
15
+ };
16
+ const redrawAt = (base, path) => {
17
+ const key = present(path.at(-1));
18
+ const holderPath = path.slice(0, -1);
19
+ const holderKey = holderKeyOf(holderPath);
20
+ if (!isTag(holderKey, key))
21
+ return withAt(base, path, 0, (holder, at) => redrawn(holder, at, holderKey));
22
+ // A tag takes a whole object from a matching container in another kept input, an array element's container being the holder of its array.
23
+ let field = holderPath.at(-1);
24
+ let containerPath = holderPath.slice(0, -1);
25
+ while (containerPath.length && Array.isArray(valueAtPath(base, containerPath))) {
26
+ field = containerPath.at(-1);
27
+ containerPath = containerPath.slice(0, -1);
28
+ }
29
+ if (field === undefined)
30
+ return base;
31
+ const donors = donorsOf(valueAtPath(base, containerPath), holderKeyOf(containerPath), field);
32
+ return donors.length ? withAt(base, holderPath, 0, () => r.pick(donors)) : base;
33
+ };
34
+ // Redraws one number or string, reached by a walk that takes a key at random at each object, so a shallow field is drawn as often as a whole subtree.
35
+ const editBlind = (base) => {
36
+ const path = [];
37
+ let at = base;
38
+ while (isHolder(at)) {
39
+ const holder = at;
40
+ const keys = keysOf(holder).filter((key) => fieldOf(holder, key) !== null);
41
+ if (!keys.length)
42
+ return base;
43
+ const key = r.pick(keys);
44
+ path.push(key);
45
+ at = fieldOf(holder, key);
46
+ }
47
+ return typeof at === 'number' || typeof at === 'string' ? redrawAt(base, path) : base;
48
+ };
49
+ // Redraws fields the function under test read: one of them, or each by a coin, as a generator draws every one afresh around one case.
50
+ const editRead = (base) => {
51
+ const paths = readPathsOf(base);
52
+ if (!paths.length)
53
+ return editBlind(base);
54
+ const mode = r.int(1, 10);
55
+ if (mode > aimedStrings + 2)
56
+ return redrawAt(base, r.pick(paths));
57
+ // Strings alone are redrawn most often, since they name one of a few choices where a number is an index that is easily made invalid.
58
+ const isRedrawn = mode <= aimedStrings ? (path) => typeof valueAtPath(base, path) === 'string' && Boolean(r.int(0, 1)) : () => r.int(0, 9) < 3;
59
+ let next = base;
60
+ for (const path of paths) {
61
+ if (isTag(holderKeyOf(path.slice(0, -1)), present(path.at(-1))))
62
+ continue;
63
+ if (isRedrawn(path))
64
+ next = redrawAt(next, path);
65
+ }
66
+ return next;
67
+ };
68
+ // Splices at the same path in another kept input when the containing shapes and labels match.
69
+ const splice = (base) => {
70
+ const path = [];
71
+ let from = base;
72
+ let to = r.pick(kept());
73
+ for (;;) {
74
+ const source = from;
75
+ const donor = to;
76
+ if (holderShapeOf(source) !== holderShapeOf(donor))
77
+ return base;
78
+ const holderKey = holderKeyOf(path);
79
+ const sourceKeys = keysOf(source);
80
+ if (sourceKeys.some((key) => isTag(holderKey, key) && fieldOf(source, key) !== fieldOf(donor, key)))
81
+ return base;
82
+ const keys = sourceKeys.filter((key) => {
83
+ const fromChild = fieldOf(source, key);
84
+ const toChild = fieldOf(donor, key);
85
+ return isHolder(fromChild) && isHolder(toChild) && Array.isArray(fromChild) === Array.isArray(toChild);
86
+ });
87
+ if (!keys.length)
88
+ break;
89
+ const key = r.pick(keys);
90
+ path.push(key);
91
+ from = fieldOf(source, key);
92
+ to = fieldOf(donor, key);
93
+ if (r.int(0, 2) === 0)
94
+ break;
95
+ }
96
+ if (!path.length)
97
+ return base;
98
+ return withAt(base, path, 0, () => to);
99
+ };
100
+ // Lengthens or shortens one array, a new element being a copy of one of its own or of one a kept input holds at the same key.
101
+ const resized = (array, key, holder = { [key]: array }) => {
102
+ const next = array.slice();
103
+ if (array.length && r.int(0, 1)) {
104
+ next.splice(r.int(0, array.length - 1), 1);
105
+ return next;
106
+ }
107
+ const donors = elementsOf(holder, key);
108
+ const item = array.length && (!donors || r.int(0, 1)) ? array[r.int(0, array.length - 1)] : donors && r.pick(donors);
109
+ if (item !== undefined)
110
+ next.splice(r.int(0, array.length), 0, item);
111
+ return next;
112
+ };
113
+ const resize = (base) => {
114
+ // The array is reached by a walk that stops at one by a coin, sparing a list of them all, and walks on through a tuple.
115
+ const path = [];
116
+ let at = base;
117
+ for (;;) {
118
+ const holder = at;
119
+ const keys = keysOf(holder).filter((key) => isHolder(fieldOf(holder, key)));
120
+ if (!keys.length)
121
+ return base;
122
+ const key = r.pick(keys);
123
+ path.push(key);
124
+ at = fieldOf(holder, key);
125
+ if (Array.isArray(at) && !isTuple(path) && r.int(0, 1))
126
+ break;
127
+ }
128
+ return withAt(base, path, 0, (holder, key) => {
129
+ const array = fieldOf(holder, key);
130
+ return Array.isArray(array) ? resized(array, key, holder) : array;
131
+ });
132
+ };
133
+ const weightSum = weights.blind + weights.aimed + weights.splice + weights.resize;
134
+ const editOnce = (base) => {
135
+ const roll = r.int(1, weightSum);
136
+ if (roll <= weights.blind)
137
+ return editBlind(base);
138
+ if (roll <= weights.blind + weights.aimed)
139
+ return editRead(base);
140
+ if (roll <= weights.blind + weights.aimed + weights.splice)
141
+ return splice(base);
142
+ return resize(base);
143
+ };
144
+ const edit = (base) => {
145
+ let next = editOnce(base);
146
+ for (let more = stackLimit - 1; more > 0 && r.int(0, 1); more--)
147
+ next = editOnce(next);
148
+ return next;
149
+ };
150
+ return { resized, edit };
151
+ };
@@ -0,0 +1,23 @@
1
+ import { type Path, type ReadNode } from './reads.ts';
2
+ export declare const firstSideOf: (reads: ReadNode, first: string, second: string) => ReadNode;
3
+ export declare const bothSidesOf: (reads: ReadNode, first: string, second: string) => ReadNode | undefined;
4
+ export declare const sizeLimitOf: (seeds: readonly object[]) => number;
5
+ export declare const fitsSize: (value: unknown, limit: number) => boolean;
6
+ type Sides = {
7
+ first: string;
8
+ second: string;
9
+ };
10
+ type ReadPathsInput = {
11
+ property: (input: object) => unknown;
12
+ mirrored: (base: object) => object;
13
+ twin: Sides | undefined;
14
+ };
15
+ export declare const readPathsOf: ({ property, mirrored, twin }: ReadPathsInput) => ((base: object) => Path[]);
16
+ type TwinReadsInput = {
17
+ twin: Sides & {
18
+ related: (input: object) => boolean;
19
+ };
20
+ mirrored: (base: object) => object;
21
+ };
22
+ export declare const twinReadsOf: ({ twin, mirrored }: TwinReadsInput) => ((edited: object) => ReadNode | undefined);
23
+ export {};
@@ -0,0 +1,35 @@
1
+ import { leafPathsOf, merged, readsOf, sizeOf } from './reads.js';
2
+ // What a run read of a two-run input, with all it read of the second side counted as read of the first, which is the side a kept input holds.
3
+ export const firstSideOf = (reads, first, second) => {
4
+ const children = new Map(reads.children);
5
+ const side = merged(children.get(first), children.get(second));
6
+ children.delete(second);
7
+ if (side)
8
+ children.set(first, side);
9
+ const keys = new Set([...reads.keys].filter((key) => key !== second));
10
+ if (side)
11
+ keys.add(first);
12
+ return { keys, children, proxy: reads.proxy };
13
+ };
14
+ // What a relation read of either side of a two-run input, as one tree, which tells the fields the second side must keep.
15
+ export const bothSidesOf = (reads, first, second) => merged(reads.children.get(first), reads.children.get(second));
16
+ // The largest input the search keeps, twice the size of its largest seed, so kept inputs grow but never without bound.
17
+ export const sizeLimitOf = (seeds) => Math.max(0, ...seeds.map((seed) => 2 * sizeOf(seed)));
18
+ export const fitsSize = (value, limit) => sizeOf(value) <= limit;
19
+ // The fields a run of the property read of each kept base, the ones an edit can change its run through, read once per base and kept.
20
+ export const readPathsOf = ({ property, mirrored, twin }) => {
21
+ const readPaths = new WeakMap();
22
+ return (base) => {
23
+ const known = readPaths.get(base);
24
+ if (known)
25
+ return known;
26
+ const reads = readsOf(mirrored(base), (proxied) => property(proxied));
27
+ const paths = leafPathsOf(base, twin ? firstSideOf(reads, twin.first, twin.second) : reads, [], []);
28
+ readPaths.set(base, paths);
29
+ return paths;
30
+ };
31
+ };
32
+ // What the relation of a two-run input read of either side, for an edited base run mirrored, which the twin plan frees the rest of.
33
+ export const twinReadsOf = ({ twin, mirrored }) => {
34
+ return (edited) => bothSidesOf(readsOf(mirrored(edited), twin.related), twin.first, twin.second);
35
+ };
@@ -0,0 +1,10 @@
1
+ import type { Random } from './draws.ts';
2
+ export declare const groupLimit = 8;
3
+ export type KeptInputs = {
4
+ queue: object[];
5
+ groupList: object[][];
6
+ pathOf: (sides: Iterable<string>) => number;
7
+ join: (base: object, path: number, always: boolean) => void;
8
+ keep: (base: object, path: number, counts: ReadonlyMap<string, number>) => boolean;
9
+ };
10
+ export declare const keptInputsOf: (r: Random, onNew: (base: object) => void, sizeLimit: number) => KeptInputs;
@@ -0,0 +1,61 @@
1
+ import { fitsSize } from './guide.js';
2
+ // The most inputs one path's group holds before a new one replaces a member at random.
3
+ export const groupLimit = 8;
4
+ // The highest hit count bucket, past which more passes through a side count as no new side.
5
+ const topBucket = 8;
6
+ // `onNew` is handed each input kept for a new side, as the pools learn it, and `sizeLimit` is the largest input kept, so kept inputs grow but never without bound.
7
+ export const keptInputsOf = (r, onNew, sizeLimit) => {
8
+ const hashes = new Map();
9
+ const seenOf = (key) => {
10
+ const had = hashes.get(key) ?? { bits: 0, hash: r.int(-0x80000000, 0x7fffffff) };
11
+ hashes.set(key, had);
12
+ return had;
13
+ };
14
+ // Which way a run went, as one number over the sides it took, in any order.
15
+ const pathOf = (sides) => {
16
+ let signature = 0;
17
+ for (const key of sides)
18
+ signature ^= seenOf(key).hash;
19
+ return signature;
20
+ };
21
+ const queue = [];
22
+ const groups = new Map();
23
+ const groupList = [];
24
+ const join = (base, path, always) => {
25
+ const group = groups.get(path);
26
+ if (!group) {
27
+ const made = [base];
28
+ groups.set(path, made);
29
+ groupList.push(made);
30
+ }
31
+ else if (always || group.length < groupLimit) {
32
+ group.push(base);
33
+ }
34
+ else {
35
+ group[r.int(0, group.length - 1)] = base;
36
+ }
37
+ };
38
+ // Keeps an input by the counts its run left, answering whether it took a side at a bucket no earlier run did.
39
+ const keep = (base, path, counts) => {
40
+ // An input past the limit marks no side seen, so a smaller one taking the same sides is still kept.
41
+ if (!fitsSize(base, sizeLimit))
42
+ return false;
43
+ let isNew = false;
44
+ for (const [key, count] of counts) {
45
+ const had = seenOf(key);
46
+ const bit = 1 << Math.min(topBucket, Math.ceil(Math.log2(count + 1)));
47
+ if (had.bits & bit)
48
+ continue;
49
+ had.bits |= bit;
50
+ isNew = true;
51
+ }
52
+ if (isNew || !groups.has(path))
53
+ join(base, path, false);
54
+ if (isNew) {
55
+ queue.push(base);
56
+ onNew(base);
57
+ }
58
+ return isNew;
59
+ };
60
+ return { queue, groupList, pathOf, join, keep };
61
+ };
@@ -0,0 +1,17 @@
1
+ import type { Random } from './draws.ts';
2
+ import { type Path } from './reads.ts';
3
+ export declare const poolLimit = 256;
4
+ export declare const holderShapeOf: (holder: unknown) => string;
5
+ export type Pools = {
6
+ donorsOf: (container: unknown, containerKey: string, key: string) => unknown[];
7
+ elementsOf: (holder: unknown, key: string) => unknown[] | undefined;
8
+ isTag: (holderKey: string, key: string) => boolean;
9
+ learn: (value: unknown, holderKey: string) => void;
10
+ learnInput: (input: object) => void;
11
+ learnLengths: (seed: object) => void;
12
+ isTuple: (path: Path) => boolean;
13
+ forget: () => void;
14
+ drawNumber: (key: string, current: number) => unknown;
15
+ drawString: (key: string, current: unknown, holderKey?: string) => unknown;
16
+ };
17
+ export declare const poolsOf: (r: Random) => Pools;