@whaaaley/crush 0.3.0-next.10 → 0.3.0-next.11

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 (70) hide show
  1. package/README.md +6 -14
  2. package/SKILL.md +4 -19
  3. package/dist/crush.tables.d.ts +12 -124
  4. package/dist/crush.tables.js +7 -22
  5. package/dist/instrument/instrument.operations.js +1 -1
  6. package/dist/judge/counters.js +1 -1
  7. package/dist/judge/edges/api.d.ts +2 -2
  8. package/dist/judge/edges/api.js +2 -2
  9. package/dist/judge/edges/hints.reporter.js +2 -2
  10. package/dist/judge/edges/judge.edges.d.ts +1 -2
  11. package/dist/judge/edges/judge.edges.js +1 -2
  12. package/dist/judge/edges/plugin.d.ts +7 -10
  13. package/dist/judge/edges/plugin.js +34 -55
  14. package/dist/judge/edges/vitest.d.ts +0 -3
  15. package/dist/judge/edges/vitest.js +1 -4
  16. package/dist/judge/hints.d.ts +1 -1
  17. package/dist/judge/hints.js +0 -3
  18. package/dist/judge/judge.schema.d.ts +0 -1
  19. package/dist/judge/judge.schema.js +0 -2
  20. package/dist/judge/provided.d.ts +2 -10
  21. package/dist/judge/provided.js +1 -1
  22. package/dist/judge/refusals.d.ts +2 -2
  23. package/dist/judge/refusals.js +2 -2
  24. package/dist/judge/report.test.js +10 -12
  25. package/dist/judge/runner.js +5 -66
  26. package/dist/judge/task-meta.d.ts +0 -6
  27. package/dist/questions/questions.operations.d.ts +2 -5
  28. package/dist/questions/questions.operations.js +8 -24
  29. package/dist/questions/questions.schema.d.ts +1 -3
  30. package/dist/questions/questions.schema.js +2 -2
  31. package/dist/record/edges/findings.db.d.ts +16 -0
  32. package/dist/record/edges/findings.db.js +25 -0
  33. package/dist/record/edges/parts.db.d.ts +1 -1
  34. package/dist/record/edges/parts.db.js +3 -15
  35. package/dist/record/edges/record.db.d.ts +1 -1
  36. package/dist/record/edges/record.db.js +1 -1
  37. package/dist/record/parts.operations.d.ts +2 -3
  38. package/dist/record/parts.operations.js +1 -2
  39. package/migrations/main/20261206102548_drop_explore/migration.sql +17 -0
  40. package/migrations/main/20261206102548_drop_explore/snapshot.json +3550 -0
  41. package/package.json +1 -3
  42. package/references/consumer-setup.md +0 -1
  43. package/dist/explore/edges/explore.d.ts +0 -53
  44. package/dist/explore/edges/explore.db.d.ts +0 -27
  45. package/dist/explore/edges/explore.db.js +0 -57
  46. package/dist/explore/edges/explore.js +0 -217
  47. package/dist/explore/edges/random.d.ts +0 -2
  48. package/dist/explore/edges/random.js +0 -32
  49. package/dist/explore/explore.operations.d.ts +0 -30
  50. package/dist/explore/explore.operations.js +0 -117
  51. package/dist/explore/limits.operations.d.ts +0 -14
  52. package/dist/explore/limits.operations.js +0 -20
  53. package/dist/explore/targets.operations.d.ts +0 -36
  54. package/dist/explore/targets.operations.js +0 -32
  55. package/dist/explore/utils/draws.d.ts +0 -6
  56. package/dist/explore/utils/draws.js +0 -2
  57. package/dist/explore/utils/edits.d.ts +0 -15
  58. package/dist/explore/utils/edits.js +0 -151
  59. package/dist/explore/utils/guide.d.ts +0 -23
  60. package/dist/explore/utils/guide.js +0 -35
  61. package/dist/explore/utils/keep.d.ts +0 -10
  62. package/dist/explore/utils/keep.js +0 -61
  63. package/dist/explore/utils/pools.d.ts +0 -17
  64. package/dist/explore/utils/pools.js +0 -121
  65. package/dist/explore/utils/reads.d.ts +0 -19
  66. package/dist/explore/utils/reads.js +0 -118
  67. package/dist/explore/utils/twin.d.ts +0 -21
  68. package/dist/explore/utils/twin.js +0 -55
  69. package/dist/judge/explore.test.d.ts +0 -1
  70. package/dist/judge/explore.test.js +0 -101
