@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
@@ -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, pluginMetaKeyProvideKey, 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,27 +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
- // Another plugin's command, as explore's own is: its coordinator test runs under the plugin's mode against the planned record, with the counters loaded.
422
- export const pluginProject = ({ name, coordinator, metaKey, ...options }) => {
423
- const project = exploreProject(options);
424
- return { ...project, test: { ...project.test, name, root: options.root, include: [coordinator], exclude: [], provide: { ...Object(project.test.provide), [pluginMetaKeyProvideKey]: metaKey } } };
425
- };
426
- 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 = {} }) => {
427
406
  const plugins = forkPluginsInput.parse(forks);
428
407
  const mutation = mutationSettingsInput.parse(written);
429
408
  return {
430
- 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 }) })],
431
410
  test: {
432
- name: 'explore',
433
- root: judgeFolder,
434
- include: [exploreTest],
411
+ name,
412
+ root,
413
+ include: [coordinator],
414
+ exclude: [],
435
415
  runner: runnerPath,
436
416
  ...workers,
437
417
  provide: {
438
418
  [rootProvideKey]: root,
439
419
  [phaseProvideKey]: 'property',
440
- [pluginMetaKeyProvideKey]: null,
441
- [exploreLimitsProvideKey]: exploreLimitsInput.parse(explore),
420
+ [pluginMetaKeyProvideKey]: metaKey,
442
421
  [removableTestsProvideKey]: removableTests,
443
422
  [rulesProvideKey]: rulesKeyOf({ version: recordVersion, tool: toolHashOf(), settings: { steps, forks: plugins, mutation } }),
444
423
  },
@@ -5,9 +5,6 @@ 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";
11
8
  export declare const pluginMetaKeyProvideKey = "crushPluginMetaKey";
12
9
  export declare const judgeFilesProvideKey = "crushJudgeFiles";
13
10
  export declare const judgeRelatedProvideKey = "crushJudgeRelated";
@@ -13,10 +13,7 @@ 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';
19
- // The meta key a plugin's tests declare, whose files the runner loads for its coordinator, or null for explore's own run.
16
+ // The meta key a plugin's tests declare, whose files the runner loads for its coordinator.
20
17
  export const pluginMetaKeyProvideKey = 'crushPluginMetaKey';
21
18
  export const judgeFilesProvideKey = 'crushJudgeFiles';
22
19
  export const judgeRelatedProvideKey = 'crushJudgeRelated';
@@ -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)
@@ -112,7 +112,6 @@ export declare const judgedInput: z.ZodObject<{
112
112
  }, z.core.$strip>>;
113
113
  outside: z.ZodArray<z.ZodString>;
114
114
  changed: z.ZodArray<z.ZodString>;
115
- properties: z.ZodArray<z.ZodString>;
116
115
  failure: z.ZodNullable<z.ZodString>;
