@whaaaley/crush 0.0.0-stage → 0.2.7
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/LICENSE +32 -0
- package/README.md +185 -2
- package/SKILL.md +187 -0
- package/THIRD_PARTY_NOTICES.md +277 -0
- package/dist/capture/capture.operations.d.ts +23 -0
- package/dist/capture/capture.operations.js +231 -0
- package/dist/capture/capture.schema.d.ts +73 -0
- package/dist/capture/capture.schema.js +28 -0
- package/dist/collapse/collapse.operations.d.ts +2 -0
- package/dist/collapse/collapse.operations.js +82 -0
- package/dist/collapse/collapse.schema.d.ts +40 -0
- package/dist/collapse/collapse.schema.js +35 -0
- package/dist/crush.tables.d.ts +3583 -0
- package/dist/crush.tables.js +456 -0
- package/dist/crushes/callback.crush.d.ts +2 -0
- package/dist/crushes/callback.crush.js +19 -0
- package/dist/crushes/crush.d.ts +36 -0
- package/dist/crushes/crush.js +12 -0
- package/dist/crushes/crush.names.d.ts +1 -0
- package/dist/crushes/crush.names.js +2 -0
- package/dist/crushes/crushes.d.ts +2 -0
- package/dist/crushes/crushes.js +9 -0
- package/dist/crushes/default-value.crush.d.ts +2 -0
- package/dist/crushes/default-value.crush.js +29 -0
- package/dist/crushes/drop-operand.crush.d.ts +2 -0
- package/dist/crushes/drop-operand.crush.js +37 -0
- package/dist/crushes/fold.d.ts +64 -0
- package/dist/crushes/fold.js +366 -0
- package/dist/crushes/force-fork.crush.d.ts +2 -0
- package/dist/crushes/force-fork.crush.js +79 -0
- package/dist/crushes/loop-once.crush.d.ts +2 -0
- package/dist/crushes/loop-once.crush.js +71 -0
- package/dist/crushes/optional-chain.crush.d.ts +2 -0
- package/dist/crushes/optional-chain.crush.js +30 -0
- package/dist/crushes/switch-case.crush.d.ts +2 -0
- package/dist/crushes/switch-case.crush.js +19 -0
- package/dist/decisions/decide.d.ts +61 -0
- package/dist/decisions/decide.js +161 -0
- package/dist/decisions/decisions.d.ts +24 -0
- package/dist/decisions/decisions.js +62 -0
- package/dist/decisions/forks.decision.d.ts +4 -0
- package/dist/decisions/forks.decision.js +32 -0
- package/dist/decisions/kinds.d.ts +101 -0
- package/dist/decisions/kinds.js +38 -0
- package/dist/decisions/loops.decision.d.ts +4 -0
- package/dist/decisions/loops.decision.js +39 -0
- package/dist/decisions/shorts.decision.d.ts +3 -0
- package/dist/decisions/shorts.decision.js +66 -0
- package/dist/decisions/switches.decision.d.ts +3 -0
- package/dist/decisions/switches.decision.js +20 -0
- package/dist/decisions/throws.decision.d.ts +3 -0
- package/dist/decisions/throws.decision.js +35 -0
- package/dist/decisions/values.decision.d.ts +3 -0
- package/dist/decisions/values.decision.js +67 -0
- package/dist/explore/edges/explore.d.ts +60 -0
- package/dist/explore/edges/explore.db.d.ts +22 -0
- package/dist/explore/edges/explore.db.js +55 -0
- package/dist/explore/edges/explore.js +305 -0
- package/dist/explore/edges/random.d.ts +2 -0
- package/dist/explore/edges/random.js +32 -0
- package/dist/explore/explore.operations.d.ts +30 -0
- package/dist/explore/explore.operations.js +117 -0
- package/dist/explore/limits.operations.d.ts +14 -0
- package/dist/explore/limits.operations.js +20 -0
- package/dist/explore/targets.operations.d.ts +36 -0
- package/dist/explore/targets.operations.js +32 -0
- package/dist/explore/utils/draws.d.ts +6 -0
- package/dist/explore/utils/draws.js +2 -0
- package/dist/explore/utils/edits.d.ts +15 -0
- package/dist/explore/utils/edits.js +151 -0
- package/dist/explore/utils/guide.d.ts +23 -0
- package/dist/explore/utils/guide.js +35 -0
- package/dist/explore/utils/keep.d.ts +10 -0
- package/dist/explore/utils/keep.js +61 -0
- package/dist/explore/utils/pools.d.ts +17 -0
- package/dist/explore/utils/pools.js +121 -0
- package/dist/explore/utils/reads.d.ts +19 -0
- package/dist/explore/utils/reads.js +118 -0
- package/dist/explore/utils/twin.d.ts +21 -0
- package/dist/explore/utils/twin.js +55 -0
- package/dist/forks/forks.operations.d.ts +32 -0
- package/dist/forks/forks.operations.js +134 -0
- package/dist/forks/forks.schema.d.ts +20 -0
- package/dist/forks/forks.schema.js +14 -0
- package/dist/graph/cfg/cfg.d.ts +28 -0
- package/dist/graph/cfg/cfg.js +31 -0
- package/dist/graph/cfg/code-paths/analyzer.d.ts +27 -0
- package/dist/graph/cfg/code-paths/analyzer.js +358 -0
- package/dist/graph/cfg/code-paths/segments.d.ts +44 -0
- package/dist/graph/cfg/code-paths/segments.js +105 -0
- package/dist/graph/cfg/code-paths/state.d.ts +121 -0
- package/dist/graph/cfg/code-paths/state.js +611 -0
- package/dist/graph/cfg/entries.d.ts +13 -0
- package/dist/graph/cfg/entries.js +120 -0
- package/dist/graph/cfg/functions.d.ts +6 -0
- package/dist/graph/cfg/functions.js +47 -0
- package/dist/graph/cfg/paths.d.ts +27 -0
- package/dist/graph/cfg/paths.js +91 -0
- package/dist/graph/cfg/scopes/scopes.d.ts +40 -0
- package/dist/graph/cfg/scopes/scopes.js +375 -0
- package/dist/graph/symbols/file.d.ts +90 -0
- package/dist/graph/symbols/file.js +427 -0
- package/dist/graph/symbols/keys.d.ts +13 -0
- package/dist/graph/symbols/keys.js +22 -0
- package/dist/graph/symbols/resolve.operations.d.ts +4 -0
- package/dist/graph/symbols/resolve.operations.js +33 -0
- package/dist/graph/symbols/symbols.d.ts +12 -0
- package/dist/graph/symbols/symbols.js +155 -0
- package/dist/graph/symbols/symbols.schema.d.ts +32 -0
- package/dist/graph/symbols/symbols.schema.js +19 -0
- package/dist/graph/unused/tests.d.ts +7 -0
- package/dist/graph/unused/tests.js +95 -0
- package/dist/graph/unused/unused.d.ts +53 -0
- package/dist/graph/unused/unused.js +319 -0
- package/dist/graph/walk/walk.d.ts +7 -0
- package/dist/graph/walk/walk.js +39 -0
- package/dist/instrument/instrument.operations.d.ts +72 -0
- package/dist/instrument/instrument.operations.js +786 -0
- package/dist/instrument/instrument.schema.d.ts +257 -0
- package/dist/instrument/instrument.schema.js +100 -0
- package/dist/judge/counters.d.ts +86 -0
- package/dist/judge/counters.js +402 -0
- package/dist/judge/edges/api.d.ts +14 -0
- package/dist/judge/edges/api.js +80 -0
- package/dist/judge/edges/completion.reporter.d.ts +9 -0
- package/dist/judge/edges/completion.reporter.js +51 -0
- package/dist/judge/edges/hints.reporter.d.ts +13 -0
- package/dist/judge/edges/hints.reporter.js +29 -0
- package/dist/judge/edges/judge.edges.d.ts +52 -0
- package/dist/judge/edges/judge.edges.js +59 -0
- package/dist/judge/edges/judge.fs.d.ts +8 -0
- package/dist/judge/edges/judge.fs.js +45 -0
- package/dist/judge/edges/merge.d.ts +11 -0
- package/dist/judge/edges/merge.js +60 -0
- package/dist/judge/edges/plugin.d.ts +132 -0
- package/dist/judge/edges/plugin.js +441 -0
- package/dist/judge/edges/reach.d.ts +68 -0
- package/dist/judge/edges/reach.js +132 -0
- package/dist/judge/edges/speed.d.ts +32 -0
- package/dist/judge/edges/speed.js +34 -0
- package/dist/judge/edges/strays.d.ts +1 -0
- package/dist/judge/edges/strays.js +14 -0
- package/dist/judge/edges/vitest.d.ts +20 -0
- package/dist/judge/edges/vitest.js +36 -0
- package/dist/judge/edges/vitest.schema.d.ts +14 -0
- package/dist/judge/edges/vitest.schema.js +16 -0
- package/dist/judge/explore.test.d.ts +1 -0
- package/dist/judge/explore.test.js +101 -0
- package/dist/judge/hints.d.ts +11 -0
- package/dist/judge/hints.js +44 -0
- package/dist/judge/judge.operations.d.ts +218 -0
- package/dist/judge/judge.operations.js +464 -0
- package/dist/judge/judge.schema.d.ts +135 -0
- package/dist/judge/judge.schema.js +129 -0
- package/dist/judge/judge.shard-1.test.d.ts +1 -0
- package/dist/judge/judge.shard-1.test.js +3 -0
- package/dist/judge/judge.shard-2.test.d.ts +1 -0
- package/dist/judge/judge.shard-2.test.js +3 -0
- package/dist/judge/judge.test.d.ts +1 -0
- package/dist/judge/judge.test.js +3 -0
- package/dist/judge/refusals.d.ts +14 -0
- package/dist/judge/refusals.js +10 -0
- package/dist/judge/report.test.d.ts +1 -0
- package/dist/judge/report.test.js +432 -0
- package/dist/judge/runner.d.ts +3 -0
- package/dist/judge/runner.js +1602 -0
- package/dist/judge/stresses.test.d.ts +1 -0
- package/dist/judge/stresses.test.js +12 -0
- package/dist/judge/task-meta.d.ts +14 -0
- package/dist/judge/task-meta.js +1 -0
- package/dist/justify/edges/load.d.ts +7 -0
- package/dist/justify/edges/load.js +40 -0
- package/dist/justify/edges/refresh.fs.d.ts +8 -0
- package/dist/justify/edges/refresh.fs.js +15 -0
- package/dist/justify/justify.operations.d.ts +46 -0
- package/dist/justify/justify.operations.js +80 -0
- package/dist/justify/justify.schema.d.ts +21 -0
- package/dist/justify/justify.schema.js +11 -0
- package/dist/mutators/arithmetic-operator.mutator.d.ts +2 -0
- package/dist/mutators/arithmetic-operator.mutator.js +22 -0
- package/dist/mutators/array-declaration.mutator.d.ts +2 -0
- package/dist/mutators/array-declaration.mutator.js +12 -0
- package/dist/mutators/arrow-function.mutator.d.ts +2 -0
- package/dist/mutators/arrow-function.mutator.js +10 -0
- package/dist/mutators/assignment-operator.mutator.d.ts +2 -0
- package/dist/mutators/assignment-operator.mutator.js +29 -0
- package/dist/mutators/await-expression.mutator.d.ts +2 -0
- package/dist/mutators/await-expression.mutator.js +7 -0
- package/dist/mutators/bitwise-operator.mutator.d.ts +2 -0
- package/dist/mutators/bitwise-operator.mutator.js +19 -0
- package/dist/mutators/block-statement.mutator.d.ts +2 -0
- package/dist/mutators/block-statement.mutator.js +30 -0
- package/dist/mutators/boolean-literal.mutator.d.ts +2 -0
- package/dist/mutators/boolean-literal.mutator.js +5 -0
- package/dist/mutators/coercion.mutator.d.ts +2 -0
- package/dist/mutators/coercion.mutator.js +28 -0
- package/dist/mutators/conditional-expression.mutator.d.ts +2 -0
- package/dist/mutators/conditional-expression.mutator.js +36 -0
- package/dist/mutators/disposal.mutator.d.ts +2 -0
- package/dist/mutators/disposal.mutator.js +13 -0
- package/dist/mutators/empty-destructuring.mutator.d.ts +2 -0
- package/dist/mutators/empty-destructuring.mutator.js +35 -0
- package/dist/mutators/empty-return.mutator.d.ts +2 -0
- package/dist/mutators/empty-return.mutator.js +35 -0
- package/dist/mutators/equality-operator.mutator.d.ts +2 -0
- package/dist/mutators/equality-operator.mutator.js +16 -0
- package/dist/mutators/loop-exit.mutator.d.ts +2 -0
- package/dist/mutators/loop-exit.mutator.js +5 -0
- package/dist/mutators/method-expression.mutator.d.ts +2 -0
- package/dist/mutators/method-expression.mutator.js +59 -0
- package/dist/mutators/missing-lookup.mutator.d.ts +2 -0
- package/dist/mutators/missing-lookup.mutator.js +25 -0
- package/dist/mutators/mutator.d.ts +40 -0
- package/dist/mutators/mutator.js +49 -0
- package/dist/mutators/mutator.names.d.ts +3 -0
- package/dist/mutators/mutator.names.js +43 -0
- package/dist/mutators/mutators.d.ts +8 -0
- package/dist/mutators/mutators.js +84 -0
- package/dist/mutators/nested-condition.mutator.d.ts +2 -0
- package/dist/mutators/nested-condition.mutator.js +16 -0
- package/dist/mutators/number-literal.mutator.d.ts +3 -0
- package/dist/mutators/number-literal.mutator.js +13 -0
- package/dist/mutators/object-literal.mutator.d.ts +2 -0
- package/dist/mutators/object-literal.mutator.js +6 -0
- package/dist/mutators/odd-number.mutator.d.ts +2 -0
- package/dist/mutators/odd-number.mutator.js +15 -0
- package/dist/mutators/operand-deletion.mutator.d.ts +2 -0
- package/dist/mutators/operand-deletion.mutator.js +9 -0
- package/dist/mutators/outcome.mutator.d.ts +3 -0
- package/dist/mutators/outcome.mutator.js +45 -0
- package/dist/mutators/plain-assignment.mutator.d.ts +2 -0
- package/dist/mutators/plain-assignment.mutator.js +7 -0
- package/dist/mutators/power-operator.mutator.d.ts +2 -0
- package/dist/mutators/power-operator.mutator.js +13 -0
- package/dist/mutators/private-brand.mutator.d.ts +2 -0
- package/dist/mutators/private-brand.mutator.js +7 -0
- package/dist/mutators/regex.mutator.d.ts +2 -0
- package/dist/mutators/regex.mutator.js +29 -0
- package/dist/mutators/short-iteration.mutator.d.ts +2 -0
- package/dist/mutators/short-iteration.mutator.js +8 -0
- package/dist/mutators/string-literal.mutator.d.ts +3 -0
- package/dist/mutators/string-literal.mutator.js +149 -0
- package/dist/mutators/switch-default.mutator.d.ts +2 -0
- package/dist/mutators/switch-default.mutator.js +13 -0
- package/dist/mutators/sync-iteration.mutator.d.ts +3 -0
- package/dist/mutators/sync-iteration.mutator.js +9 -0
- package/dist/mutators/thrown-call.mutator.d.ts +2 -0
- package/dist/mutators/thrown-call.mutator.js +7 -0
- package/dist/mutators/unary-operator.mutator.d.ts +2 -0
- package/dist/mutators/unary-operator.mutator.js +18 -0
- package/dist/mutators/unbound-call.mutator.d.ts +2 -0
- package/dist/mutators/unbound-call.mutator.js +14 -0
- package/dist/mutators/update-operator.mutator.d.ts +2 -0
- package/dist/mutators/update-operator.mutator.js +15 -0
- package/dist/mutators/yield-value.mutator.d.ts +2 -0
- package/dist/mutators/yield-value.mutator.js +7 -0
- package/dist/parity/compare.d.ts +27 -0
- package/dist/parity/compare.js +26 -0
- package/dist/parity/corpus.parity.d.ts +1 -0
- package/dist/parity/corpus.parity.js +97 -0
- package/dist/parity/edges/corpus.fs.d.ts +3 -0
- package/dist/parity/edges/corpus.fs.js +30 -0
- package/dist/parity/edges/ports.d.ts +2 -0
- package/dist/parity/edges/ports.js +21 -0
- package/dist/parity/edges/vitest.d.ts +2 -0
- package/dist/parity/edges/vitest.js +3 -0
- package/dist/parity/parity.operations.d.ts +33 -0
- package/dist/parity/parity.operations.js +60 -0
- package/dist/parity/parity.schema.d.ts +5 -0
- package/dist/parity/parity.schema.js +6 -0
- package/dist/parity/stryker/compare.d.ts +14 -0
- package/dist/parity/stryker/compare.js +52 -0
- package/dist/parity/stryker/edges/ports.d.ts +12 -0
- package/dist/parity/stryker/edges/ports.js +28 -0
- package/dist/parity/stryker/equivalence.d.ts +1 -0
- package/dist/parity/stryker/equivalence.js +42 -0
- package/dist/parity/stryker/intended.d.ts +29 -0
- package/dist/parity/stryker/intended.js +152 -0
- package/dist/parity/stryker/normalize.d.ts +27 -0
- package/dist/parity/stryker/normalize.js +181 -0
- package/dist/parity/stryker/rules.d.ts +6 -0
- package/dist/parity/stryker/rules.js +116 -0
- package/dist/parity/stryker/sides.d.ts +46 -0
- package/dist/parity/stryker/sides.js +199 -0
- package/dist/parity/stryker/stryker.parity.d.ts +1 -0
- package/dist/parity/stryker/stryker.parity.js +147 -0
- package/dist/parity/stryker/stryker.schema.d.ts +6 -0
- package/dist/parity/stryker/stryker.schema.js +7 -0
- package/dist/parity/views.d.ts +21 -0
- package/dist/parity/views.js +119 -0
- package/dist/questions/questions.operations.d.ts +110 -0
- package/dist/questions/questions.operations.js +446 -0
- package/dist/questions/questions.schema.d.ts +57 -0
- package/dist/questions/questions.schema.js +28 -0
- package/dist/record/edges/calls.db.d.ts +10 -0
- package/dist/record/edges/calls.db.js +91 -0
- package/dist/record/edges/hits.db.d.ts +3 -0
- package/dist/record/edges/hits.db.js +5 -0
- package/dist/record/edges/holds.db.d.ts +4 -0
- package/dist/record/edges/holds.db.js +31 -0
- package/dist/record/edges/judged-state.db.d.ts +5 -0
- package/dist/record/edges/judged-state.db.js +25 -0
- package/dist/record/edges/markers.db.d.ts +11 -0
- package/dist/record/edges/markers.db.js +55 -0
- package/dist/record/edges/merge.db.d.ts +7 -0
- package/dist/record/edges/merge.db.js +46 -0
- package/dist/record/edges/parts.db.d.ts +42 -0
- package/dist/record/edges/parts.db.js +389 -0
- package/dist/record/edges/parts.edges.d.ts +2 -0
- package/dist/record/edges/parts.edges.js +7 -0
- package/dist/record/edges/parts.fs.d.ts +1 -0
- package/dist/record/edges/parts.fs.js +11 -0
- package/dist/record/edges/parts.writer.d.ts +1 -0
- package/dist/record/edges/parts.writer.js +85 -0
- package/dist/record/edges/passes.db.d.ts +19 -0
- package/dist/record/edges/passes.db.js +31 -0
- package/dist/record/edges/plan.db.d.ts +21 -0
- package/dist/record/edges/plan.db.js +174 -0
- package/dist/record/edges/reach.db.d.ts +6 -0
- package/dist/record/edges/reach.db.js +62 -0
- package/dist/record/edges/record.db.d.ts +22 -0
- package/dist/record/edges/record.db.js +176 -0
- package/dist/record/edges/record.fs.d.ts +3 -0
- package/dist/record/edges/record.fs.js +7 -0
- package/dist/record/edges/site-verdicts.db.d.ts +11 -0
- package/dist/record/edges/site-verdicts.db.js +66 -0
- package/dist/record/edges/verified.db.d.ts +7 -0
- package/dist/record/edges/verified.db.js +71 -0
- package/dist/record/parts.operations.d.ts +26 -0
- package/dist/record/parts.operations.js +31 -0
- package/dist/record/path-checks.operations.d.ts +15 -0
- package/dist/record/path-checks.operations.js +84 -0
- package/dist/record/record.operations.d.ts +36 -0
- package/dist/record/record.operations.js +11 -0
- package/dist/stresses/edges/stresses.record.d.ts +4 -0
- package/dist/stresses/edges/stresses.record.js +37 -0
- package/dist/stresses/stresses.operations.d.ts +28 -0
- package/dist/stresses/stresses.operations.js +22 -0
- package/dist/utils/ast.d.ts +55 -0
- package/dist/utils/ast.js +181 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.js +12 -0
- package/dist/utils/faults.d.ts +6 -0
- package/dist/utils/faults.js +10 -0
- package/dist/utils/lookup.d.ts +4 -0
- package/dist/utils/lookup.js +27 -0
- package/dist/utils/order.d.ts +2 -0
- package/dist/utils/order.js +17 -0
- package/dist/utils/retry.d.ts +14 -0
- package/dist/utils/retry.js +15 -0
- package/dist/utils/safe.d.ts +11 -0
- package/dist/utils/safe.js +31 -0
- package/migrations/main/20261129123324_initial/migration.sql +418 -0
- package/migrations/main/20261129123324_initial/snapshot.json +3641 -0
- package/package.json +89 -4
- package/references/consumer-setup.md +92 -0
- package/src/graph/cfg/code-paths/LICENSE +21 -0
- package/src/graph/cfg/scopes/LICENSE +24 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { locatedJustificationInput } from '../justify/justify.schema.js';
|
|
3
|
+
import { forkSides, sides, statuses } from '../crush.tables.js';
|
|
4
|
+
import { encodedQuestionIdLength } from '../questions/questions.schema.js';
|
|
5
|
+
const offsetInput = z.number().int().nonnegative();
|
|
6
|
+
// One crush the joint check forces: its key, its decision's point, what it forces there, and the span its edits reach.
|
|
7
|
+
export const candidateInput = z.object({
|
|
8
|
+
key: z.string().min(1).max(1_048_576),
|
|
9
|
+
point: offsetInput,
|
|
10
|
+
forced: z.union([z.boolean(), z.literal('once')]),
|
|
11
|
+
start: offsetInput,
|
|
12
|
+
edits: z.array(z.object({ start: offsetInput, end: offsetInput })).min(1),
|
|
13
|
+
});
|
|
14
|
+
// The project root a command passes to its runner or report.
|
|
15
|
+
export const phaseRootInput = z.string().min(1).max(2048);
|
|
16
|
+
// Which tests crush may ask to remove: those carrying `meta.answers`, or all of them.
|
|
17
|
+
export const removableTestsInput = z.enum(['answers', 'all']);
|
|
18
|
+
// Whether the report asks each test's step questions.
|
|
19
|
+
export const stepsSettingInput = z.boolean();
|
|
20
|
+
// One held crush, as the record's `holds` keep it: what it rests on and the tests that held it.
|
|
21
|
+
export const holdInput = z.object({
|
|
22
|
+
key: z.string().min(1).max(1_048_576),
|
|
23
|
+
basis: z.string().min(1).max(128),
|
|
24
|
+
tests: z.array(z.string().min(1).max(4096)),
|
|
25
|
+
});
|
|
26
|
+
const keyInput = z.string().min(1).max(1_048_576);
|
|
27
|
+
const testNameInput = z.object({
|
|
28
|
+
groups: z.array(z.string()),
|
|
29
|
+
title: z.string(),
|
|
30
|
+
occurrence: z.number().int().positive().optional(),
|
|
31
|
+
});
|
|
32
|
+
// One test as a test file's judged part keeps it: whether it passed, what failed it, what it cost, and the question it answers.
|
|
33
|
+
const judgedTestInput = z.object({
|
|
34
|
+
key: keyInput,
|
|
35
|
+
name: testNameInput.optional(),
|
|
36
|
+
passed: z.boolean(),
|
|
37
|
+
failure: z.string().max(65_536).nullable(),
|
|
38
|
+
steps: z.number().int().nonnegative(),
|
|
39
|
+
ticks: z.number().int().nonnegative(),
|
|
40
|
+
ns: z.number().int().nonnegative(),
|
|
41
|
+
answers: z.array(z.string().max(encodedQuestionIdLength)),
|
|
42
|
+
keeps: z.string().max(4096).nullable(),
|
|
43
|
+
// The count and reason the test's `{ meta: { steps, stepsReason } }` states, null where it states none.
|
|
44
|
+
statedSteps: z.number().int().nonnegative().nullable(),
|
|
45
|
+
stepsReason: z.string().max(4096).nullable(),
|
|
46
|
+
// Whether two reruns with nothing forced agreed on the test's ticks, without which its step count holds on no run.
|
|
47
|
+
isSteady: z.boolean(),
|
|
48
|
+
});
|
|
49
|
+
// One side of one site a test took.
|
|
50
|
+
const judgedHitInput = z.object({
|
|
51
|
+
siteKey: keyInput,
|
|
52
|
+
side: z.enum(sides),
|
|
53
|
+
testKey: keyInput,
|
|
54
|
+
});
|
|
55
|
+
// A function of a source a test's baseline entered, by its unit key.
|
|
56
|
+
const judgedEntryInput = z.object({
|
|
57
|
+
unit: keyInput,
|
|
58
|
+
testKey: keyInput,
|
|
59
|
+
});
|
|
60
|
+
// How many times a test file's tests passed through one side of one fork.
|
|
61
|
+
const judgedPassesInput = z.object({
|
|
62
|
+
siteKey: keyInput,
|
|
63
|
+
side: z.enum(forkSides),
|
|
64
|
+
passes: z.number().int().positive(),
|
|
65
|
+
});
|
|
66
|
+
// One site's verdict from a test file's tests, with the basis it was judged on, the units that basis read, and whether the record supplied it.
|
|
67
|
+
const judgedVerdictInput = z.object({
|
|
68
|
+
key: keyInput,
|
|
69
|
+
status: z.enum(statuses),
|
|
70
|
+
catcher: keyInput.nullable(),
|
|
71
|
+
backup: keyInput.nullable(),
|
|
72
|
+
// How many tests reran against the site when it was judged, kept with a reused verdict as the cost it measured then.
|
|
73
|
+
reruns: z.number().int().nonnegative(),
|
|
74
|
+
basis: z.string().min(1).max(128),
|
|
75
|
+
// The units the basis read: the first `count` of the file's read sequence of `generation`.
|
|
76
|
+
reads: z.object({ generation: z.number().int().nonnegative(), count: z.number().int().nonnegative() }),
|
|
77
|
+
readHash: z.string().optional(),
|
|
78
|
+
isReused: z.boolean(),
|
|
79
|
+
// The test file this one left the site to, since that file caught it last run, or null when this file judged it.
|
|
80
|
+
deferred: keyInput.nullable(),
|
|
81
|
+
});
|
|
82
|
+
// One source a test file's run loaded, with the hash of the text it loaded.
|
|
83
|
+
const readInput = z.object({
|
|
84
|
+
path: keyInput,
|
|
85
|
+
hash: z.string().max(128),
|
|
86
|
+
});
|
|
87
|
+
// One test file's part of a run: its tests, the sides and sites each reached, each site's verdict from its tests, and the sources its run loaded.
|
|
88
|
+
export const judgedInput = z.object({
|
|
89
|
+
file: keyInput,
|
|
90
|
+
hash: z.string().min(1).max(128),
|
|
91
|
+
tests: z.array(judgedTestInput),
|
|
92
|
+
justifications: z.array(locatedJustificationInput).optional(),
|
|
93
|
+
hits: z.array(judgedHitInput),
|
|
94
|
+
// The functions of the sources each test whose baseline and unforced rerun passed entered, which show it called a function that returned before any site in it.
|
|
95
|
+
entered: z.array(judgedEntryInput),
|
|
96
|
+
verdicts: z.array(judgedVerdictInput),
|
|
97
|
+
reads: z.array(readInput),
|
|
98
|
+
reused: z.number().int().nonnegative(),
|
|
99
|
+
// The tests that passed but failed their rerun with nothing forced, which judge no site.
|
|
100
|
+
rerunFailing: z.array(keyInput),
|
|
101
|
+
// How many times this file's tests passed through each fork side they took.
|
|
102
|
+
passes: z.array(judgedPassesInput),
|
|
103
|
+
// The project files this file's run loaded that crush leaves uninstrumented, where no step counts.
|
|
104
|
+
outside: z.array(keyInput),
|
|
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
|
+
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
|
+
// 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
|
+
failure: z.string().max(65_536).nullable(),
|
|
111
|
+
// 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.
|
|
112
|
+
assignees: z.array(z.object({
|
|
113
|
+
source: keyInput,
|
|
114
|
+
assignee: keyInput,
|
|
115
|
+
})),
|
|
116
|
+
// The units this file's run entered, in the order first entered, under the generation its new verdicts read.
|
|
117
|
+
sequence: z.object({ generation: z.number().int().nonnegative(), units: z.array(keyInput) }),
|
|
118
|
+
});
|
|
119
|
+
// One crush a test file dropped from the joint check, with its pillars: the first test that failed with it, and the test that failed the whole set.
|
|
120
|
+
const droppedInput = z.object({
|
|
121
|
+
key: keyInput,
|
|
122
|
+
tests: z.array(keyInput),
|
|
123
|
+
});
|
|
124
|
+
// One test file's part of the joint check: the candidate set it checked, and the crushes it dropped to pass with the rest.
|
|
125
|
+
export const verifiedInput = z.object({
|
|
126
|
+
file: keyInput,
|
|
127
|
+
candidates: z.string().max(128),
|
|
128
|
+
dropped: z.array(droppedInput),
|
|
129
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type UnreadableInput = {
|
|
2
|
+
path: string;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const unreadableRecordOf: ({ path, message }: UnreadableInput) => string;
|
|
6
|
+
export declare const stillWorkingOf: (files: readonly string[], ms: number) => string;
|
|
7
|
+
export declare const refusedJudge = "the judge phase was refused, so this run has no parts to report; run `vp run judge` again";
|
|
8
|
+
export declare const stalePlanOf: (paths: readonly string[]) => string;
|
|
9
|
+
export declare const changedDuringRunOf: (paths: readonly string[]) => string;
|
|
10
|
+
export declare const failedJudgingOf: (count: number) => string;
|
|
11
|
+
export declare const missingVitestOf: (root: string) => string;
|
|
12
|
+
export declare const staleExploreOf: (named: string) => string;
|
|
13
|
+
export declare const markedExploreOf: (markers: number) => string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Each refusal ends with the command that clears it, so an agent reading only the error knows its next step.
|
|
2
|
+
export const unreadableRecordOf = ({ path, message }) => `the record at ${path} could not be read: ${message}; delete it and run \`vp run record\` to rebuild it`;
|
|
3
|
+
export const stillWorkingOf = (files, ms) => `test files still working after ${ms} ms: ${files.join(', ')}; let the run holding them finish, or run \`vp run record\` if it stopped`;
|
|
4
|
+
export const refusedJudge = 'the judge phase was refused, so this run has no parts to report; run `vp run judge` again';
|
|
5
|
+
export const stalePlanOf = (paths) => `crush's plan is stale for ${paths.join(', ')}; run \`vp run judge\` again`;
|
|
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
|
+
export const failedJudgingOf = (count) => `${count} test files failed during judging; make them pass, then run \`vp run judge\` again`;
|
|
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`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { relative, resolve, sep } from 'node:path';
|
|
54
|
+
import { z } from 'zod';
|
|
55
|
+
import { collapsedOf } from '../collapse/collapse.operations.js';
|
|
56
|
+
import { describe, expect, inject, it } from 'vite-plus/test';
|
|
57
|
+
import { readJustifications } from '../justify/edges/load.js';
|
|
58
|
+
import { refreshEntry } from '../justify/edges/refresh.fs.js';
|
|
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';
|
|
61
|
+
import { readJudgeEdges } from './edges/judge.edges.js';
|
|
62
|
+
import { hasRefusal, readJudgeSourceNullable } from './edges/judge.fs.js';
|
|
63
|
+
import { recordPathOf, questionsRelatedProvideKey, recordTestFilesProvideKey, removableTestsProvideKey, rootProvideKey, stepsProvideKey } from './edges/vitest.js';
|
|
64
|
+
import { candidatesHashOf, dropsAgree, figuresOf, functionsOf, heldAfter, holdBasisOf, judgedSitesOf, mergedOf, pointKeyOf, removableOf, ridingSidesOf, sideKeyOf, stalePartsOf, testLabelOf, unsettledTestsOf, verdictBasesOf, } from './judge.operations.js';
|
|
65
|
+
import { phaseRootInput, removableTestsInput, stepsSettingInput } from './judge.schema.js';
|
|
66
|
+
import { testRootPattern } from './edges/reach.js';
|
|
67
|
+
import { reachedFrom } from '../graph/symbols/symbols.js';
|
|
68
|
+
import { fileKey } from '../graph/symbols/keys.js';
|
|
69
|
+
import { hashOf, unitFieldsOf, unitKeyOf } from '../record/record.operations.js';
|
|
70
|
+
import { entryAt, itemAt } from '../utils/lookup.js';
|
|
71
|
+
import { noSplitsOf, sameResultsOf, uncomparedOf } from '../record/path-checks.operations.js';
|
|
72
|
+
import { loopKinds } from '../decisions/kinds.js';
|
|
73
|
+
import { refusedJudge } from './refusals.js';
|
|
74
|
+
// Crush's results as tests: one per source and one for the project, each failing while questions stay open, with its figures and questions as annotations.
|
|
75
|
+
const root = phaseRootInput.parse(inject(rootProvideKey));
|
|
76
|
+
// A refused judge phase wrote no parts this run, so the report stops before reading the ones an earlier run left.
|
|
77
|
+
if (hasRefusal(root))
|
|
78
|
+
throw new Error(refusedJudge);
|
|
79
|
+
const recordPath = recordPathOf(root);
|
|
80
|
+
const opened = readJudgeEdges(recordPath);
|
|
81
|
+
if (opened.error)
|
|
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;
|
|
84
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
85
|
+
try {
|
|
86
|
+
edges = __addDisposableResource(env_1, opened.data, false);
|
|
87
|
+
stillWorking = await edges.settled();
|
|
88
|
+
if (stillWorking)
|
|
89
|
+
throw stillWorking;
|
|
90
|
+
plan = edges.getPlan();
|
|
91
|
+
runs = edges.getJudged({ withHits: true });
|
|
92
|
+
testFiles = inject(recordTestFilesProvideKey);
|
|
93
|
+
currentHashOf = (path) => {
|
|
94
|
+
const source = readJudgeSourceNullable(root, path);
|
|
95
|
+
return source === null ? null : hashOf(source);
|
|
96
|
+
};
|
|
97
|
+
stale = stalePartsOf({ parts: runs, testFiles, hashOf: currentHashOf });
|
|
98
|
+
merged = mergedOf(runs.map(({ verdicts }) => verdicts));
|
|
99
|
+
statusOf = new Map([...merged].map(([key, { status }]) => [key, status]));
|
|
100
|
+
// The joint check: every test file reran its tests with the candidates forced together, dropping any a test failed with.
|
|
101
|
+
// Collapse applies only candidates no file dropped, and calls itself verified once every file checked this set and all dropped the same crushes, since each file's last passing step then ran exactly the applied set.
|
|
102
|
+
candidates = edges.getCandidates();
|
|
103
|
+
candidatesHash = candidatesHashOf(candidates);
|
|
104
|
+
checks = edges.getVerified().filter(({ candidates: checked }) => checked === candidatesHash);
|
|
105
|
+
drops = checks.flatMap((check) => check.dropped);
|
|
106
|
+
dropped = new Set(drops.map(({ key }) => key));
|
|
107
|
+
// The holds rest on the basis merge chose candidates under; a different one now means a source changed mid-run, which leaves the run unverified.
|
|
108
|
+
({ data: basis } = edges.getMergeBasis());
|
|
109
|
+
isCurrent = holdBasisOf({ sources: plan.files, tests: runs }) === basis;
|
|
110
|
+
checkedFiles = new Set(checks.map(({ file }) => file));
|
|
111
|
+
isVerified = runs.every(({ file }) => checkedFiles.has(file)) && dropsAgree(checks) && isCurrent;
|
|
112
|
+
falling = new Set(candidates.filter(({ key }) => !dropped.has(key)).map(({ key }) => key));
|
|
113
|
+
liveSources = new Map();
|
|
114
|
+
liveSourceOf = (path) => {
|
|
115
|
+
const cached = liveSources.get(path);
|
|
116
|
+
if (cached !== undefined)
|
|
117
|
+
return cached;
|
|
118
|
+
const source = readJudgeSourceNullable(root, path);
|
|
119
|
+
if (source === null)
|
|
120
|
+
return undefined;
|
|
121
|
+
liveSources.set(path, source);
|
|
122
|
+
return source;
|
|
123
|
+
};
|
|
124
|
+
isLive = ({ path, hash }) => {
|
|
125
|
+
const source = liveSourceOf(path);
|
|
126
|
+
return source !== undefined && hashOf(source) === hash;
|
|
127
|
+
};
|
|
128
|
+
isLiveVerified = isVerified && (!falling.size || [...plan.files, ...plan.tests].every(isLive));
|
|
129
|
+
// Each source's collapse, from the candidates no file dropped; one it refuses or backs off was verified only alongside it, so it is held back too and the next run verifies exactly what is applied.
|
|
130
|
+
collapses = new Map(plan.files.flatMap(({ path, hash, crushes }) => {
|
|
131
|
+
const fallen = crushes.filter(({ key }) => falling.has(key));
|
|
132
|
+
if (!fallen.length)
|
|
133
|
+
return [];
|
|
134
|
+
const source = liveSourceOf(path);
|
|
135
|
+
if (source === undefined || hashOf(source) !== hash)
|
|
136
|
+
return [];
|
|
137
|
+
const collapse = collapsedOf({ path, source, fallen: fallen.map(({ edits, dedents }) => ({ edits, dedents })) });
|
|
138
|
+
const left = [...collapse.clashed, ...collapse.broken].map((index) => itemAt(fallen, index).key);
|
|
139
|
+
return [[path, { source, collapse, left }]];
|
|
140
|
+
}));
|
|
141
|
+
// A hold may rest on a partner crush in any source and on any test, so it lifts once any source or test file changes.
|
|
142
|
+
// A crush collapse left out has no test holding it, since its text, not a test, keeps it standing.
|
|
143
|
+
holding = [...drops, ...[...collapses.values()].flatMap(({ left }) => left.map((key) => ({ key, tests: [] })))];
|
|
144
|
+
heldNow = basis === null ? [] : heldAfter(edges.getHolds(), holding, statusOf, () => basis);
|
|
145
|
+
heldKeys = new Set(heldNow.map(({ key }) => key));
|
|
146
|
+
isAnyLeft = [...collapses.values()].some(({ left }) => left.length > 0);
|
|
147
|
+
// The fork points some test took a side of, so a span whose loop ran once still asks for a second pass rather than whether it runs.
|
|
148
|
+
takenPoints = new Set(runs.flatMap(({ hits }) => hits.filter(({ side }) => side === 'true' || side === 'false').map(({ siteKey }) => siteKey)));
|
|
149
|
+
covered = new Map(merged);
|
|
150
|
+
observed = new Set(runs.flatMap(({ hits }) => hits.map(({ siteKey, side }) => sideKeyOf(siteKey, side))));
|
|
151
|
+
for (const { path, switches, crushes } of plan.files) {
|
|
152
|
+
for (const { key } of switches) {
|
|
153
|
+
if (!covered.has(key) && observed.has(sideKeyOf(key, 'reached')))
|
|
154
|
+
covered.set(key, { key, status: 'unjudged', catcher: null, backup: null });
|
|
155
|
+
}
|
|
156
|
+
for (const crush of crushes) {
|
|
157
|
+
const point = pointKeyOf(path, crush.decision);
|
|
158
|
+
if (!covered.has(crush.key) && ridingSidesOf(crush).some((side) => observed.has(sideKeyOf(point, side))))
|
|
159
|
+
covered.set(crush.key, { key: crush.key, status: 'unjudged', catcher: null, backup: null });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
sites = judgedSitesOf(plan.files, covered);
|
|
163
|
+
judged = siteQuestionsOf(sites, heldKeys, takenPoints, functionsOf(plan.files, runs));
|
|
164
|
+
// The plan step's graph asks of each file, export and function nothing reaches, a test's own code aside.
|
|
165
|
+
reachNodes = edges.getReachNodes();
|
|
166
|
+
plannedTests = new Set(plan.tests.map(({ path }) => path));
|
|
167
|
+
unused = unusedQuestionsOf(reachNodes.filter(({ file }) => !plannedTests.has(file) && !testRootPattern.test(file)));
|
|
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));
|
|
170
|
+
exportCalls = edges.getExportCalls();
|
|
171
|
+
// 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
|
+
loopSites = new Set(plan.files.flatMap(({ path, points }) => points.filter(({ kind }) => loopKinds.has(kind)).map(({ decision }) => pointKeyOf(path, decision))));
|
|
173
|
+
pathFindingsOf = () => {
|
|
174
|
+
const locations = new Map(plan.files.flatMap(({ path, crushes }) => crushes.map(({ decision, code, line }) => [pointKeyOf(path, decision), { file: path, code, line }])));
|
|
175
|
+
const findings = [
|
|
176
|
+
...noSplitsOf(exportCalls, loopSites).map(({ exportKey, siteKey }) => ({ exportKey, siteKey, kind: 'no-split' })),
|
|
177
|
+
...sameResultsOf(exportCalls).map(({ exportKey, siteKey }) => ({ exportKey, siteKey, kind: 'same-result' })),
|
|
178
|
+
];
|
|
179
|
+
const uncompared = uncomparedOf(exportCalls);
|
|
180
|
+
return pathQuestionsOf(findings.flatMap(({ exportKey, siteKey, kind }) => {
|
|
181
|
+
const location = locations.get(siteKey);
|
|
182
|
+
const [file, name] = unitFieldsOf(exportKey);
|
|
183
|
+
return location?.file === file ? [{ ...location, siteKey, kind, function: name, uncompared: uncompared.get(exportKey) ?? 0 }] : [];
|
|
184
|
+
}));
|
|
185
|
+
};
|
|
186
|
+
pathQuestions = pathFindingsOf();
|
|
187
|
+
all = [...judged.all, ...unused.all, ...explored, ...pathQuestions];
|
|
188
|
+
// 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
|
+
// 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
|
+
({ data: entries, error: justifyError } = readJustifications(runs));
|
|
191
|
+
if (justifyError)
|
|
192
|
+
throw justifyError;
|
|
193
|
+
sourceHashes = new Map(plan.files.map(({ path, hash }) => [path, hash]));
|
|
194
|
+
bases = verdictBasesOf(runs);
|
|
195
|
+
justified = justifiedOf({ entries, questions: all, sourceHashes, bases });
|
|
196
|
+
// An entry whose basis reads `refresh` takes the printed basis into its test file and stands from this run on.
|
|
197
|
+
refreshProblems = [];
|
|
198
|
+
refreshedIds = new Set();
|
|
199
|
+
for (const { id, basis, position, current } of justified.stale) {
|
|
200
|
+
if (basis !== 'refresh')
|
|
201
|
+
continue;
|
|
202
|
+
const failure = position ? refreshEntry({ root, id, position, basis: current }) : 'has no position, so set its basis by hand';
|
|
203
|
+
if (failure)
|
|
204
|
+
refreshProblems.push({ id, problem: failure });
|
|
205
|
+
else
|
|
206
|
+
refreshedIds.add(id);
|
|
207
|
+
}
|
|
208
|
+
acceptedEntries = [...justified.accepted, ...justified.stale.filter(({ id }) => refreshedIds.has(id))];
|
|
209
|
+
staleEntries = justified.stale.filter(({ id }) => !refreshedIds.has(id));
|
|
210
|
+
acceptedIds = new Set(acceptedEntries.map(({ id }) => id));
|
|
211
|
+
staleIds = new Set(staleEntries.map(({ id }) => id));
|
|
212
|
+
asked = [...judged.openWith(acceptedIds), ...unused.open, ...explored, ...pathQuestions];
|
|
213
|
+
open = asked.filter(({ id }) => !acceptedIds.has(id));
|
|
214
|
+
acceptedQuestions = asked.filter(({ id }) => acceptedIds.has(id));
|
|
215
|
+
reasonOf = new Map([...acceptedEntries, ...staleEntries].map(({ id, reason }) => [id, reason]));
|
|
216
|
+
positions = new Map(entries.map(({ id, position, path }) => [id, position ?? path]));
|
|
217
|
+
basisFor = (question) => basisOf({ question, sourceHashes, bases, position: positions.get(question.id) });
|
|
218
|
+
// An entry for a question a test or an edit already closed settles nothing, so it is asked to go.
|
|
219
|
+
// 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
|
+
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
|
+
// Which tests caught each site and which reached it, read from every file's run, for checking each test's answer.
|
|
223
|
+
caughtBy = new Map();
|
|
224
|
+
reachedBy = new Map();
|
|
225
|
+
note = (into, key, test) => {
|
|
226
|
+
into.set(key, (into.get(key) ?? new Set()).add(test));
|
|
227
|
+
};
|
|
228
|
+
crushesByDecision = Map.groupBy(plan.files.flatMap((file) => file.crushes.flatMap((crush) => ridingSidesOf(crush).map((side) => ({ key: crush.key, riding: sideKeyOf(pointKeyOf(file.path, crush.decision), side) })))), (crush) => crush.riding);
|
|
229
|
+
for (const run of runs) {
|
|
230
|
+
for (const verdict of run.verdicts) {
|
|
231
|
+
for (const test of [verdict.catcher, verdict.backup])
|
|
232
|
+
if (test)
|
|
233
|
+
note(caughtBy, verdict.key, test);
|
|
234
|
+
}
|
|
235
|
+
for (const hit of run.hits) {
|
|
236
|
+
if (hit.side === 'reached')
|
|
237
|
+
note(reachedBy, hit.siteKey, hit.testKey);
|
|
238
|
+
for (const crush of crushesByDecision.get(sideKeyOf(hit.siteKey, hit.side)) ?? [])
|
|
239
|
+
note(reachedBy, crush.key, hit.testKey);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// A catch in any part counts, even when another test supplied the merged verdict.
|
|
243
|
+
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 }))
|
|
249
|
+
for (const test of tests)
|
|
250
|
+
note(caughtBy, key, test);
|
|
251
|
+
answers = runs.flatMap(({ file, tests }) => tests.flatMap(({ key, answers: ids }) => ids.map((id) => ({ test: key, id, file }))));
|
|
252
|
+
// A test answering a graph question reaches its node from the test's own file through the graph.
|
|
253
|
+
graphIds = new Set(unused.all.map(({ id }) => id));
|
|
254
|
+
graphAnswers = answers.filter(({ id }) => graphIds.has(id));
|
|
255
|
+
answerFiles = new Map(answers.map(({ test, file }) => [test, file]));
|
|
256
|
+
answerReach = new Map(reachedBy);
|
|
257
|
+
graphOutOf = () => new Map([...Map.groupBy(edges.getReachEdges(), ({ fromKey }) => fromKey)].map(([from, edges]) => [from, edges.map(({ toKey }) => toKey)]));
|
|
258
|
+
pathArgs = z.array(z.string()).parse(inject(questionsRelatedProvideKey));
|
|
259
|
+
paths = pathArgs.map((path) => relative(root, resolve(root, path)));
|
|
260
|
+
visibleFiles = () => {
|
|
261
|
+
if (!paths.length || paths.includes(''))
|
|
262
|
+
return null;
|
|
263
|
+
const matching = reachNodes.filter(({ file }) => paths.some((path) => file === path || file.startsWith(path + sep))).map(({ key }) => key);
|
|
264
|
+
const reached = reachedFrom((graphOut ??= graphOutOf()), matching);
|
|
265
|
+
return new Set(reachNodes.filter(({ key }) => reached.has(key)).map(({ file }) => file));
|
|
266
|
+
};
|
|
267
|
+
visible = visibleFiles();
|
|
268
|
+
isVisible = (file) => visible === null || visible.has(file);
|
|
269
|
+
noteGraphReach = (claims) => {
|
|
270
|
+
if (!claims.length || !graphIds.size)
|
|
271
|
+
return;
|
|
272
|
+
const out = (graphOut ??= graphOutOf());
|
|
273
|
+
for (const [file, tests] of Map.groupBy(claims, ({ test }) => fileKey(entryAt(answerFiles, test, 'the file of an answering test')))) {
|
|
274
|
+
for (const key of reachedFrom(out, [file]))
|
|
275
|
+
for (const { test } of tests)
|
|
276
|
+
note(answerReach, key, test);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
noteGraphReach(graphAnswers);
|
|
280
|
+
evidence = { caughtBy, reachedBy: answerReach, enteredFor: judged.enteredFor };
|
|
281
|
+
problems = answerProblemsOf(answers, all, evidence);
|
|
282
|
+
noteGraphReach(problems);
|
|
283
|
+
refusedChoices = answerChoicesOf(new Set(problems.map(({ test }) => test)), all, evidence);
|
|
284
|
+
// A test that holds nothing up is asked to go only once the run is verified and no source it reaches has an open question, since each answer there can move which test catches what.
|
|
285
|
+
unsettledTests = unsettledTestsOf({ reach: reachedBy, fileOfSite: new Map(sites.map(({ key, file }) => [key, file])), openFiles: new Set(open.map(({ file }) => file)) });
|
|
286
|
+
tests = runs.flatMap((run) => run.tests);
|
|
287
|
+
names = new Map(runs.flatMap(({ file, tests: ran }) => ran.flatMap(({ key, name }) => (name ? [[key, { file, ...name }]] : []))));
|
|
288
|
+
labelOf = (key) => {
|
|
289
|
+
const name = names.get(key);
|
|
290
|
+
return name ? testLabelOf(name) : key;
|
|
291
|
+
};
|
|
292
|
+
// A part a stale plan refused measured neither its tests' steps nor their reach, so its tests are asked nothing until the next run judges them.
|
|
293
|
+
measured = runs.filter(({ changed }) => !changed.length);
|
|
294
|
+
measuredTests = new Set(measured.flatMap(({ tests: ran }) => ran.map(({ key }) => key)));
|
|
295
|
+
removableTests = removableTestsInput.parse(inject(removableTestsProvideKey));
|
|
296
|
+
// A test reading an exported pattern counts as reaching it, so a removal keeps one test reading each pattern.
|
|
297
|
+
keyOfLabel = new Map([...names].map(([key, name]) => [testLabelOf(name), key]));
|
|
298
|
+
readers = reachNodes.flatMap(({ key, patternTests }) => (patternTests ? patternTests.split('\n').map((reader) => ({ key, reader })) : []));
|
|
299
|
+
patternReaders = [...Map.groupBy(readers, ({ key }) => key)].map(([key, each]) => [key, new Set(each.flatMap(({ reader }) => keyOfLabel.get(reader) ?? []))]);
|
|
300
|
+
removalReach = new Map([...reachedBy, ...patternReaders]);
|
|
301
|
+
// A reader the graph names only by its file, a hook or a case table, could be any of its tests, so none of that file's tests is asked to go.
|
|
302
|
+
shieldedFiles = new Set(readers.filter(({ reader }) => !keyOfLabel.has(reader)).map(({ reader }) => reader));
|
|
303
|
+
isAskable = ({ key }) => measuredTests.has(key) && !unsettledTests.has(key) && !shieldedFiles.has(names.get(key)?.file ?? '');
|
|
304
|
+
removable = isLiveVerified && !isAnyLeft ? removableOf({ tests, reach: removalReach, verdicts: merged, holds: heldNow, liveQuestions: new Set(all.map(({ id }) => id)), catchingTests, removableTests }).filter(isAskable) : [];
|
|
305
|
+
testQuestions = testQuestionsOf(removable, names);
|
|
306
|
+
// Each passing test's steps against the count it states, read from every test file's last run the record keeps, a partial record's untouched files included.
|
|
307
|
+
outsideOf = new Map(runs.flatMap(({ tests: ran, outside }) => ran.map(({ key }) => [key, outside])));
|
|
308
|
+
counted = measured.flatMap(({ tests: ran }) => {
|
|
309
|
+
return ran.flatMap(({ key, passed, steps, statedSteps, stepsReason, isSteady }) => {
|
|
310
|
+
const name = names.get(key);
|
|
311
|
+
return passed && name ? [{ ...name, key, steps, statedSteps, stepsReason, isSteady, outside: outsideOf.get(key) ?? [] }] : [];
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
testMetaQuestions = stepsSettingInput.parse(inject(stepsProvideKey)) ? stepsQuestionsOf(counted) : [];
|
|
315
|
+
justifiedSites = new Set(acceptedQuestions.flatMap(({ sites: keys }) => keys));
|
|
316
|
+
// Every fork side some test took, read once for every file's figures, since the hits are most of the record.
|
|
317
|
+
taken = new Set(runs.flatMap(({ hits }) => hits.filter(({ side }) => side === 'true' || side === 'false').map(({ siteKey, side }) => sideKeyOf(siteKey, side))));
|
|
318
|
+
// A file's or the project's figures: its open questions with any asked of the project's tests, then cov, the score and behavior cov.
|
|
319
|
+
figureLineOf = (paths, testsAsked) => {
|
|
320
|
+
const points = plan.files.filter(({ path }) => paths.has(path)).flatMap(({ path, points: each }) => each.map(({ decision, kind }) => ({ key: pointKeyOf(path, decision), kind })));
|
|
321
|
+
const mine = sites.filter(({ file }) => paths.has(file));
|
|
322
|
+
const questions = open.filter(({ file }) => paths.has(file)).length + testsAsked;
|
|
323
|
+
const justifiedCount = acceptedQuestions.filter(({ file }) => paths.has(file)).length;
|
|
324
|
+
return `${questions} questions · ${justifiedCount} justified · ${figuresOf({ points, taken, sites: mine, justified: justifiedSites })}`;
|
|
325
|
+
};
|
|
326
|
+
describe('crush', () => {
|
|
327
|
+
for (const { path, crushes } of plan.files) {
|
|
328
|
+
if (!isVisible(path))
|
|
329
|
+
continue;
|
|
330
|
+
it(path, async ({ annotate, task }) => {
|
|
331
|
+
await annotate(figureLineOf(new Set([path]), 0), 'figures');
|
|
332
|
+
const mine = open.filter(({ file }) => file === path);
|
|
333
|
+
if (mine.length)
|
|
334
|
+
task.meta.crushOpenIn = path;
|
|
335
|
+
for (const [index, question] of mine.filter(({ id }) => !staleIds.has(id)).entries()) {
|
|
336
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
337
|
+
await annotate(`${index + 1}. ${path}:${question.line} ${question.ask}\n id: ${question.id}\n basis: ${basisFor(question)}\n ${question.answers.join('\n ')}`, question.kind);
|
|
338
|
+
}
|
|
339
|
+
// A justification whose basis moved is reported apart from new questions, since its reason may still hold and needs only a refresh.
|
|
340
|
+
for (const question of mine.filter(({ id }) => staleIds.has(id))) {
|
|
341
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
342
|
+
await annotate(`${path}:${question.line} ${question.ask}\n id: ${question.id}\n basis: ${basisFor(question)}\n justified as "${reasonOf.get(question.id)}", but its basis changed since: answer it, or set its basis to refresh once the reason still holds`, 'justification');
|
|
343
|
+
}
|
|
344
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
345
|
+
for (const question of acceptedQuestions.filter(({ file }) => file === path))
|
|
346
|
+
await annotate(`${path}:${question.line} ${question.ask}\n id: ${question.id}\n reason: ${reasonOf.get(question.id)}`, 'justified');
|
|
347
|
+
// Collapse applies every crush that fell, so the agent sees the smaller program a yes to each crush question leaves.
|
|
348
|
+
const kept = collapses.get(path);
|
|
349
|
+
if (kept) {
|
|
350
|
+
const { source, collapse } = kept;
|
|
351
|
+
const holds = crushes.filter(({ key }) => heldKeys.has(key)).length;
|
|
352
|
+
// Every file was checked with the one global set forced, so a crush any collapse left out leaves every file unverified.
|
|
353
|
+
const isFileVerified = isLiveVerified && !isAnyLeft;
|
|
354
|
+
await annotate(`collapsing its fallen crushes applies ${collapse.applied.length}, drops ${collapse.covered.length} gone with another, refuses ${collapse.clashed.length} clashing, backs off ${collapse.broken.length} that would not parse and holds back ${holds} a test failed with together or collapse left out, ${source.length} characters become ${collapse.source.length}, ${isFileVerified ? 'verified against every test' : 'not yet verified, so the next run checks it'}`, 'collapse');
|
|
355
|
+
await annotate(collapse.source, 'collapsed source');
|
|
356
|
+
}
|
|
357
|
+
expect(mine.map(({ id }) => id), `${mine.length} questions open in ${path}`).toEqual([]);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
it('project', async ({ annotate, task }) => {
|
|
361
|
+
const shownStale = stale.filter(({ file }) => isVisible(file));
|
|
362
|
+
const shown = open.filter(({ file }) => isVisible(file));
|
|
363
|
+
const isQuestionVisible = ({ id }) => visible === null || visible.has(decodeURIComponent(id.split('|')[1] ?? ''));
|
|
364
|
+
const shownTests = testQuestions.filter(isQuestionVisible);
|
|
365
|
+
const shownMeta = testMetaQuestions.filter(isQuestionVisible);
|
|
366
|
+
const shownProblems = problems.filter(({ test }) => isVisible(answerFiles.get(test) ?? ''));
|
|
367
|
+
const shownJustifications = justifyProblems.filter(isQuestionVisible);
|
|
368
|
+
const shownRuns = runs.filter(({ file }) => isVisible(file));
|
|
369
|
+
await annotate(figureLineOf(new Set(plan.files.map(({ path }) => path).filter(isVisible)), shownMeta.length + shownStale.length), 'figures');
|
|
370
|
+
// A file crush plans no sites in, as one nothing gates or one nothing reaches, has no test of its own, so the project's test asks for it.
|
|
371
|
+
const plannedPaths = new Set(plan.files.map(({ path }) => path));
|
|
372
|
+
for (const [index, question] of shown.filter(({ file }) => !plannedPaths.has(file)).entries()) {
|
|
373
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
374
|
+
await annotate(`${index + 1}. ${question.file}:${question.line} ${question.ask}\n id: ${question.id}\n ${question.answers.join('\n ')}`, question.kind);
|
|
375
|
+
}
|
|
376
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
377
|
+
for (const key of shownRuns.flatMap(({ rerunFailing }) => rerunFailing))
|
|
378
|
+
await annotate(`${key} passes only its first run, so it judges nothing and the sites only it reaches read as unreached`, 'rerun');
|
|
379
|
+
for (const { file, verdicts: judged, changed } of shownRuns) {
|
|
380
|
+
const unjudged = judged.filter(({ status }) => status === 'unjudged').length;
|
|
381
|
+
// A stale plan refuses its file before any site is judged, so every unjudged site of such a part is the changed sources' doing, never a mutant's.
|
|
382
|
+
const reason = changed.length ? `${changed.join(', ')} changed during the run, so the next run judges them` : 'a mutant left its module state broken and no later rerun could be trusted';
|
|
383
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
384
|
+
if (unjudged)
|
|
385
|
+
await annotate(`${unjudged} sites in ${file} are unjudged, since ${reason}`, 'unjudged');
|
|
386
|
+
}
|
|
387
|
+
for (const { test, id, problem } of shownProblems) {
|
|
388
|
+
const choices = refusedChoices.get(test) ?? [];
|
|
389
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
390
|
+
await annotate([`${labelOf(test)} answers ${id}, but ${problem}`, ...choices].join('\n '), 'answer');
|
|
391
|
+
}
|
|
392
|
+
for (const { file, changes } of shownStale) {
|
|
393
|
+
const reasons = changes.map(({ path, reason }) => `${reason} ${path}`).join(', ');
|
|
394
|
+
const by = `'./${file.replaceAll("'", "'\\''")}'`;
|
|
395
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
396
|
+
await annotate(`${file}: ${reasons}. Run \`vp run record:related ${by}\`.`, 'stale');
|
|
397
|
+
}
|
|
398
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
399
|
+
for (const [index, question] of shownTests.entries())
|
|
400
|
+
await annotate(`${index + 1}. ${question.ask}\n id: ${question.id}\n ${question.answers.join('\n ')}`, 'test');
|
|
401
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
402
|
+
for (const [index, question] of shownMeta.entries())
|
|
403
|
+
await annotate(`${index + 1}. ${question.ask}\n id: ${question.id}\n ${question.answers.join('\n ')}`, question.kind);
|
|
404
|
+
// oxlint-disable-next-line no-await-in-loop -- Vitest records an annotation only once its runner call resolves, so concurrent ones can land out of order
|
|
405
|
+
for (const problem of shownJustifications)
|
|
406
|
+
await annotate(`a justification of ${problem.id} ${problem.problem}`, 'justify');
|
|
407
|
+
const failing = shownRuns.flatMap(({ tests: ran }) => ran.filter(({ passed }) => !passed).map(({ key }) => key));
|
|
408
|
+
for (const { file, failure, rerunFailing } of shownRuns) {
|
|
409
|
+
if (failure !== null)
|
|
410
|
+
failing.push(`${file}: ${failure}`);
|
|
411
|
+
// A test failing its rerun judges no site it reaches, so it holds the report back as a failing baseline does.
|
|
412
|
+
for (const key of rerunFailing)
|
|
413
|
+
failing.push(`${key}: fails when rerun with nothing changed`);
|
|
414
|
+
}
|
|
415
|
+
const questions = shown.length + shownTests.length + shownMeta.length + shownStale.length;
|
|
416
|
+
task.meta.crushOpen = questions;
|
|
417
|
+
expect({ questions, answers: shownProblems.length, justifications: shownJustifications.length, failing }).toEqual({
|
|
418
|
+
questions: 0,
|
|
419
|
+
answers: 0,
|
|
420
|
+
justifications: 0,
|
|
421
|
+
failing: [],
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
catch (e_1) {
|
|
427
|
+
env_1.error = e_1;
|
|
428
|
+
env_1.hasError = true;
|
|
429
|
+
}
|
|
430
|
+
finally {
|
|
431
|
+
__disposeResources(env_1);
|
|
432
|
+
}
|