@@ -1,55 +0,0 @@
1
- import { copyOf, fieldOf, isIndex, keysOf } from './reads.js';
2
- // The chance in a thousand each free field of the second side is redrawn.
3
- const varyChance = 500;
4
- // The chance in a hundred a free array of the second side changes length.
5
- const growChance = 25;
6
- export const twinOf = ({ r, pools, resized }) => {
7
- // The path is where the value sits in the input, so its last step names the field a resize keys on.
8
- const planOf = (value, node, key, path) => {
9
- const field = path.at(-1) ?? key;
10
- const isResizable = Array.isArray(value) && !node?.keys.has('length') && !pools.isTuple(path);
11
- const plan = { numbers: [], strings: [], children: [], resizes: isResizable ? field : undefined, free: 0 };
12
- for (const each of keysOf(value)) {
13
- const inner = fieldOf(value, each);
14
- if (typeof inner === 'number') {
15
- if (!node?.keys.has(each))
16
- plan.numbers.push([each, inner]);
17
- }
18
- else if (typeof inner === 'string') {
19
- if (!pools.isTag(key, each) && !node?.keys.has(each))
20
- plan.strings.push(each);
21
- }
22
- else {
23
- // Only a holder has fields to free, so a boolean or null plans nothing.
24
- const child = planOf(inner, node?.children.get(each), isIndex(each) ? key : each, path.concat(each));
25
- if (child) {
26
- plan.children.push([each, child]);
27
- plan.free += child.free;
28
- }
29
- }
30
- }
31
- plan.free += plan.numbers.length + plan.strings.length + (plan.resizes === undefined ? 0 : 1);
32
- return plan.free ? plan : undefined;
33
- };
34
- const vary = (value, plan, holderKey = '', holder) => {
35
- let copy;
36
- const set = (key, next) => {
37
- copy ??= copyOf(value);
38
- Reflect.set(copy, key, next);
39
- };
40
- for (const [key, current] of plan.numbers)
41
- if (r.int(0, 999) < varyChance)
42
- set(key, pools.drawNumber(key, current));
43
- for (const key of plan.strings)
44
- if (r.int(0, 999) < varyChance)
45
- set(key, pools.drawString(key, fieldOf(value, key), holderKey));
46
- for (const [key, child] of plan.children) {
47
- set(key, vary(fieldOf(value, key), child, isIndex(key) ? holderKey : key, value));
48
- }
49
- const varied = copy ?? value;
50
- if (plan.resizes !== undefined && Array.isArray(varied) && r.int(0, 99) < growChance)
51
- return resized(varied, plan.resizes, holder);
52
- return varied;
53
- };
54
- return { planOf, vary };
55
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,101 +0,0 @@
1
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
- });
6
- }
7
- return path;
8
- };
9
- import { join } from 'node:path';
10
- import { describe, expect, inject, it } from 'vite-plus/test';
11
- import { exploreExport } from '../explore/edges/explore.js';
12
- import { getCovered, getSeeds, getUnreplayable, setExploreRun, setFindings } from '../explore/edges/explore.db.js';
13
- import { explorableOf, graphOf, skippedOf, unexploredOf } from '../explore/targets.operations.js';
14
- import { shareOf } from '../explore/explore.operations.js';
15
- import { exploreBudgetOf } from '../explore/limits.operations.js';
16
- import { getReachEdges, getReachNodes } from '../record/edges/reach.db.js';
17
- import { openRecord } from '../record/edges/record.db.js';
18
- import { unitFieldsOf } from '../record/record.operations.js';
19
- import { exploreLimitsProvideKey, explorePathsProvideKey, exploreSeedProvideKey, recordPathOf, rootProvideKey } from './edges/vitest.js';
20
- import { testFilePattern } from './edges/plugin.js';
21
- // Crush's explore of every export the record's baselines called with data it kept, each for a throw from a site no test covered, in what the step's cap leaves after the property pass.
22
- const root = inject(rootProvideKey);
23
- const seed = inject(exploreSeedProvideKey);
24
- const record = openRecord(recordPathOf(root));
25
- const seeds = getSeeds(record);
26
- const covered = getCovered(record);
27
- const limits = inject(exploreLimitsProvideKey);
28
- // The paths a related explore names, or null for a full one, as the plugin provides them.
29
- const paths = inject(explorePathsProvideKey);
30
- const graph = graphOf({ nodes: getReachNodes(record), edges: getReachEdges(record) });
31
- // The runner collects properties before this test. Export search excludes edge-reaching targets and respects related paths.
32
- const candidates = [...seeds.keys()].filter((key) => !testFilePattern.test(unitFieldsOf(key)[0]));
33
- const explorable = new Set(explorableOf({ ...graph, keys: candidates, paths: paths && new Set(paths) }).map(({ key }) => key));
34
- const exports = [...seeds].filter(([key]) => explorable.has(key));
35
- describe('crush:explore', () => {
36
- it('explores every replayable export', { timeout: 0 }, async ({ annotate, crushExploreProperties }) => {
37
- const now = () => performance.now();
38
- const budget = exploreBudgetOf(limits, now);
39
- const targets = [
40
- ...(crushExploreProperties ?? []),
41
- ...exports.map(([key, lists]) => {
42
- let resume;
43
- return {
44
- key,
45
- search: async (slice) => {
46
- resume ??= exploreExport({ root, key, module: await import(__rewriteRelativeImportExtension(join(root, unitFieldsOf(key)[0]))), seeds: lists, covered, seed });
47
- return resume(slice);
48
- },
49
- };
50
- }),
51
- ];
52
- const found = new Set();
53
- const stopped = [];
54
- const spent = new Map();
55
- const searched = new Set();
56
- let active = targets;
57
- while (active.length && budget.isLeft()) {
58
- const again = [];
59
- for (const [index, target] of active.entries()) {
60
- if (!budget.isLeft())
61
- break;
62
- const { key } = target;
63
- const started = now();
64
- const used = budget.used();
65
- // A finite run shares its remaining time. An unlimited one uses slices so every target gets a turn.
66
- const leftMs = budget.remainingMs();
67
- const limitMs = Number.isFinite(leftMs) ? Math.max(1, shareOf({ leftMs, count: active.length - index })) : 2000;
68
- const takeRun = () => now() - started < limitMs && budget.takeRun();
69
- // oxlint-disable-next-line no-await-in-loop -- each target shares the same budget and saves its own result before the next one runs
70
- const explored = await target.search({ limitMs, now, takeRun });
71
- const ms = Math.round(now() - started);
72
- const reason = explored instanceof Error ? explored.message : explored.stopped;
73
- setExploreRun(record, { key, ms, at: Temporal.Now.instant().epochMilliseconds, stopped: reason });
74
- if (explored instanceof Error)
75
- throw explored;
76
- if (reason)
77
- stopped.push({ key, reason });
78
- if (explored.isSearched) {
79
- searched.add(key);
80
- spent.set(key, (spent.get(key) ?? 0) + ms);
81
- }
82
- if (explored.finding) {
83
- setFindings(record, { plugin: 'explore', targets: [key], findings: [explored.finding] });
84
- found.add(key);
85
- }
86
- else if (!reason && (explored.isSearched || budget.used() > used || now() - started >= limitMs))
87
- again.push(target);
88
- }
89
- active = again;
90
- }
91
- setFindings(record, { plugin: 'explore', targets: [...searched].filter((key) => !found.has(key)), findings: [] });
92
- await annotate(`${searched.size} of ${targets.length} targets explored from seed ${seed}, ${budget.used()} runs, ${found.size} findings`, 'explore');
93
- const isStopped = (key) => stopped.some((each) => each.key === key);
94
- const unsearched = targets.map(({ key }) => key).filter((key) => !searched.has(key) && !isStopped(key));
95
- const unexplorable = candidates.filter((key) => !explorable.has(key));
96
- const skipped = { unreplayable: getUnreplayable(record), unexplorable, stopped, unsearched };
97
- await annotate(['explored:', ...[...spent].map(([key, ms]) => `${key}: ${ms} ms`), 'skipped:', ...skippedOf(skipped)].join('\n'), 'targets');
98
- if (limits.runs !== 0)
99
- expect(searched.size || budget.used(), unexploredOf(skipped)).toBeGreaterThan(0);
100
- });
101
- });