117
116
  assignees: z.ZodArray<z.ZodObject<{
118
117
  source: z.ZodString;
@@ -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.
@@ -1,11 +1,9 @@
1
- import type { ExploreTarget } from '../explore/edges/explore.ts';
2
- import { exploreLimitsProvideKey, explorePathsProvideKey, exploreSeedProvideKey, pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey } from './edges/vitest.ts';
1
+ import { pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey } from './edges/vitest.ts';
3
2
  import type { LoadedTestFile, RemovableTests } from './judge.schema.ts';
4
3
  import { type BaselineSpeed, type JudgeSpeed, type PlanSpeed, planSpeedKey } from './edges/speed.ts';
5
4
  import type { CrushTaskMeta } from './task-meta.ts';
6
5
  declare module 'vite-plus/test' {
7
6
  interface TestContext {
8
- crushExploreProperties?: ExploreTarget[];
9
7
  crushLoadedTestFiles?: LoadedTestFile[];
10
8
  }
11
9
  interface TaskMeta extends CrushTaskMeta {
@@ -22,13 +20,7 @@ declare module 'vite-plus/test' {
22
20
  [removableTestsProvideKey]: RemovableTests;
23
21
  [stepsProvideKey]: boolean;
24
22
  [recordTestFilesProvideKey]: string[];
25
- [explorePathsProvideKey]: string[] | null;
26
- [exploreSeedProvideKey]: number;
27
- [pluginMetaKeyProvideKey]: string | null;
28
- [exploreLimitsProvideKey]: {
29
- maxTotalTime: number;
30
- runs: number;
31
- };
23
+ [pluginMetaKeyProvideKey]: string;
32
24
  [judgeFilesProvideKey]: string[];
33
25
  [judgeShardsProvideKey]: number;
34
26
  [judgeRelatedProvideKey]: string[];
@@ -1,2 +1,2 @@
1
- import { exploreLimitsProvideKey, explorePathsProvideKey, exploreSeedProvideKey, pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './edges/vitest.js';
1
+ import { pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './edges/vitest.js';
2
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, findingQuestionsOf, 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, currentFindings, 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);
@@ -167,7 +167,7 @@ try {
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
169
  currentFindings = edges.getFindings().filter(({ file, sourceHash }) => plannedHashOf.get(file) === sourceHash);
170
- explored = [...exploreQuestionsOf(currentFindings.filter(({ plugin }) => plugin === 'explore')), ...findingQuestionsOf(currentFindings.filter(({ plugin }) => plugin !== 'explore'))];
170
+ findingQuestions = findingQuestionsOf(currentFindings);
171
171
  exportCalls = edges.getExportCalls();
172
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.
173
173
  loopSites = new Set(plan.files.flatMap(({ path, points }) => points.filter(({ kind }) => loopKinds.has(kind)).map(({ decision }) => pointKeyOf(path, decision))));
@@ -185,7 +185,7 @@ try {
185
185
  }));
186
186
  };
187
187
  pathQuestions = pathFindingsOf();
188
- all = [...judged.all, ...unused.all, ...explored, ...pathQuestions];
188
+ all = [...judged.all, ...unused.all, ...findingQuestions, ...pathQuestions];
189
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.
190
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.
191
191
  ({ data: entries, error: justifyError } = readJustifications(runs));
@@ -210,7 +210,7 @@ try {
210
210
  staleEntries = justified.stale.filter(({ id }) => !refreshedIds.has(id));
211
211
  acceptedIds = new Set(acceptedEntries.map(({ id }) => id));
212
212
  staleIds = new Set(staleEntries.map(({ id }) => id));
213
- asked = [...judged.openWith(acceptedIds), ...unused.open, ...explored, ...pathQuestions];
213
+ asked = [...judged.openWith(acceptedIds), ...unused.open, ...findingQuestions, ...pathQuestions];
214
214
  open = asked.filter(({ id }) => !acceptedIds.has(id));
215
215
  acceptedQuestions = asked.filter(({ id }) => acceptedIds.has(id));
216
216
  reasonOf = new Map([...acceptedEntries, ...staleEntries].map(({ id, reason }) => [id, reason]));
@@ -218,7 +218,7 @@ try {
218
218
  basisFor = (question) => basisOf({ question, sourceHashes, bases, position: positions.get(question.id) });
219
219
  // An entry for a question a test or an edit already closed settles nothing, so it is asked to go.
220
220
  // A question folded under a fork whose entry went stale is still live, so its own entry is kept.
221
- 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));
222
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' }))];
223
223
  // Which tests caught each site and which reached it, read from every file's run, for checking each test's answer.
224
224
  caughtBy = new Map();
@@ -242,11 +242,9 @@ try {
242
242
  }
243
243
  // A catch in any part counts, even when another test supplied the merged verdict.
244
244
  catchingTests = new Set(caughtBy.values().flatMap((catchers) => catchers.values()));
245
- // A test answers an explore finding by throwing from its site, or by calling its property, in its own baseline.
246
- // A property counts as one once explore has run it, as its run's time or a finding of it shows.
247
- // 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.
248
- properties = new Set(runs.flatMap(({ file, properties: declared }) => declared.map((name) => unitKeyOf(file, name))));
249
- 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 }))
250
248
  for (const test of tests)
251
249
  note(caughtBy, key, test);
252
250
  answers = runs.flatMap(({ file, tests }) => tests.flatMap(({ key, answers: ids }) => ids.map((id) => ({ test: key, id, file }))));
@@ -73,8 +73,6 @@ import { eachInOrder, firstInOrder } from '../utils/order.js';
73
73
  import { CrushError, failed, thrownToVitest } from '../utils/errors.js';
74
74
  import { safeAsync } from '../utils/safe.js';
75
75
  import { clearedCalls, isLiteralJustification, loadId, setObservations, state, stepLimitOf } from './counters.js';
76
- import { exploreProperty, exploresMeta } from '../explore/edges/explore.js';
77
- import { explorableOf, graphOf } from '../explore/targets.operations.js';
78
76
  import { answerSitesOf, answeringRidersOf, backupRidersOf, candidatesHashOf, caughtOf, creditedOf, groupOf, fileFailureOf, runFailureOf, hookedOf, metaOf, pointKeyOf, ridersOf, ridingSidesOf, shareOf, suitedOf, stalePartsOf, runKeyOf, testDisplayNameOf, testFileOfKey, testKeyOf, testsUnderOf, timedOutPattern, } from './judge.operations.js';
