@whaaaley/crush 0.2.7 → 0.3.0-next.10
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.
- package/README.md +48 -0
- package/dist/crush.tables.d.ts +16 -0
- package/dist/crush.tables.js +3 -1
- package/dist/explore/edges/explore.d.ts +0 -7
- package/dist/explore/edges/explore.db.d.ts +9 -4
- package/dist/explore/edges/explore.db.js +8 -6
- package/dist/explore/edges/explore.js +1 -89
- package/dist/judge/counters.d.ts +6 -0
- package/dist/judge/counters.js +88 -0
- package/dist/judge/edges/api.d.ts +23 -3
- package/dist/judge/edges/api.js +19 -5
- package/dist/judge/edges/judge.edges.d.ts +2 -2
- package/dist/judge/edges/plugin.d.ts +6 -0
- package/dist/judge/edges/plugin.js +7 -1
- package/dist/judge/edges/plugin.npm.d.ts +2 -0
- package/dist/judge/edges/plugin.npm.js +2 -0
- package/dist/judge/edges/vitest.d.ts +1 -0
- package/dist/judge/edges/vitest.js +2 -0
- package/dist/judge/explore.test.js +2 -2
- package/dist/judge/judge.schema.d.ts +10 -0
- package/dist/judge/provided.d.ts +39 -0
- package/dist/judge/provided.js +2 -0
- package/dist/judge/report.test.js +4 -3
- package/dist/judge/runner.js +52 -14
- package/dist/questions/questions.operations.d.ts +5 -1
- package/dist/questions/questions.operations.js +18 -2
- package/dist/questions/questions.schema.d.ts +3 -1
- package/dist/questions/questions.schema.js +1 -1
- package/dist/record/edges/plan.db.d.ts +1 -0
- package/dist/record/edges/plan.db.js +5 -0
- package/dist/record/edges/record.db.d.ts +1 -1
- package/dist/record/edges/record.db.js +1 -1
- package/migrations/main/20261206094906_plugin_findings/migration.sql +20 -0
- package/migrations/main/20261206094906_plugin_findings/snapshot.json +3652 -0
- package/package.json +3 -3
|
@@ -0,0 +1,39 @@
|
|
|
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';
|
|
3
|
+
import type { LoadedTestFile, RemovableTests } from './judge.schema.ts';
|
|
4
|
+
import { type BaselineSpeed, type JudgeSpeed, type PlanSpeed, planSpeedKey } from './edges/speed.ts';
|
|
5
|
+
import type { CrushTaskMeta } from './task-meta.ts';
|
|
6
|
+
declare module 'vite-plus/test' {
|
|
7
|
+
interface TestContext {
|
|
8
|
+
crushExploreProperties?: ExploreTarget[];
|
|
9
|
+
crushLoadedTestFiles?: LoadedTestFile[];
|
|
10
|
+
}
|
|
11
|
+
interface TaskMeta extends CrushTaskMeta {
|
|
12
|
+
crushBaselineSpeed?: BaselineSpeed;
|
|
13
|
+
crushJudgeSpeed?: JudgeSpeed;
|
|
14
|
+
crushOpen?: number;
|
|
15
|
+
crushOpenIn?: string;
|
|
16
|
+
}
|
|
17
|
+
interface ProvidedContext {
|
|
18
|
+
[vitestProvideKey]: string;
|
|
19
|
+
[phaseProvideKey]: 'record' | 'judge' | 'verify' | 'property';
|
|
20
|
+
[rulesProvideKey]: string;
|
|
21
|
+
[rootProvideKey]: string;
|
|
22
|
+
[removableTestsProvideKey]: RemovableTests;
|
|
23
|
+
[stepsProvideKey]: boolean;
|
|
24
|
+
[recordTestFilesProvideKey]: string[];
|
|
25
|
+
[explorePathsProvideKey]: string[] | null;
|
|
26
|
+
[exploreSeedProvideKey]: number;
|
|
27
|
+
[pluginMetaKeyProvideKey]: string | null;
|
|
28
|
+
[exploreLimitsProvideKey]: {
|
|
29
|
+
maxTotalTime: number;
|
|
30
|
+
runs: number;
|
|
31
|
+
};
|
|
32
|
+
[judgeFilesProvideKey]: string[];
|
|
33
|
+
[judgeShardsProvideKey]: number;
|
|
34
|
+
[judgeRelatedProvideKey]: string[];
|
|
35
|
+
[questionsRelatedProvideKey]: string[];
|
|
36
|
+
[judgeRedundantProvideKey]: boolean;
|
|
37
|
+
[planSpeedKey]: PlanSpeed;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { exploreLimitsProvideKey, explorePathsProvideKey, exploreSeedProvideKey, pluginMetaKeyProvideKey, judgeRedundantProvideKey, judgeFilesProvideKey, judgeRelatedProvideKey, questionsRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, rulesProvideKey, stepsProvideKey, vitestProvideKey, } from './edges/vitest.js';
|
|
2
|
+
import { planSpeedKey } from './edges/speed.js';
|
|
@@ -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, exploreCaughtOf, exploreQuestionsOf, 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';
|
|
@@ -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, 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;
|
|
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
|
-
|
|
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
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))));
|
package/dist/judge/runner.js
CHANGED
|
@@ -82,7 +82,7 @@ import { hasRefusal, markRefusal, readJudgeSource, readJudgeSourceNullable } fro
|
|
|
82
82
|
import { mergeJudged } from './edges/merge.js';
|
|
83
83
|
import { browserModuleOutput, runnerModuleOutput, workerStateOutput } from './edges/vitest.schema.js';
|
|
84
84
|
import { judgeSpeedOf, now } from './edges/speed.js';
|
|
85
|
-
import { explorePathsProvideKey, judgeCoordinators, judgeFilesProvideKey, judgeRedundantProvideKey, judgeRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordPathOf, rootProvideKey, rulesProvideKey, vitestProvideKey, } from './edges/vitest.js';
|
|
85
|
+
import { explorePathsProvideKey, pluginMetaKeyProvideKey, judgeCoordinators, judgeFilesProvideKey, judgeRedundantProvideKey, judgeRelatedProvideKey, judgeShardsProvideKey, phaseProvideKey, recordPathOf, rootProvideKey, rulesProvideKey, vitestProvideKey, } from './edges/vitest.js';
|
|
86
86
|
import { changedDuringRunOf, failedJudgingOf, stalePlanOf } from './refusals.js';
|
|
87
87
|
// 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
88
|
// The values the command project provides reach the worker whichever copy reads them, so crush's own `inject` finds the project's copy.
|
|
@@ -493,6 +493,14 @@ export default function CrushRunner(config) {
|
|
|
493
493
|
const onBeforeRunTask = async (task) => {
|
|
494
494
|
await base.onBeforeRunTask(task);
|
|
495
495
|
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
|
+
}
|
|
496
504
|
const { data, error } = await exploreProperties();
|
|
497
505
|
if (error)
|
|
498
506
|
thrownToVitest(error);
|
|
@@ -1445,13 +1453,52 @@ export default function CrushRunner(config) {
|
|
|
1445
1453
|
}, { calls: [], clearVerification: false, clearFailure: session.pass === 'record' && session.ran.size > 0 });
|
|
1446
1454
|
return refusal;
|
|
1447
1455
|
};
|
|
1456
|
+
// Loads one test file through Vitest's own loader without running its tests, so a plugin reads each test's meta and calls what the module exports.
|
|
1457
|
+
// Vitest's shared runner collects one file at a time, so a caller loads files in turn.
|
|
1458
|
+
const loadTestFile = async (file) => {
|
|
1459
|
+
const root = inject(rootProvideKey);
|
|
1460
|
+
const path = join(root, file);
|
|
1461
|
+
const { data: files, error: collectError } = await safeAsync(() => collectTests([path], runner));
|
|
1462
|
+
if (collectError)
|
|
1463
|
+
return { data: null, error: collectError };
|
|
1464
|
+
const loaded = itemAt(files, 0);
|
|
1465
|
+
const failure = runFailureOf(loaded);
|
|
1466
|
+
if (failure)
|
|
1467
|
+
return { data: null, error: new CrushError(failure) };
|
|
1468
|
+
// The module was just collected by the same Vitest loader, so importing it again loads nothing new.
|
|
1469
|
+
const { data: module, error: loadError } = await safeAsync(async () => await runner.importFile(path, 'collect'));
|
|
1470
|
+
if (loadError)
|
|
1471
|
+
return { data: null, error: loadError };
|
|
1472
|
+
const tests = testsOf(loaded).map(({ name, meta }) => ({ name, meta }));
|
|
1473
|
+
return { data: { file, source: readJudgeSource(root, file), module, tests }, error: null };
|
|
1474
|
+
};
|
|
1475
|
+
// Loads each recorded test file whose source names a plugin's meta key, in turn, for that plugin's coordinator to read.
|
|
1476
|
+
const loadTestFilesDeclaring = async (metaKey) => {
|
|
1477
|
+
const { data: edges, error } = currentEdgesOf();
|
|
1478
|
+
if (error)
|
|
1479
|
+
return { data: null, error };
|
|
1480
|
+
const root = inject(rootProvideKey);
|
|
1481
|
+
const files = [];
|
|
1482
|
+
const loadDeclaring = async ({ file }) => {
|
|
1483
|
+
if (!readJudgeSource(root, file).includes(metaKey))
|
|
1484
|
+
return null;
|
|
1485
|
+
const { data: loaded, error: loadError } = await loadTestFile(file);
|
|
1486
|
+
if (loadError)
|
|
1487
|
+
return loadError;
|
|
1488
|
+
files.push(loaded);
|
|
1489
|
+
return null;
|
|
1490
|
+
};
|
|
1491
|
+
const loadError = await firstInOrder(edges.getJudged({ withHits: false }), loadDeclaring);
|
|
1492
|
+
if (loadError)
|
|
1493
|
+
return { data: null, error: loadError };
|
|
1494
|
+
return { data: files, error: null };
|
|
1495
|
+
};
|
|
1448
1496
|
// Collects declarations from eligible recorded test modules without executing their tests.
|
|
1449
1497
|
const exploreProperties = async () => {
|
|
1450
1498
|
const { data: edges, error } = currentEdgesOf();
|
|
1451
1499
|
if (error)
|
|
1452
1500
|
return { data: null, error };
|
|
1453
1501
|
const targets = [];
|
|
1454
|
-
const root = inject(rootProvideKey);
|
|
1455
1502
|
const graph = graphOf({ nodes: edges.getReachNodes(), edges: edges.getReachEdges() });
|
|
1456
1503
|
const paths = inject(explorePathsProvideKey);
|
|
1457
1504
|
const related = paths === null ? null : new Set(paths);
|
|
@@ -1462,20 +1509,11 @@ export default function CrushRunner(config) {
|
|
|
1462
1509
|
const allowed = new Set(explorableOf({ ...graph, keys, paths: related }).map(({ key }) => key));
|
|
1463
1510
|
if (!allowed.size)
|
|
1464
1511
|
return null;
|
|
1465
|
-
const
|
|
1466
|
-
const { data: files, error: collectError } = await safeAsync(() => collectTests([path], runner));
|
|
1467
|
-
if (collectError)
|
|
1468
|
-
return collectError;
|
|
1469
|
-
const loaded = itemAt(files, 0);
|
|
1470
|
-
const failure = runFailureOf(loaded);
|
|
1471
|
-
if (failure)
|
|
1472
|
-
return new CrushError(failure);
|
|
1473
|
-
// The module was just collected by the same Vitest loader, so importing it again loads nothing new.
|
|
1474
|
-
const { data: module, error: loadError } = await safeAsync(async () => await runner.importFile(path, 'collect'));
|
|
1512
|
+
const { data: loaded, error: loadError } = await loadTestFile(file);
|
|
1475
1513
|
if (loadError)
|
|
1476
1514
|
return loadError;
|
|
1477
|
-
const source =
|
|
1478
|
-
for (const task of
|
|
1515
|
+
const { source, module } = loaded;
|
|
1516
|
+
for (const task of loaded.tests) {
|
|
1479
1517
|
const declaration = exploresMeta.safeParse(task.meta);
|
|
1480
1518
|
if (!declaration.success)
|
|
1481
1519
|
continue;
|
|
@@ -59,7 +59,11 @@ export type ExploreFinding = {
|
|
|
59
59
|
function: string;
|
|
60
60
|
input: string;
|
|
61
61
|
};
|
|
62
|
-
export declare const exploreQuestionsOf: (all: readonly ExploreFinding[]) => Asked[];
|
|
62
|
+
export declare const exploreQuestionsOf: (all: readonly ExploreFinding[], kind?: 'explore' | 'finding') => Asked[];
|
|
63
|
+
type PluginFinding = ExploreFinding & {
|
|
64
|
+
plugin: string;
|
|
65
|
+
};
|
|
66
|
+
export declare const findingQuestionsOf: (all: readonly PluginFinding[]) => Asked[];
|
|
63
67
|
type PathFinding = Pick<QuestionInput, 'file' | 'function' | 'code'> & {
|
|
64
68
|
kind: 'same-result' | 'no-split';
|
|
65
69
|
siteKey: string;
|
|
@@ -63,6 +63,11 @@ const wordings = {
|
|
|
63
63
|
ask: `Explore called ${ownerOf(name)} with ${quote(input)} and it failed ${quote(code)}, which no test covers. Is that input one a caller can send?`,
|
|
64
64
|
answers: ['yes: fix the code, with a test that fails before the fix, then run explore again', 'no: refuse the input where it enters with a parse or guard, or justify it'],
|
|
65
65
|
}),
|
|
66
|
+
// Another plugin's finding is worded as explore's, and findingQuestionsOf names the plugin in place of explore.
|
|
67
|
+
finding: ({ function: name, code, replacement: input }) => ({
|
|
68
|
+
ask: `A plugin called ${ownerOf(name)} with ${quote(input)} and it failed ${quote(code)}, which no test covers. Is that input one a caller can send?`,
|
|
69
|
+
answers: ['yes: fix the code, with a test that fails before the fix, then run the plugin again', 'no: refuse the input where it enters with a parse or guard, or justify it'],
|
|
70
|
+
}),
|
|
66
71
|
behavior: ({ function: name, code }) => ({ ask: `What should ${ownerOf(name)} give at ${quote(code)}?`, answers: ['yes: add a case answering this question with its output', 'no: remove that outcome'] }),
|
|
67
72
|
'same-result': ({ function: name, code }) => ({
|
|
68
73
|
ask: `The recorded paths parting at ${quote(code)} in ${ownerOf(name)} give the same result. Can any input tell them apart?`,
|
|
@@ -276,16 +281,27 @@ export const unusedQuestionsOf = (nodes) => {
|
|
|
276
281
|
};
|
|
277
282
|
// One question per finding's site, open until an explore no longer finds it or a justification answers it; a site two targets found is asked once, of the first.
|
|
278
283
|
// Its id names the site alone, never the function that found it, so refreshing which target found a shared site keeps the id an answer names.
|
|
279
|
-
export const exploreQuestionsOf = (all) => {
|
|
284
|
+
export const exploreQuestionsOf = (all, kind = 'explore') => {
|
|
280
285
|
const seen = new Set();
|
|
281
286
|
const findings = all.filter(({ key }) => !seen.has(key) && Boolean(seen.add(key)));
|
|
282
|
-
const inputs = findings.map((finding) => ({ kind
|
|
287
|
+
const inputs = findings.map((finding) => ({ kind, file: finding.file, function: finding.function, code: finding.key, replacement: finding.input.slice(0, 1024) }));
|
|
283
288
|
const ids = questionsOf(inputs.map((input) => ({ ...input, function: '' })));
|
|
284
289
|
return questionsOf(inputs).map((question, index) => {
|
|
285
290
|
const finding = itemAt(findings, index);
|
|
286
291
|
return Object.assign(question, { id: itemAt(ids, index).id, sites: [finding.key], file: finding.file, line: finding.line });
|
|
287
292
|
});
|
|
288
293
|
};
|
|
294
|
+
// Another plugin's findings, asked as explore's are under their own kind, each naming the plugin that found it.
|
|
295
|
+
export const findingQuestionsOf = (all) => {
|
|
296
|
+
const pluginOf = new Map();
|
|
297
|
+
for (const { key, plugin } of all)
|
|
298
|
+
if (!pluginOf.has(key))
|
|
299
|
+
pluginOf.set(key, plugin);
|
|
300
|
+
return exploreQuestionsOf(all, 'finding').map((question) => {
|
|
301
|
+
const [site] = question.sites;
|
|
302
|
+
return Object.assign(question, { ask: question.ask.replace(/^A plugin/, pluginOf.get(site ?? '') ?? 'A plugin') });
|
|
303
|
+
});
|
|
304
|
+
};
|
|
289
305
|
export const pathQuestionsOf = (findings) => {
|
|
290
306
|
return questionsOf(findings.map(({ kind, file, function: name, code }) => ({ kind, file, function: name, code, replacement: '' }))).map((question, index) => {
|
|
291
307
|
const { file, line, siteKey, uncompared } = itemAt(findings, index);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const questionKinds: readonly ['crush', 'reach', 'call', 'side', 'tell', 'matter', 'behavior', 'test', 'unused', 'unexport', 'untested', 'testonly', 'steps', 'answers', 'explore', 'same-result', 'no-split'];
|
|
2
|
+
export declare const questionKinds: readonly ['crush', 'reach', 'call', 'side', 'tell', 'matter', 'behavior', 'test', 'unused', 'unexport', 'untested', 'testonly', 'steps', 'answers', 'explore', 'finding', 'same-result', 'no-split'];
|
|
3
3
|
export declare const questionIdPattern: RegExp;
|
|
4
4
|
export declare const encodedQuestionIdLength: number;
|
|
5
5
|
export declare const questionId: z.ZodString;
|
|
@@ -10,6 +10,7 @@ export declare const questionInput: z.ZodObject<{
|
|
|
10
10
|
call: "call";
|
|
11
11
|
crush: "crush";
|
|
12
12
|
explore: "explore";
|
|
13
|
+
finding: "finding";
|
|
13
14
|
matter: "matter";
|
|
14
15
|
"no-split": "no-split";
|
|
15
16
|
reach: "reach";
|
|
@@ -36,6 +37,7 @@ declare const questionOutput: z.ZodObject<{
|
|
|
36
37
|
call: "call";
|
|
37
38
|
crush: "crush";
|
|
38
39
|
explore: "explore";
|
|
40
|
+
finding: "finding";
|
|
39
41
|
matter: "matter";
|
|
40
42
|
"no-split": "no-split";
|
|
41
43
|
reach: "reach";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const questionKinds = ['crush', 'reach', 'call', 'side', 'tell', 'matter', 'behavior', 'test', 'unused', 'unexport', 'untested', 'testonly', 'steps', 'answers', 'explore', 'same-result', 'no-split'];
|
|
2
|
+
export const questionKinds = ['crush', 'reach', 'call', 'side', 'tell', 'matter', 'behavior', 'test', 'unused', 'unexport', 'untested', 'testonly', 'steps', 'answers', 'explore', 'finding', 'same-result', 'no-split'];
|
|
3
3
|
// Matches a question id with pipes and percent signs escaped inside its fields.
|
|
4
4
|
export const questionIdPattern = /^(crush|reach|call|side|tell|matter|behavior|test|unused|unexport|untested|testonly|steps|answers|explore|same-result|no-split)\|(?:[^|%]|%25|%7C)+\|(?:[^|%]|%25|%7C)*\|\d+\|(?:[^|%]|%25|%7C)+$/;
|
|
5
5
|
const questionIdLength = 2048;
|
|
@@ -14,6 +14,7 @@ export type PlanCode = {
|
|
|
14
14
|
code: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const setPlanCodes: (db: Record, planKey: string, codes: readonly PlanCode[]) => void;
|
|
17
|
+
export declare const getPlanCodes: (db: Reader) => PlanCode[];
|
|
17
18
|
export declare const getPlanCodesNullable: (db: Record, planKey: string) => PlanCode[] | null;
|
|
18
19
|
export declare const getPlan: (db: Record, { withRewrites }?: {
|
|
19
20
|
withRewrites?: boolean;
|
|
@@ -105,6 +105,11 @@ export const setPlanCodes = (db, planKey, codes) => {
|
|
|
105
105
|
tx.insert(planCodes).values(chunk).run();
|
|
106
106
|
}, { behavior: 'immediate' });
|
|
107
107
|
};
|
|
108
|
+
// The instrumented code the last plan kept, in path order, whatever its plan key.
|
|
109
|
+
export const getPlanCodes = (db) => {
|
|
110
|
+
const rows = db.select().from(planCodes).orderBy(asc(planCodes.path)).all();
|
|
111
|
+
return rows.map(({ path, hash, code }) => ({ path, hash, code }));
|
|
112
|
+
};
|
|
108
113
|
// The instrumented code kept under a plan key, in path order, or null when the last plan kept was another.
|
|
109
114
|
export const getPlanCodesNullable = (db, planKey) => {
|
|
110
115
|
const rows = db.select().from(planCodes).orderBy(asc(planCodes.path)).all();
|
|
@@ -2,7 +2,7 @@ import { DatabaseSync } from 'node:sqlite';
|
|
|
2
2
|
import { type NodeSQLiteDatabase } from 'drizzle-orm/node-sqlite';
|
|
3
3
|
import { CrushError } from '../../utils/errors.ts';
|
|
4
4
|
import { type Safe } from '../../utils/safe.ts';
|
|
5
|
-
export declare const recordVersion = "
|
|
5
|
+
export declare const recordVersion = "58";
|
|
6
6
|
export declare const memoryPath = ":memory:";
|
|
7
7
|
export type Record = NodeSQLiteDatabase & {
|
|
8
8
|
$client: DatabaseSync;
|
|
@@ -60,7 +60,7 @@ import { safe } from '../../utils/safe.js';
|
|
|
60
60
|
import { ensureRecordFolder, recordFileExists, removeRecordFile } from './record.fs.js';
|
|
61
61
|
import { unreadableRecordOf } from '../../judge/refusals.js';
|
|
62
62
|
// The record's shape; a record of any other version is deleted and rebuilt, since every row can be recorded again.
|
|
63
|
-
export const recordVersion = '
|
|
63
|
+
export const recordVersion = '58';
|
|
64
64
|
// How long a connection waits on the record while another holds its write lock, as every test file's worker writes its own part at once.
|
|
65
65
|
const busyMs = 30_000;
|
|
66
66
|
const migrationsFolder = join(import.meta.dirname, '../../../migrations/main');
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
ALTER TABLE `explore_findings` ADD `plugin` text DEFAULT 'explore' NOT NULL;--> statement-breakpoint
|
|
2
|
+
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
3
|
+
CREATE TABLE `__new_explore_findings` (
|
|
4
|
+
`finding_key` text NOT NULL,
|
|
5
|
+
`kind` text NOT NULL,
|
|
6
|
+
`file` text NOT NULL,
|
|
7
|
+
`line` integer NOT NULL,
|
|
8
|
+
`function` text NOT NULL,
|
|
9
|
+
`input` text NOT NULL,
|
|
10
|
+
`target` text NOT NULL,
|
|
11
|
+
`source_hash` text NOT NULL,
|
|
12
|
+
`plugin` text DEFAULT 'explore' NOT NULL,
|
|
13
|
+
CONSTRAINT `explore_findings_pk` PRIMARY KEY(`plugin`, `target`, `finding_key`),
|
|
14
|
+
CONSTRAINT "explore_findings_kind_check" CHECK("kind" in ('throw', 'property'))
|
|
15
|
+
);
|
|
16
|
+
--> statement-breakpoint
|
|
17
|
+
INSERT INTO `__new_explore_findings`(`finding_key`, `kind`, `file`, `line`, `function`, `input`, `target`, `source_hash`) SELECT `finding_key`, `kind`, `file`, `line`, `function`, `input`, `target`, `source_hash` FROM `explore_findings`;--> statement-breakpoint
|
|
18
|
+
DROP TABLE `explore_findings`;--> statement-breakpoint
|
|
19
|
+
ALTER TABLE `__new_explore_findings` RENAME TO `explore_findings`;--> statement-breakpoint
|
|
20
|
+
PRAGMA foreign_keys=ON;
|