@whaaaley/crush 0.2.7 → 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 (77) hide show
  1. package/README.md +54 -14
  2. package/SKILL.md +4 -19
  3. package/dist/crush.tables.d.ts +26 -122
  4. package/dist/crush.tables.js +8 -21
  5. package/dist/instrument/instrument.operations.js +1 -1
  6. package/dist/judge/counters.d.ts +6 -0
  7. package/dist/judge/counters.js +89 -1
  8. package/dist/judge/edges/api.d.ts +24 -4
  9. package/dist/judge/edges/api.js +20 -6
  10. package/dist/judge/edges/hints.reporter.js +2 -2
  11. package/dist/judge/edges/judge.edges.d.ts +2 -3
  12. package/dist/judge/edges/judge.edges.js +1 -2
  13. package/dist/judge/edges/plugin.d.ts +12 -9
  14. package/dist/judge/edges/plugin.js +34 -49
  15. package/dist/judge/edges/plugin.npm.d.ts +2 -0
  16. package/dist/judge/edges/plugin.npm.js +2 -0
  17. package/dist/judge/edges/vitest.d.ts +1 -3
  18. package/dist/judge/edges/vitest.js +2 -3
  19. package/dist/judge/hints.d.ts +1 -1
  20. package/dist/judge/hints.js +0 -3
  21. package/dist/judge/judge.schema.d.ts +10 -1
  22. package/dist/judge/judge.schema.js +0 -2
  23. package/dist/judge/provided.d.ts +31 -0
  24. package/dist/judge/provided.js +2 -0
  25. package/dist/judge/refusals.d.ts +2 -2
  26. package/dist/judge/refusals.js +2 -2
  27. package/dist/judge/report.test.js +11 -12
  28. package/dist/judge/runner.js +35 -58
  29. package/dist/judge/task-meta.d.ts +0 -6
  30. package/dist/questions/questions.operations.d.ts +4 -3
  31. package/dist/questions/questions.operations.js +11 -11
  32. package/dist/questions/questions.schema.d.ts +3 -3
  33. package/dist/questions/questions.schema.js +2 -2
  34. package/dist/record/edges/findings.db.d.ts +16 -0
  35. package/dist/record/edges/findings.db.js +25 -0
  36. package/dist/record/edges/parts.db.d.ts +1 -1
  37. package/dist/record/edges/parts.db.js +3 -15
  38. package/dist/record/edges/plan.db.d.ts +1 -0
  39. package/dist/record/edges/plan.db.js +5 -0
  40. package/dist/record/edges/record.db.d.ts +1 -1
  41. package/dist/record/edges/record.db.js +1 -1
  42. package/dist/record/parts.operations.d.ts +2 -3
  43. package/dist/record/parts.operations.js +1 -2
  44. package/migrations/main/20261206094906_plugin_findings/migration.sql +20 -0
  45. package/migrations/main/20261206094906_plugin_findings/snapshot.json +3652 -0
  46. package/migrations/main/20261206102548_drop_explore/migration.sql +17 -0
  47. package/migrations/main/20261206102548_drop_explore/snapshot.json +3550 -0
  48. package/package.json +3 -5
  49. package/references/consumer-setup.md +0 -1
  50. package/dist/explore/edges/explore.d.ts +0 -60
  51. package/dist/explore/edges/explore.db.d.ts +0 -22
  52. package/dist/explore/edges/explore.db.js +0 -55
  53. package/dist/explore/edges/explore.js +0 -305
  54. package/dist/explore/edges/random.d.ts +0 -2
  55. package/dist/explore/edges/random.js +0 -32
  56. package/dist/explore/explore.operations.d.ts +0 -30
  57. package/dist/explore/explore.operations.js +0 -117
  58. package/dist/explore/limits.operations.d.ts +0 -14
  59. package/dist/explore/limits.operations.js +0 -20
  60. package/dist/explore/targets.operations.d.ts +0 -36
  61. package/dist/explore/targets.operations.js +0 -32
  62. package/dist/explore/utils/draws.d.ts +0 -6
  63. package/dist/explore/utils/draws.js +0 -2
  64. package/dist/explore/utils/edits.d.ts +0 -15
  65. package/dist/explore/utils/edits.js +0 -151
  66. package/dist/explore/utils/guide.d.ts +0 -23
  67. package/dist/explore/utils/guide.js +0 -35
  68. package/dist/explore/utils/keep.d.ts +0 -10
  69. package/dist/explore/utils/keep.js +0 -61
  70. package/dist/explore/utils/pools.d.ts +0 -17
  71. package/dist/explore/utils/pools.js +0 -121
  72. package/dist/explore/utils/reads.d.ts +0 -19
  73. package/dist/explore/utils/reads.js +0 -118
  74. package/dist/explore/utils/twin.d.ts +0 -21
  75. package/dist/explore/utils/twin.js +0 -55
  76. package/dist/judge/explore.test.d.ts +0 -1
  77. package/dist/judge/explore.test.js +0 -101
@@ -1,6 +1,6 @@
1
1
  import { relative } from 'node:path';
2
2
  import { hintLinesOf } from '../hints.js';
3
- const commands = new Set(['record', 'judge', 'questions', 'explore']);
3
+ const commands = new Set(['record', 'judge', 'questions']);
4
4
  const isHintCommand = (name) => commands.has(name);
5
5
  // The hint lines for the crush command this run is, or none for a run of another project.