79
77
  import {} from './judge.schema.js';
80
78
  import { droppedStrays } from './edges/strays.js';
@@ -82,7 +80,7 @@ import { hasRefusal, markRefusal, readJudgeSource, readJudgeSourceNullable } fro
82
80
  import { mergeJudged } from './edges/merge.js';
83
81
  import { browserModuleOutput, runnerModuleOutput, workerStateOutput } from './edges/vitest.schema.js';
84
82
  import { judgeSpeedOf, now } from './edges/speed.js';
85
- import { explorePathsProvideKey, pluginMetaKeyProvideKey, judgeCoordinators, judgeFilesProvideKey, judgeRedundantProvideKey, judgeRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordPathOf, rootProvideKey, rulesProvideKey, vitestProvideKey, } from './edges/vitest.js';
83
+ import { pluginMetaKeyProvideKey, judgeCoordinators, judgeFilesProvideKey, judgeRedundantProvideKey, judgeRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordPathOf, rootProvideKey, rulesProvideKey, vitestProvideKey, } from './edges/vitest.js';
86
84
  import { changedDuringRunOf, failedJudgingOf, stalePlanOf } from './refusals.js';
87
85
  // This file loads natively from crush's own tree, where `vite-plus/test` names crush's copy, and the project's tests register with the copy the plugin resolved from the project, whose test functions only that copy can hand back.
88
86
  // The values the command project provides reach the worker whichever copy reads them, so crush's own `inject` finds the project's copy.