6
6
  export const runHintsOf = ({ ctx, modules, reason }) => {
@@ -14,7 +14,7 @@ export const runHintsOf = ({ ctx, modules, reason }) => {
14
14
  const [firstFile = null] = metas.flatMap(({ crushOpenIn }) => (crushOpenIn ? [crushOpenIn] : []));
15
15
  return hintLinesOf({ command: project.name, isPassed: reason === 'passed', related, open, firstFile });
16
16
  };
17
- // Ends a questions or explore run with the hint, skill and next-step lines, after Vitest's own report.
17
+ // Ends a record, judge or questions run with the hint, skill and next-step lines, after Vitest's own report.
18
18
  export default class HintsReporter {
19
19
  ctx;
20
20
  onInit(ctx) {
@@ -8,7 +8,7 @@ import { type MeasureWrite } from '../../record/edges/record.db.ts';
8
8
  import type { CrushError } from '../../utils/errors.ts';
9
9
  import type { Safe } from '../../utils/safe.ts';
10
10
  import type { Candidate, Hold, Judged, Verified } from '../judge.schema.ts';
11
- import { type Finding } from '../../explore/edges/explore.db.ts';
11
+ import { getFindings } from '../../record/edges/findings.db.ts';
12
12
  export type JudgeEdges = {
13
13
  getPlan: (input?: {
14
14
  withRewrites?: boolean;
@@ -42,8 +42,7 @@ export type JudgeEdges = {
42
42
  getReachNodes: () => ReachNodeOutput[];
43
43
  getReachEdges: () => ReachEdgeOutput[];
44
44
  getExportCalls: () => ExportCallOutput[];
45
- getFindings: () => Finding[];
46
- getSeeds: () => Map<string, unknown[][]>;
45
+ getFindings: () => ReturnType<typeof getFindings>;
47
46
  marked: (name: string, work: () => Promise<Error | null>) => Promise<Error | null>;
48
47
  settled: () => Promise<Error | null>;
49
48
  [Symbol.dispose]: () => void;
@@ -10,7 +10,7 @@ import { getSiteVerdicts, setSiteVerdicts } from '../../record/edges/site-verdic
10
10
  import { getReachEdges, getReachNodes } from '../../record/edges/reach.db.js';
11
11
  import { openCurrentRecord, openReadOnlyRecord, writeDirectly } from '../../record/edges/record.db.js';
12
12
  import { clearVerified, getCheckedCandidatesNullable, getVerified, setVerified } from '../../record/edges/verified.db.js';
13
- import { getFindings, getSeeds } from '../../explore/edges/explore.db.js';
13
+ import { getFindings } from '../../record/edges/findings.db.js';
14
14
  const judgeEdgesOf = (record, write = writeDirectly) => ({
15
15
  getPlan: (input) => getPlan(record, input),
16
16
  getJudged: (input) => getJudged(record, input),
@@ -41,7 +41,6 @@ const judgeEdgesOf = (record, write = writeDirectly) => ({
41
41
  getReachEdges: () => getReachEdges(record),
42
42
  getExportCalls: () => getExportCalls(record),
43
43
  getFindings: () => getFindings(record),
44
- getSeeds: () => getSeeds(record),
45
44
  marked: (name, work) => marked(record, name, work, undefined, write),
46
45
  settled: () => settled(record),
47
46
  [Symbol.dispose]: () => record[Symbol.dispose](),
@@ -3,7 +3,6 @@ import { type MutationSettings, mutationSettingsInput } from '../../instrument/i
3
3
  import type { RemovableTests } from '../judge.schema.ts';
4
4
  import { type ForkPlugin } from '../../forks/forks.schema.ts';
5
5
  import { phaseProvideKey } from './vitest.ts';
6
- import { type ExploreLimits } from '../../explore/limits.operations.ts';
7
6
  import type { ProvidedContext } from 'vite-plus/test';
8
7
  export declare const nativePattern: RegExp;
9
8
  export declare const ungatedPattern: RegExp;
@@ -66,9 +65,6 @@ type VitestContext = {
66
65
  };
67
66
  defineCacheKeyGenerator?: (generate: () => string) => void;
68
67
  };
69
- type ResolvedConfig = {
70
- mode: string;
71
- };
72
68
  type Transformed = {
73
69
  code: string;
74
70
  map: null;
@@ -85,7 +81,6 @@ type CrushPlugin = {
85
81
  };
86
82
  };
87
83
  };
88
- configResolved: (config: ResolvedConfig) => void;
89
84
  watchChange: () => void;
90
85
  configureVitest: (context: VitestContext) => Promise<void>;
91
86
  transform: (source: string, id: string) => Promise<Transformed>;
@@ -98,6 +93,10 @@ type CrushProject = {
98
93
  };
99
94
  };
100
95
  type DiscoverTests = (project: VitestContext['project']) => Promise<string[]>;
96
+ type PluginRun = {
97
+ name: string;
98
+ coordinator: string;
99
+ };
101
100
  type CrushPluginInput = {
102
101
  root: string;
103
102
  entries: string[];
@@ -105,10 +104,10 @@ type CrushPluginInput = {
105
104
  plugins: readonly ForkPlugin[];
106
105
  steps: boolean;
107
106
  mutation: MutationSettings;
108
- explore: boolean;
107
+ plugin: PluginRun | null;
109
108
  discoverTests: DiscoverTests;
110
109
  };
111
- export declare const crushPlugin: ({ root, entries, jsx, plugins, steps, mutation, explore, discoverTests }: CrushPluginInput) => CrushPlugin;
110
+ export declare const crushPlugin: ({ root, entries, jsx, plugins, steps, mutation, plugin, discoverTests }: CrushPluginInput) => CrushPlugin;
112
111
  type Mutation = z.input<typeof mutationSettingsInput>;
113
112
  type CrushProjectsInput = {
114
113
  root: string;
@@ -122,11 +121,15 @@ type CrushProjectsInput = {
122
121
  redundant?: boolean;
123
122
  forks?: ForkPlugin[];
124
123
  mutation?: Mutation;
125
- explore?: ExploreLimits;
126
124
  };
127
125
  export declare const questionsProject: ({ root, include, exclude, removableTests, steps }: CrushProjectsInput) => CrushProject;
128
126
  export declare const stressesProject: ({ root }: CrushProjectsInput) => CrushProject;
129
127
  export declare const recordProject: (input: CrushProjectsInput) => CrushProject;
130
128
  export declare const judgeProject: (input: CrushProjectsInput) => CrushProject;
131
- export declare const exploreProject: ({ root, include, exclude, entries, jsx, removableTests, steps, forks, mutation: written, explore }: CrushProjectsInput) => CrushProject;
129
+ type PluginProjectInput = CrushProjectsInput & {
130
+ name: string;
131
+ coordinator: string;
132
+ metaKey: string;
133
+ };
134
+ export declare const pluginProject: ({ name, coordinator, metaKey, root, include, exclude, entries, jsx, removableTests, steps, forks, mutation: written }: PluginProjectInput) => CrushProject;
132
135
  export {};
@@ -18,18 +18,15 @@ import { clearRefusal, pathsIn, readJudgeSource, readJudgeSourceNullable, readJu
18
18
  import { cachedImportsOf, jsxFilePattern, projectResolverOf, reachCacheOf, reachPathsOf, setReached } from './reach.js';
19
19
  import { forkPluginsInput } from '../../forks/forks.schema.js';
20
20
  import { planSpeedKey } from './speed.js';
21
- import { exploreLimitsProvideKey, explorePathsProvideKey, exploreSeedProvideKey, judgeFilesProvideKey, judgeCoordinators, judgeRedundantProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, ownExtension, phaseProvideKey, recordTestFilesProvideKey, recordPathOf, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './vitest.js';
22
- import { exploreLimitsInput } from '../../explore/limits.operations.js';
23
- import { clearExploreRuns } from '../../explore/edges/explore.db.js';
24
- import { markedExploreOf, missingVitestOf, staleExploreOf } from '../refusals.js';
21
+ import { pluginMetaKeyProvideKey, judgeFilesProvideKey, judgeCoordinators, judgeRedundantProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, ownExtension, phaseProvideKey, recordTestFilesProvideKey, recordPathOf, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './vitest.js';
22
+ import { markedPluginOf, missingVitestOf, stalePluginOf } from '../refusals.js';
25
23
  // The judge folder, holding the counters, the runner and crush's merge and report tests.
26
24
  const judgeFolder = join(import.meta.dirname, '..');
27
25
  const countersPath = join(judgeFolder, `counters${ownExtension}`);
28
26
  const runnerPath = join(judgeFolder, `runner${ownExtension}`);
29
27
  const reportTest = `report.test${ownExtension}`;
30
28
  const stressesTest = `stresses.test${ownExtension}`;
31
- const exploreTest = `explore.test${ownExtension}`;
32
- const commandTests = [...judgeCoordinators, reportTest, stressesTest, exploreTest].map((name) => join(judgeFolder, name));
29
+ const commandTests = [...judgeCoordinators, reportTest, stressesTest].map((name) => join(judgeFolder, name));
33
30
  // Matches crush's counters and runner, which Vitest must load natively rather than through Vite: the counters so each test file's run and its runner share one copy, the runner so what it imports is never instrumented, even when crush checks itself.
34
31
  export const nativePattern = /\/judge\/(counters|runner)\.[jt]s$/;
35
32
  // Matches a source crush never gates: one in an edges or fixtures folder, which the project tests by integration, or one that loads natively and never runs instrumented.
@@ -79,9 +76,9 @@ export const toolHashOf = () => {
79
76
  toolHash ||= toolHashIn(crushSrc);
80
77
  return toolHash;
81
78
  };
82
- // An explore serves the code its record was planned with and writes no row the record owns, so a source edited since refuses it, naming the record that catches it up.
83
- // An explore reads what the record's tests passed and threw, so it refuses a record made from other sources than these: a planned one, or any file a test file loaded, an edges file its sources import among them.
84
- const exploredPlanOf = (root, record, kept, fileHashes) => {
79
+ // A plugin's run serves the code its record was planned with and writes no row the record owns, so a source edited since refuses it, naming the record that catches it up.
80
+ // A plugin reads what the record's tests passed and threw, so it refuses a record made from other sources than these: a planned one, or any file a test file loaded, an edges file its sources import among them.
81
+ const pluginPlanOf = (name, root, record, kept, fileHashes) => {
85
82
  const isChanged = ({ path, hash }) => {
86
83
  const known = fileHashes.get(path);
87
84
  if (known !== undefined)
@@ -96,12 +93,12 @@ const exploredPlanOf = (root, record, kept, fileHashes) => {
96
93
  const changedPlanned = getPlan(record).files.flatMap((file) => (isChanged(file) ? [file.path] : []));
97
94
  const changed = [...new Set([...changedPlanned, ...changedReads])];
98
95
  const named = changed.length ? changed.join(' ') : '<paths>';
99
- return failed(staleExploreOf(named));
96
+ return failed(stalePluginOf(name, named));
100
97
  }
101
98
  const served = new Map(kept.map(({ path, hash, code }) => [path, { code, plan: { hash } }]));
102
99
  return { data: { byPath: served, hash: planKeyOf(served), cached: true }, error: null };
103
100
  };
104
- const plannedOf = async (root, record, reach, write, explore, testFiles) => {
101
+ const plannedOf = async (root, record, reach, write, plugin, testFiles) => {
105
102
  const byPath = new Map();
106
103
  let pointBase = 0;
107
104
  let siteBase = 0;
@@ -125,8 +122,8 @@ const plannedOf = async (root, record, reach, write, explore, testFiles) => {
125
122
  const plugins = hashOf(JSON.stringify(resolver ? [reach.plugins, resolver.basis] : reach.plugins));
126
123
  const cacheKey = planCacheKeyOf({ files, settings, plugins, tool: `${toolHashOf()}|${countersPath}` });
127
124
  const kept = getPlanCodesNullable(record, cacheKey);
128
- if (explore)
129
- return exploredPlanOf(root, record, kept, fileHashes);
125
+ if (plugin)
126
+ return pluginPlanOf(plugin.name, root, record, kept, fileHashes);
130
127
  const reached = async () => {
131
128
  const { data, error } = resolver ? { data: resolver, error: null } : await resolve();
132
129
  if (error)
@@ -207,23 +204,7 @@ const projectVitestPlugin = (root, discoverTests) => {
207
204
  resolveId: (source, importer) => (source === 'vite-plus/test' && importer?.startsWith(judgeFolder) ? vitest : null),
208
205
  };
209
206
  };
210
- // The paths a related explore names, from the project's root, leaving out the phases crush adds to Vitest's filter, or null for a full explore.
211
- // Vitest starts every project's configureVitest together, so each reads the paths off the filter itself rather than waiting on another.
212
- const namedPathsOf = (root, related) => {
213
- if (!related)
214
- return null;
215
- const named = related.map((path) => resolve(root, path)).filter((path) => !path.startsWith(judgeFolder));
216
- return named.map((path) => relative(root, path));
217
- };
218
- // Hands the explore project Vitest's `--sequence.seed`, which its search draws from, so a seed given on the command line repeats a run, and the paths a related explore names.
219
- const exploreSeedPlugin = (root) => ({
220
- name: 'crush:explore-seed',
221
- configureVitest: ({ vitest, project }) => {
222
- project.provide(exploreSeedProvideKey, vitest.config.sequence.seed);
223
- project.provide(explorePathsProvideKey, namedPathsOf(root, vitest.config.related));
224
- },
225
- });
226
- export const crushPlugin = ({ root, entries, jsx, plugins, steps, mutation, explore, discoverTests }) => {
207
+ export const crushPlugin = ({ root, entries, jsx, plugins, steps, mutation, plugin, discoverTests }) => {
227
208
  let planned = null;
228
209
  let planning = null;
229
210
  let record = null;
@@ -233,7 +214,7 @@ export const crushPlugin = ({ root, entries, jsx, plugins, steps, mutation, expl
233
214
  const recordOf = () => {
234
215
  if (record)
235
216
  return record;
236
- if (!explore) {
217
+ if (!plugin) {
237
218
  record = write(() => openRecord(recordPathOf(root)));
238
219
  return record;
239
220
  }
@@ -250,7 +231,7 @@ export const crushPlugin = ({ root, entries, jsx, plugins, steps, mutation, expl
250
231
  if (planning)
251
232
  return planning;
252
233
  const started = performance.now();
253
- planning = plannedOf(root, recordOf(), { entries, jsx, resolveImport: imports.resolve, cache, plugins, steps, mutation }, write, explore, testFiles)
234
+ planning = plannedOf(root, recordOf(), { entries, jsx, resolveImport: imports.resolve, cache, plugins, steps, mutation }, write, plugin, testFiles)
254
235
  .then(({ data, error }) => {
255
236
  const ms = performance.now() - started;
256
237
  if (data?.cached) {
@@ -276,29 +257,23 @@ export const crushPlugin = ({ root, entries, jsx, plugins, steps, mutation, expl
276
257
  name: 'crush',
277
258
  enforce: 'pre',
278
259
  config: () => ({ test: { server: { deps: { external: [nativePattern] } } } }),
279
- configResolved: (config) => {
280
- // A config that selects the record project for explore would run a record under `--mode explore`, which reads as an explore that found nothing, so that run is refused.
281
- if (config.mode === 'explore' && !explore)
282
- throw new Error('crush ran under --mode explore with record projects; use exploreProject');
283
- },
284
260
  watchChange: () => imports?.clear(),
285
261
  configureVitest: async ({ vitest, project, defineCacheKeyGenerator }) => {
286
- if (!explore)
262
+ if (!plugin)
287
263
  root = project.config.root;
288
264
  imports = cachedImportsOf((id, importer) => project.vite.pluginContainer.resolveId(id, importer, { ssr: true }));
289
265
  testFiles = new Set(await discoverTests(project));
290
266
  publish = () => project.provide(planSpeedKey, { ...speed });
291
267
  // A part stands only while its test file does, so a deleted file's part goes before anything reads the parts, and the sites it caught fall to the files left.
292
268
  const db = recordOf();
293
- if (explore) {
269
+ if (plugin) {
294
270
  const markers = getWorking(db).length;
295
271
  if (markers)
296
- throw new Error(markedExploreOf(markers));
272
+ throw new Error(markedPluginOf(plugin.name, markers));
297
273
  const initial = await (planning ?? planned ?? replan());
298
274
  if (vitest.config.related)
299
- vitest.config.related = [...new Set([...vitest.config.related, join(judgeFolder, exploreTest)])];
275
+ vitest.config.related = [...new Set([...vitest.config.related, plugin.coordinator])];
300
276
  defineCacheKeyGenerator?.(() => (planned ?? initial).hash);
301
- clearExploreRuns(db);
302
277
  return;
303
278
  }
304
279
  clearGoneTestFiles(db, root, write);
@@ -346,6 +321,14 @@ const discoverTestsOf = ({ root, include, exclude = [] }) => {
346
321
  let files;
347
322
  return (project) => (files ??= project.globFiles(include, ['**/node_modules/**', ...exclude, ...commandTests], root).then((paths) => paths.map((path) => relative(root, path).replaceAll('\\', '/')).toSorted()));
348
323
  };
324
+ // The paths a related command names, from the project's root, leaving out the phases crush adds to Vitest's filter, or null for a full run.
325
+ // Vitest starts every project's configureVitest together, so each reads the paths off the filter itself rather than waiting on another.
326
+ const namedPathsOf = (root, related) => {
327
+ if (!related)
328
+ return null;
329
+ const named = related.map((path) => resolve(root, path)).filter((path) => !path.startsWith(judgeFolder));
330
+ return named.map((path) => relative(root, path));
331
+ };
349
332
  const relatedPathsOf = ({ vitest, root, own }) => {
350
333
  const named = namedPathsOf(root, vitest.config.related) ?? [];
351
334
  if (vitest.config.related)
@@ -382,7 +365,7 @@ const recordProjectWithTests = ({ root, include, entries, jsx = false, exclude =
382
365
  const plugins = forkPluginsInput.parse(forks);
383
366
  const mutation = mutationSettingsInput.parse(written);
384
367
  return {
385
- plugins: [projectVitestPlugin(root), crushPlugin({ root, entries, jsx, plugins, steps, mutation, explore: false, discoverTests })],
368
+ plugins: [projectVitestPlugin(root), crushPlugin({ root, entries, jsx, plugins, steps, mutation, plugin: null, discoverTests })],
386
369
  test: {
387
370
  name: 'record',
388
371
  root,
@@ -418,21 +401,23 @@ export const judgeProject = (input) => {
418
401
  test: { ...project.test, name: 'judge', include: coordinators, exclude: [], provide: { ...Object(project.test.provide), [phaseProvideKey]: 'judge', [judgeRelatedProvideKey]: [] } },
419
402
  };
420
403
  };
421
- export const exploreProject = ({ root, include, exclude, entries, jsx = false, removableTests = 'all', steps = true, forks = [], mutation: written = {}, explore = {} }) => {
404
+ // Another plugin's command: its coordinator test runs under the plugin's mode against the planned record, with the counters loaded and every recorded test file declaring its meta key on the test context.
405
+ export const pluginProject = ({ name, coordinator, metaKey, root, include, exclude, entries, jsx = false, removableTests = 'all', steps = true, forks = [], mutation: written = {} }) => {
422
406
  const plugins = forkPluginsInput.parse(forks);
423
407
  const mutation = mutationSettingsInput.parse(written);
424
408
  return {
425
- plugins: [projectVitestPlugin(root), crushPlugin({ root, entries, jsx, plugins, steps, mutation, explore: true, discoverTests: discoverTestsOf({ root, include, exclude }) }), exploreSeedPlugin(root)],
409
+ plugins: [projectVitestPlugin(root), crushPlugin({ root, entries, jsx, plugins, steps, mutation, plugin: { name, coordinator }, discoverTests: discoverTestsOf({ root, include, exclude }) })],
426
410
  test: {
427
- name: 'explore',
428
- root: judgeFolder,
429
- include: [exploreTest],
411
+ name,
412
+ root,
413
+ include: [coordinator],
414
+ exclude: [],
430
415
  runner: runnerPath,
431
416
  ...workers,
432
417
  provide: {
433
418
  [rootProvideKey]: root,
434
419
  [phaseProvideKey]: 'property',
435
- [exploreLimitsProvideKey]: exploreLimitsInput.parse(explore),
420
+ [pluginMetaKeyProvideKey]: metaKey,
436
421
  [removableTestsProvideKey]: removableTests,
437
422
  [rulesProvideKey]: rulesKeyOf({ version: recordVersion, tool: toolHashOf(), settings: { steps, forks: plugins, mutation } }),
438
423
  },
@@ -0,0 +1,2 @@
1
+ import '../provided.ts';
2
+ export * from './plugin.ts';
@@ -0,0 +1,2 @@
1
+ import '../provided.js';
2
+ export * from './plugin.js';
@@ -5,9 +5,7 @@ export declare const rootProvideKey = "crushRoot";
5
5
  export declare const removableTestsProvideKey = "crushRemovableTests";
6
6
  export declare const stepsProvideKey = "crushSteps";
7
7
  export declare const recordTestFilesProvideKey = "crushRecordTestFiles";
8
- export declare const explorePathsProvideKey = "crushExplorePaths";
9
- export declare const exploreLimitsProvideKey = "crushExploreLimits";
10
- export declare const exploreSeedProvideKey = "crushExploreSeed";
8
+ export declare const pluginMetaKeyProvideKey = "crushPluginMetaKey";
11
9
  export declare const judgeFilesProvideKey = "crushJudgeFiles";
12
10
  export declare const judgeRelatedProvideKey = "crushJudgeRelated";
13
11
  export declare const questionsRelatedProvideKey = "crushQuestionsRelated";
@@ -13,9 +13,8 @@ export const removableTestsProvideKey = 'crushRemovableTests';
13
13
  // Whether the report asks each test's step questions.
14
14
  export const stepsProvideKey = 'crushSteps';
15
15
  export const recordTestFilesProvideKey = 'crushRecordTestFiles';
16
- export const explorePathsProvideKey = 'crushExplorePaths';
17
- export const exploreLimitsProvideKey = 'crushExploreLimits';
18
- export const exploreSeedProvideKey = 'crushExploreSeed';
16
+ // The meta key a plugin's tests declare, whose files the runner loads for its coordinator.
17
+ export const pluginMetaKeyProvideKey = 'crushPluginMetaKey';
19
18
  export const judgeFilesProvideKey = 'crushJudgeFiles';
20
19
  export const judgeRelatedProvideKey = 'crushJudgeRelated';
21
20
  // The paths a related questions run names, from Vitest's own `related` filter, whose reach the report shows alone.
@@ -1,4 +1,4 @@
1
- type HintCommand = 'record' | 'judge' | 'questions' | 'explore';
1
+ type HintCommand = 'record' | 'judge' | 'questions';
2
2
  export type HintsInput = {
3
3
  command: HintCommand;
4
4
  isPassed: boolean;
@@ -3,7 +3,6 @@ const hints = {
3
3
  record: 'hint: judge reuses every verdict whose basis still holds, so after an edit a related record and judge cost only what the edit reaches',
4
4
  judge: 'hint: questions lists each open question with its printed answers, and one answer near the top can settle questions farther down',
5
5
  questions: "hint: answer with a test for behavior that must stay, with simpler code for behavior that can go, and with a justification only when no input can answer; ask the user, with the question's id and both readings, when the code's intent is unknown",
6
- explore: 'hint: each finding is a question, answered by a test that pins the input explore found',
7
6
  };
8
7
  // Matches a path a shell reads as one word with no quoting.
9
8
  export const plainPathPattern = /^[\w./@+-]+$/;
@@ -21,8 +20,6 @@ const stepsOf = ({ command, isPassed, related, open, firstFile }) => {
21
20
  return { next: `step 2 of 3, judge: fix each failure printed above these lines, then run \`vp run judge${scope}\` again`, dont: [unedited] };
22
21
  if (command === 'judge')
23
22
  return { next: `step 3 of 3, questions: run \`vp run questions${scope}\` and answer each question from the top`, dont: ['answer from an earlier report, since judging may have settled or opened questions'] };
24
- if (command === 'explore')
25
- return { next: `step 3 of 3, questions: run \`vp run questions${scope}\` to read explore's findings with the other questions`, dont: ["gate a release on explore's findings, since explore is experimental"] };
26
23
  if (!isPassed && !open)
27
24
  return { next: `step 3 of 3, questions: fix each failure printed above these lines, then run \`vp run questions${scope}\` again`, dont: [unedited] };
28
25
  if (!open)
@@ -1,3 +1,4 @@
1
+ import type { TaskMeta } from 'vite-plus/test';
1
2
  import { z } from 'zod';
2
3
  export declare const candidateInput: z.ZodObject<{
3
4
  key: z.ZodString;
@@ -111,7 +112,6 @@ export declare const judgedInput: z.ZodObject<{
111
112
  }, z.core.$strip>>;
112
113
  outside: z.ZodArray<z.ZodString>;
113
114
  changed: z.ZodArray<z.ZodString>;
114
- properties: z.ZodArray<z.ZodString>;
115
115
  failure: z.ZodNullable<z.ZodString>;
116
116
  assignees: z.ZodArray<z.ZodObject<{
117
117
  source: z.ZodString;
@@ -132,4 +132,13 @@ export declare const verifiedInput: z.ZodObject<{
132
132
  }, z.core.$strip>>;
133
133
  }, z.core.$strip>;
134
134
  export type Verified = z.infer<typeof verifiedInput>;
135
+ export type LoadedTestFile = {
136
+ file: string;
137
+ source: string;
138
+ module: unknown;
139
+ tests: {
140
+ name: string;
141
+ meta: TaskMeta;
142
+ }[];
143
+ };
135
144
  export {};
@@ -104,8 +104,6 @@ export const judgedInput = z.object({
104
104
  outside: z.array(keyInput),
105
105
  // The sources this file's run loaded that changed during it, whose stale plan left every site of the part unjudged and its tests' steps unmeasured.
106
106
  changed: z.array(keyInput),
107
- // The exports this file's tests declare as explore properties, by name.
108
- properties: z.array(z.string().min(1)),
109
107
  // Why the file failed outside its tests, as a throwing suite hook, null when it did not, so a record whose file failed never passes.
110
108
  failure: z.string().max(65_536).nullable(),
111
109
  // The test file judging each source this file's run reached, as the run found it, so a partial record knows when that has moved.
@@ -0,0 +1,31 @@
1
+ import { pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey } from './edges/vitest.ts';
2
+ import type { LoadedTestFile, RemovableTests } from './judge.schema.ts';
3
+ import { type BaselineSpeed, type JudgeSpeed, type PlanSpeed, planSpeedKey } from './edges/speed.ts';
4
+ import type { CrushTaskMeta } from './task-meta.ts';
5
+ declare module 'vite-plus/test' {
6
+ interface TestContext {
7
+ crushLoadedTestFiles?: LoadedTestFile[];
8
+ }
9
+ interface TaskMeta extends CrushTaskMeta {
10
+ crushBaselineSpeed?: BaselineSpeed;
11
+ crushJudgeSpeed?: JudgeSpeed;
12
+ crushOpen?: number;
13
+ crushOpenIn?: string;
14
+ }
15
+ interface ProvidedContext {
16
+ [vitestProvideKey]: string;
17
+ [phaseProvideKey]: 'record' | 'judge' | 'verify' | 'property';
18
+ [rulesProvideKey]: string;
19
+ [rootProvideKey]: string;
20
+ [removableTestsProvideKey]: RemovableTests;
21
+ [stepsProvideKey]: boolean;
22
+ [recordTestFilesProvideKey]: string[];
23
+ [pluginMetaKeyProvideKey]: string;
24
+ [judgeFilesProvideKey]: string[];
25
+ [judgeShardsProvideKey]: number;
26
+ [judgeRelatedProvideKey]: string[];
27
+ [questionsRelatedProvideKey]: string[];
28
+ [judgeRedundantProvideKey]: boolean;
29
+ [planSpeedKey]: PlanSpeed;
30
+ }
31
+ }
@@ -0,0 +1,2 @@
1
+ import { pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './edges/vitest.js';
2
+ import { planSpeedKey } from './edges/speed.js';
@@ -9,6 +9,6 @@ export declare const stalePlanOf: (paths: readonly string[]) => string;
9
9
  export declare const changedDuringRunOf: (paths: readonly string[]) => string;
10
10
  export declare const failedJudgingOf: (count: number) => string;
11
11
  export declare const missingVitestOf: (root: string) => string;
12
- export declare const staleExploreOf: (named: string) => string;
13
- export declare const markedExploreOf: (markers: number) => string;
12
+ export declare const stalePluginOf: (name: string, named: string) => string;
13
+ export declare const markedPluginOf: (name: string, markers: number) => string;
14
14
  export {};
@@ -6,5 +6,5 @@ export const stalePlanOf = (paths) => `crush's plan is stale for ${paths.join(',
6
6
  export const changedDuringRunOf = (paths) => `crush's plan is stale, since these sources changed during the run: ${paths.join(', ')}. Their sites stay unjudged until \`vp run judge\` runs again.`;
7
7
  export const failedJudgingOf = (count) => `${count} test files failed during judging; make them pass, then run \`vp run judge\` again`;
8
8
  export const missingVitestOf = (root) => `crush found no vite-plus/test from ${root}; install it with \`vp add -D vite-plus\``;
9
- export const staleExploreOf = (named) => `the record was made from other sources than these, so explore stops; run \`vp run record:related ${named}\` first`;
10
- export const markedExploreOf = (markers) => `a record still holds ${markers} ${markers === 1 ? 'marker' : 'markers'}, so explore stops; let it finish, or run \`vp run record\` if it stopped`;
9
+ export const stalePluginOf = (name, named) => `the record was made from other sources than these, so ${name} stops; run \`vp run record:related ${named}\` first`;
10
+ export const markedPluginOf = (name, markers) => `a record still holds ${markers} ${markers === 1 ? 'marker' : 'markers'}, so ${name} stops; let it finish, or run \`vp run record\` if it stopped`;
@@ -57,7 +57,7 @@ import { describe, expect, inject, it } from 'vite-plus/test';
57
57
  import { readJustifications } from '../justify/edges/load.js';
58
58
  import { refreshEntry } from '../justify/edges/refresh.fs.js';
59
59
  import { basisOf, justifiedOf } from '../justify/justify.operations.js';
60
- import { answerChoicesOf, answerProblemsOf, exploreCaughtOf, exploreQuestionsOf, pathQuestionsOf, siteQuestionsOf, stepsQuestionsOf, testQuestionsOf, unusedQuestionsOf } from '../questions/questions.operations.js';
60
+ import { answerChoicesOf, answerProblemsOf, findingCaughtOf, findingQuestionsOf, pathQuestionsOf, siteQuestionsOf, stepsQuestionsOf, testQuestionsOf, unusedQuestionsOf } from '../questions/questions.operations.js';
61
61
  import { readJudgeEdges } from './edges/judge.edges.js';
62
62
  import { hasRefusal, readJudgeSourceNullable } from './edges/judge.fs.js';
63
63
  import { recordPathOf, questionsRelatedProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, stepsProvideKey } from './edges/vitest.js';
@@ -66,7 +66,7 @@ import { phaseRootInput, removableTestsInput, stepsSettingInput } from './judge.
66
66
  import { testRootPattern } from './edges/reach.js';
67
67
  import { reachedFrom } from '../graph/symbols/symbols.js';
68
68
  import { fileKey } from '../graph/symbols/keys.js';
69
- import { hashOf, unitFieldsOf, unitKeyOf } from '../record/record.operations.js';
69
+ import { hashOf, unitFieldsOf } from '../record/record.operations.js';
70
70
  import { entryAt, itemAt } from '../utils/lookup.js';
71
71
  import { noSplitsOf, sameResultsOf, uncomparedOf } from '../record/path-checks.operations.js';
72
72
  import { loopKinds } from '../decisions/kinds.js';
@@ -80,7 +80,7 @@ const recordPath = recordPathOf(root);
80
80
  const opened = readJudgeEdges(recordPath);
81
81
  if (opened.error)
82
82
  throw opened.error;
83
- var edges, stillWorking, plan, runs, testFiles, currentHashOf, stale, merged, statusOf, candidates, candidatesHash, checks, drops, dropped, basis, isCurrent, checkedFiles, isVerified, falling, liveSources, liveSourceOf, isLive, isLiveVerified, collapses, holding, heldNow, heldKeys, isAnyLeft, takenPoints, covered, observed, sites, judged, reachNodes, plannedTests, unused, plannedHashOf, explored, exportCalls, loopSites, pathFindingsOf, pathQuestions, all, entries, justifyError, sourceHashes, bases, justified, refreshProblems, refreshedIds, acceptedEntries, staleEntries, acceptedIds, staleIds, asked, open, acceptedQuestions, reasonOf, positions, basisFor, liveIds, justifyProblems, caughtBy, reachedBy, note, crushesByDecision, catchingTests, properties, answers, graphIds, graphAnswers, answerFiles, answerReach, graphOutOf, graphOut, pathArgs, paths, visibleFiles, visible, isVisible, noteGraphReach, evidence, problems, refusedChoices, unsettledTests, tests, names, labelOf, measured, measuredTests, removableTests, keyOfLabel, readers, patternReaders, removalReach, shieldedFiles, isAskable, removable, testQuestions, outsideOf, counted, testMetaQuestions, justifiedSites, taken, figureLineOf;
83
+ var edges, stillWorking, plan, runs, testFiles, currentHashOf, stale, merged, statusOf, candidates, candidatesHash, checks, drops, dropped, basis, isCurrent, checkedFiles, isVerified, falling, liveSources, liveSourceOf, isLive, isLiveVerified, collapses, holding, heldNow, heldKeys, isAnyLeft, takenPoints, covered, observed, sites, judged, reachNodes, plannedTests, unused, plannedHashOf, currentFindings, findingQuestions, exportCalls, loopSites, pathFindingsOf, pathQuestions, all, entries, justifyError, sourceHashes, bases, justified, refreshProblems, refreshedIds, acceptedEntries, staleEntries, acceptedIds, staleIds, asked, open, acceptedQuestions, reasonOf, positions, basisFor, liveIds, justifyProblems, caughtBy, reachedBy, note, crushesByDecision, catchingTests, properties, answers, graphIds, graphAnswers, answerFiles, answerReach, graphOutOf, graphOut, pathArgs, paths, visibleFiles, visible, isVisible, noteGraphReach, evidence, problems, refusedChoices, unsettledTests, tests, names, labelOf, measured, measuredTests, removableTests, keyOfLabel, readers, patternReaders, removalReach, shieldedFiles, isAskable, removable, testQuestions, outsideOf, counted, testMetaQuestions, justifiedSites, taken, figureLineOf;
84
84
  const env_1 = { stack: [], error: void 0, hasError: false };
85
85
  try {
86
86
  edges = __addDisposableResource(env_1, opened.data, false);
@@ -166,7 +166,8 @@ try {
166
166
  plannedTests = new Set(plan.tests.map(({ path }) => path));
167
167
  unused = unusedQuestionsOf(reachNodes.filter(({ file }) => !plannedTests.has(file) && !testRootPattern.test(file)));
168
168
  plannedHashOf = new Map([...plan.files, ...plan.tests].map(({ path, hash }) => [path, hash]));
169
- explored = exploreQuestionsOf(edges.getFindings().filter(({ file, sourceHash }) => plannedHashOf.get(file) === sourceHash));
169
+ currentFindings = edges.getFindings().filter(({ file, sourceHash }) => plannedHashOf.get(file) === sourceHash);
170
+ findingQuestions = findingQuestionsOf(currentFindings);
170
171
  exportCalls = edges.getExportCalls();
171
172
  // The fork points that test a loop, which no-split never asks of, by the same key a call's steps name their site with.
172
173
  loopSites = new Set(plan.files.flatMap(({ path, points }) => points.filter(({ kind }) => loopKinds.has(kind)).map(({ decision }) => pointKeyOf(path, decision))));
@@ -184,7 +185,7 @@ try {
184
185
  }));
185
186
  };
186
187
  pathQuestions = pathFindingsOf();
187
- all = [...judged.all, ...unused.all, ...explored, ...pathQuestions];
188
+ all = [...judged.all, ...unused.all, ...findingQuestions, ...pathQuestions];
188
189
  // A justification answers its question without a test while it carries the basis the question rests on now: its source's text and every file its verdicts read.
189
190
  // The basis is written in the entry, so an edit to any of those files asks the question again, whatever the record holds, until the entry's basis is set to the one printed.
190
191
  ({ data: entries, error: justifyError } = readJustifications(runs));
@@ -209,7 +210,7 @@ try {
209
210
  staleEntries = justified.stale.filter(({ id }) => !refreshedIds.has(id));
210
211
  acceptedIds = new Set(acceptedEntries.map(({ id }) => id));
211
212
  staleIds = new Set(staleEntries.map(({ id }) => id));
212
- asked = [...judged.openWith(acceptedIds), ...unused.open, ...explored, ...pathQuestions];
213
+ asked = [...judged.openWith(acceptedIds), ...unused.open, ...findingQuestions, ...pathQuestions];
213
214
  open = asked.filter(({ id }) => !acceptedIds.has(id));
214
215
  acceptedQuestions = asked.filter(({ id }) => acceptedIds.has(id));
215
216
  reasonOf = new Map([...acceptedEntries, ...staleEntries].map(({ id, reason }) => [id, reason]));
@@ -217,7 +218,7 @@ try {
217
218
  basisFor = (question) => basisOf({ question, sourceHashes, bases, position: positions.get(question.id) });
218
219
  // An entry for a question a test or an edit already closed settles nothing, so it is asked to go.
219
220
  // A question folded under a fork whose entry went stale is still live, so its own entry is kept.
220
- liveIds = new Set([...judged.openWith(new Set([...acceptedIds, ...staleIds])), ...unused.open, ...explored, ...pathQuestions].map(({ id }) => id));
221
+ liveIds = new Set([...judged.openWith(new Set([...acceptedIds, ...staleIds])), ...unused.open, ...findingQuestions, ...pathQuestions].map(({ id }) => id));
221
222
  justifyProblems = [...justified.problems, ...refreshProblems, ...[...acceptedEntries, ...staleEntries].filter(({ id }) => !liveIds.has(id)).map(({ id }) => ({ id, problem: 'justifies a question no longer open, so remove it' }))];
222
223
  // Which tests caught each site and which reached it, read from every file's run, for checking each test's answer.
223
224
  caughtBy = new Map();
@@ -241,11 +242,9 @@ try {
241
242
  }
242
243
  // A catch in any part counts, even when another test supplied the merged verdict.
243
244
  catchingTests = new Set(caughtBy.values().flatMap((catchers) => catchers.values()));
244
- // A test answers an explore finding by throwing from its site, or by calling its property, in its own baseline.
245
- // A property counts as one once explore has run it, as its run's time or a finding of it shows.
246
- // A property counts as one where its test file declares it, which the record holds from the file's own tests, so a clean record credits an answer to it as a warm one does.
247
- properties = new Set(runs.flatMap(({ file, properties: declared }) => declared.map((name) => unitKeyOf(file, name))));
248
- for (const [key, tests] of exploreCaughtOf({ calls: exportCalls, properties }))
245
+ // A test answers a finding by throwing from its site, or by calling its property, in its own baseline.
246
+ properties = new Set(currentFindings.flatMap(({ key, kind }) => (kind === 'property' ? [key] : [])));
247
+ for (const [key, tests] of findingCaughtOf({ calls: exportCalls, properties }))
249
248
  for (const test of tests)
250
249
  note(caughtBy, key, test);
251
250
  answers = runs.flatMap(({ file, tests }) => tests.flatMap(({ key, answers: ids }) => ids.map((id) => ({ test: key, id, file }))));