@@ -379,7 +377,6 @@ export default function CrushRunner(config) {
379
377
  keys: new Map(),
380
378
  displaySeen: new Map(),
381
379
  unfound: [],
382
- properties: [],
383
380
  loadTicks: 0,
384
381
  refusal: null,
385
382
  staleLoads: new Map(),
@@ -426,7 +423,6 @@ export default function CrushRunner(config) {
426
423
  session.keys = testKeysIn(runner.config.root, files);
427
424
  session.displaySeen.clear();
428
425
  session.unfound = [];
429
- session.properties = [];
430
426
  };
431
427
  // A suite's `beforeAll` and `afterAll` run under the suite's own id, which judging credits to every test under it.
432
428
  const onBeforeRunSuite = async (suite) => {
@@ -493,18 +489,10 @@ export default function CrushRunner(config) {
493
489
  const onBeforeRunTask = async (task) => {
494
490
  await base.onBeforeRunTask(task);
495
491
  if (phase === 'property') {
496
- const metaKey = inject(pluginMetaKeyProvideKey);
497
- if (metaKey !== null) {
498
- const { data: loaded, error: loadError } = await loadTestFilesDeclaring(metaKey);
499
- if (loadError)
500
- thrownToVitest(loadError);
501
- task.context.crushLoadedTestFiles = loaded;
502
- return;
503
- }
504
- const { data, error } = await exploreProperties();
505
- if (error)
506
- thrownToVitest(error);
507
- task.context.crushExploreProperties = data;
492
+ const { data: loaded, error: loadError } = await loadTestFilesDeclaring(inject(pluginMetaKeyProvideKey));
493
+ if (loadError)
494
+ thrownToVitest(loadError);
495
+ task.context.crushLoadedTestFiles = loaded;
508
496
  return;
509
497
  }
510
498
  if (judgeFiles && !session.isRunningPass) {
@@ -530,13 +518,6 @@ export default function CrushRunner(config) {
530
518
  const { data: stated, error: refusal } = metaOf(task.meta);
531
519
  if (refusal)
532
520
  thrownToVitest(new CrushError(`${key}: ${refusal.message}`));
533
- // A property's declaration is refused here, where its meta enters, so a misspelled one never explores in silence.
534
- if (task.meta.explores !== undefined) {
535
- const declared = exploresMeta.safeParse(task.meta);
536
- if (!declared.success)
537
- thrownToVitest(new CrushError(`${key}: its explore meta is no property declaration: ${declared.error.message}`));
538
- session.properties.push({ meta: declared.data, key });
539
- }
540
521
  const fn = TestRunner.getTestFn(task);
541
522
  // The copy that registered the test hands its function back, so another copy gives none.
542
523
  if (fn === undefined) {
@@ -974,7 +955,6 @@ export default function CrushRunner(config) {
974
955
  assignees: [],
975
956
  sequence: { generation: 0, units: [] },
976
957
  failure: fileFailureOf(testFile),
977
- properties: session.properties.map(({ meta }) => meta.explores),
978
958
  };
979
959
  };
980
960
  // Writes the parts of this shard's files with the verdicts each holds, once every shard saved the verdicts of its sites.
@@ -1449,7 +1429,6 @@ export default function CrushRunner(config) {
1449
1429
  assignees: [],
1450
1430
  sequence: { generation, units: [] },
1451
1431
  failure: refusal.message,
1452
- properties: session.properties.map(({ meta }) => meta.explores),
1453
1432
  }, { calls: [], clearVerification: false, clearFailure: session.pass === 'record' && session.ran.size > 0 });
1454
1433
  return refusal;
1455
1434
  };
@@ -1493,46 +1472,6 @@ export default function CrushRunner(config) {
1493
1472
  return { data: null, error: loadError };
1494
1473
  return { data: files, error: null };
1495
1474
  };
1496
- // Collects declarations from eligible recorded test modules without executing their tests.
1497
- const exploreProperties = async () => {
1498
- const { data: edges, error } = currentEdgesOf();
1499
- if (error)
1500
- return { data: null, error };
1501
- const targets = [];
1502
- const graph = graphOf({ nodes: edges.getReachNodes(), edges: edges.getReachEdges() });
1503
- const paths = inject(explorePathsProvideKey);
1504
- const related = paths === null ? null : new Set(paths);
1505
- const seedsOf = edges.getSeeds();
1506
- // Vitest's shared runner collects one file at a time, so the files load in turn, stopping at the first that cannot.
1507
- const collectTargets = async ({ file, properties }) => {
1508
- const keys = properties.map((name) => unitKeyOf(file, name)).filter((key) => seedsOf.has(key));
1509
- const allowed = new Set(explorableOf({ ...graph, keys, paths: related }).map(({ key }) => key));
1510
- if (!allowed.size)
1511
- return null;
1512
- const { data: loaded, error: loadError } = await loadTestFile(file);
1513
- if (loadError)
1514
- return loadError;
1515
- const { source, module } = loaded;
1516
- for (const task of loaded.tests) {
1517
- const declaration = exploresMeta.safeParse(task.meta);
1518
- if (!declaration.success)
1519
- continue;
1520
- const meta = declaration.data;
1521
- const key = unitKeyOf(file, meta.explores);
1522
- if (!allowed.has(key))
1523
- continue;
1524
- if (meta.twin && !explorableOf({ ...graph, keys: [unitKeyOf(file, meta.twin.related)], paths: null }).length)
1525
- continue;
1526
- const seeds = entryAt(seedsOf, key, 'the recorded property arguments');
1527
- targets.push({ key, search: exploreProperty({ file, source, module, meta, seeds, seed: runner.config.sequence.seed }) });
1528
- }
1529
- return null;
1530
- };
1531
- const collectError = await firstInOrder(edges.getJudged({ withHits: false }), collectTargets);
1532
- if (collectError)
1533
- return { data: null, error: collectError };
1534
- return { data: targets, error: null };
1535
- };
1536
1475
  // Reruns this file's passing tests with every candidate crush forced together, and when one fails, keeps the candidates one at a time in order, dropping each that a test fails with.
1537
1476
  const verifyFile = async (edges, first, candidates, candidateHash) => {
1538
1477
  const root = runner.config.root;
@@ -5,10 +5,4 @@ export type CrushTaskMeta = {
5
5
  keeps?: string;
6
6
  steps?: number;
7
7
  stepsReason?: string;
8
- explores?: string;
9
- twin?: {
10
- first: string;
11
- second: string;
12
- related: string;
13
- };
14
8
  };
@@ -52,15 +52,12 @@ export declare const unusedQuestionsOf: (nodes: ReachNodeOutput[]) => {
52
52
  all: Asked[];
53
53
  open: Asked[];
54
54
  };
55
- export type ExploreFinding = {
55
+ export type PluginFinding = {
56
56
  key: string;
57
57
  file: string;
58
58
  line: number;
59
59
  function: string;
60
60
  input: string;
61
- };
62
- export declare const exploreQuestionsOf: (all: readonly ExploreFinding[], kind?: 'explore' | 'finding') => Asked[];
63
- type PluginFinding = ExploreFinding & {
64
61
  plugin: string;
65
62
  };
66
63
  export declare const findingQuestionsOf: (all: readonly PluginFinding[]) => Asked[];
@@ -80,7 +77,7 @@ type CaughtInput = {
80
77
  calls: readonly CaughtCall[];
81
78
  properties: ReadonlySet<string>;
82
79
  };
83
- export declare const exploreCaughtOf: ({ calls, properties }: CaughtInput) => Map<string, Set<string>>;
80
+ export declare const findingCaughtOf: ({ calls, properties }: CaughtInput) => Map<string, Set<string>>;
84
81
  export declare const reachingKinds: ReadonlySet<string>;
85
82
  export type Answer = {
86
83
  test: string;