@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,66 @@
|
|
|
1
|
+
import { eq, inArray, sql } from 'drizzle-orm';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { siteVerdicts, sites } from '../../crush.tables.js';
|
|
4
|
+
import { siteIdsFor } from './plan.db.js';
|
|
5
|
+
import { chunksOf } from './record.db.js';
|
|
6
|
+
// The read units are stored as a JSON list of unit keys.
|
|
7
|
+
const readUnitsInput = z.array(z.string());
|
|
8
|
+
// The verdicts the record holds for the named sites, by key, a site with none left out.
|
|
9
|
+
export const getSiteVerdicts = (db, keys) => {
|
|
10
|
+
const rows = chunksOf(keys.map((key) => ({ key }))).flatMap((chunk) => {
|
|
11
|
+
return db
|
|
12
|
+
.select({
|
|
13
|
+
key: sites.siteKey,
|
|
14
|
+
status: siteVerdicts.status,
|
|
15
|
+
catcher: siteVerdicts.catcherKey,
|
|
16
|
+
backup: siteVerdicts.backupKey,
|
|
17
|
+
reruns: siteVerdicts.reruns,
|
|
18
|
+
basis: siteVerdicts.basisHash,
|
|
19
|
+
owner: siteVerdicts.ownerFile,
|
|
20
|
+
readUnits: siteVerdicts.readUnits,
|
|
21
|
+
readsHash: siteVerdicts.readsHash,
|
|
22
|
+
isReused: siteVerdicts.isReused,
|
|
23
|
+
isBackupSearched: siteVerdicts.isBackupSearched,
|
|
24
|
+
})
|
|
25
|
+
.from(siteVerdicts)
|
|
26
|
+
.innerJoin(sites, eq(siteVerdicts.site, sites.id))
|
|
27
|
+
.where(inArray(sites.siteKey, chunk.map(({ key }) => key)))
|
|
28
|
+
.all();
|
|
29
|
+
});
|
|
30
|
+
// Verdicts whose riders are the same read the same units, so each distinct list is parsed once and shared, never written to.
|
|
31
|
+
const parsed = new Map();
|
|
32
|
+
const unitsOf = (text) => {
|
|
33
|
+
const held = parsed.get(text);
|
|
34
|
+
if (held)
|
|
35
|
+
return held;
|
|
36
|
+
const units = readUnitsInput.parse(JSON.parse(text));
|
|
37
|
+
parsed.set(text, units);
|
|
38
|
+
return units;
|
|
39
|
+
};
|
|
40
|
+
return new Map(rows.map(({ readUnits, ...row }) => [row.key, { ...row, readUnits: unitsOf(readUnits) }]));
|
|
41
|
+
};
|
|
42
|
+
// Saves each site's verdict, replacing the one before, in one transaction.
|
|
43
|
+
export const setSiteVerdicts = (db, verdicts) => {
|
|
44
|
+
db.transaction((tx) => {
|
|
45
|
+
const siteOf = siteIdsFor(tx, verdicts.map(({ key }) => key));
|
|
46
|
+
const rows = verdicts.flatMap(({ key, status, catcher, backup, reruns, basis, owner, readUnits, readsHash, isReused, isBackupSearched }) => {
|
|
47
|
+
const site = siteOf.get(key);
|
|
48
|
+
return site ? [{ site, status, catcherKey: catcher, backupKey: backup, reruns, basisHash: basis, ownerFile: owner, readUnits: JSON.stringify(readUnits), readsHash, isReused, isBackupSearched }] : [];
|
|
49
|
+
});
|
|
50
|
+
const set = {
|
|
51
|
+
status: sql `excluded.status`,
|
|
52
|
+
catcherKey: sql `excluded.catcher_key`,
|
|
53
|
+
backupKey: sql `excluded.backup_key`,
|
|
54
|
+
reruns: sql `excluded.reruns`,
|
|
55
|
+
basisHash: sql `excluded.basis_hash`,
|
|
56
|
+
ownerFile: sql `excluded.owner_file`,
|
|
57
|
+
readUnits: sql `excluded.read_units`,
|
|
58
|
+
readsHash: sql `excluded.reads_hash`,
|
|
59
|
+
isReused: sql `excluded.is_reused`,
|
|
60
|
+
isBackupSearched: sql `excluded.is_backup_searched`,
|
|
61
|
+
};
|
|
62
|
+
for (const chunk of chunksOf(rows)) {
|
|
63
|
+
tx.insert(siteVerdicts).values(chunk).onConflictDoUpdate({ target: siteVerdicts.site, set }).run();
|
|
64
|
+
}
|
|
65
|
+
}, { behavior: 'immediate' });
|
|
66
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Verified } from '../../judge/judge.schema.ts';
|
|
2
|
+
import { CrushError } from '../../utils/errors.ts';
|
|
3
|
+
import { type Record } from './record.db.ts';
|
|
4
|
+
export declare const clearVerified: (db: Record, path: string) => void;
|
|
5
|
+
export declare const setVerified: (db: Record, { file, candidates: candidatesHash, dropped }: Verified) => CrushError | null;
|
|
6
|
+
export declare const getCheckedCandidatesNullable: (db: Record, path: string) => string | null;
|
|
7
|
+
export declare const getVerified: (db: Record) => Verified[];
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { asc, eq, inArray } from 'drizzle-orm';
|
|
2
|
+
import { testFiles, testRuns, verifiedDrops, verifiedDropTests, verifiedFiles } from '../../crush.tables.js';
|
|
3
|
+
import { entryAt } from '../../utils/lookup.js';
|
|
4
|
+
import { CrushError } from '../../utils/errors.js';
|
|
5
|
+
import { byPath } from '../parts.operations.js';
|
|
6
|
+
import { siteIdsOf, siteKeysOf } from './plan.db.js';
|
|
7
|
+
import { chunksOf } from './record.db.js';
|
|
8
|
+
// Removes one test file's joint-check part, so a run that could not check it leaves no earlier check standing for it.
|
|
9
|
+
export const clearVerified = (db, path) => {
|
|
10
|
+
db.delete(verifiedFiles)
|
|
11
|
+
.where(inArray(verifiedFiles.testFile, db.select({ id: testFiles.id }).from(testFiles).where(eq(testFiles.path, path))))
|
|
12
|
+
.run();
|
|
13
|
+
};
|
|
14
|
+
// One test file's part of the joint check in one transaction, replacing its last.
|
|
15
|
+
export const setVerified = (db, { file, candidates: candidatesHash, dropped }) => {
|
|
16
|
+
return db.transaction((tx) => {
|
|
17
|
+
const [row] = tx.select({ id: testFiles.id }).from(testFiles).where(eq(testFiles.path, file)).limit(1).all();
|
|
18
|
+
if (!row)
|
|
19
|
+
return new CrushError(`${file} has no judged part, so the joint check ran before judge saved it`);
|
|
20
|
+
tx.delete(verifiedFiles).where(eq(verifiedFiles.testFile, row.id)).run();
|
|
21
|
+
tx.insert(verifiedFiles).values({ testFile: row.id, candidatesHash }).run();
|
|
22
|
+
const siteOf = siteIdsOf(tx);
|
|
23
|
+
const testOf = new Map(tx
|
|
24
|
+
.select({ id: testRuns.id, testKey: testRuns.testKey })
|
|
25
|
+
.from(testRuns)
|
|
26
|
+
.where(eq(testRuns.testFile, row.id))
|
|
27
|
+
.all()
|
|
28
|
+
.map(({ id, testKey }) => [testKey, id]));
|
|
29
|
+
const dropRows = dropped.map(({ key }) => ({ testFile: row.id, site: entryAt(siteOf, key, 'a dropped crush') }));
|
|
30
|
+
// A file drops each crush once, so its drop's row is found by its site.
|
|
31
|
+
const insertDrops = (chunk) => tx.insert(verifiedDrops).values(chunk).returning({ id: verifiedDrops.id, site: verifiedDrops.site }).all();
|
|
32
|
+
const inserted = chunksOf(dropRows).flatMap(insertDrops);
|
|
33
|
+
const dropOf = new Map(inserted.map(({ id, site }) => [site, id]));
|
|
34
|
+
const testRows = dropped.flatMap(({ key, tests }) => {
|
|
35
|
+
const drop = entryAt(dropOf, entryAt(siteOf, key, 'a dropped crush'), 'a dropped crush');
|
|
36
|
+
return tests.map((test) => ({ dropped: drop, test: entryAt(testOf, test, 'a test that failed with a dropped crush') }));
|
|
37
|
+
});
|
|
38
|
+
for (const chunk of chunksOf(testRows))
|
|
39
|
+
tx.insert(verifiedDropTests).values(chunk).run();
|
|
40
|
+
return null;
|
|
41
|
+
}, { behavior: 'immediate' });
|
|
42
|
+
};
|
|
43
|
+
// The candidate set one test file's joint check ran last, by its hash, or null when it has checked none.
|
|
44
|
+
export const getCheckedCandidatesNullable = (db, path) => {
|
|
45
|
+
const [row] = db.select({ candidates: verifiedFiles.candidatesHash }).from(verifiedFiles).innerJoin(testFiles, eq(verifiedFiles.testFile, testFiles.id)).where(eq(testFiles.path, path)).limit(1).all();
|
|
46
|
+
return row ? row.candidates : null;
|
|
47
|
+
};
|
|
48
|
+
// Every test file's part of the joint check, in path order.
|
|
49
|
+
export const getVerified = (db) => {
|
|
50
|
+
return db.transaction((tx) => {
|
|
51
|
+
const keyOf = siteKeysOf(tx);
|
|
52
|
+
const testKeyOf = new Map(tx
|
|
53
|
+
.select({ id: testRuns.id, testKey: testRuns.testKey })
|
|
54
|
+
.from(testRuns)
|
|
55
|
+
.all()
|
|
56
|
+
.map(({ id, testKey }) => [id, testKey]));
|
|
57
|
+
const tests = Map.groupBy(tx.select().from(verifiedDropTests).orderBy(asc(verifiedDropTests.id)).all(), ({ dropped }) => dropped);
|
|
58
|
+
const drops = Map.groupBy(tx.select().from(verifiedDrops).orderBy(asc(verifiedDrops.id)).all(), ({ testFile }) => testFile);
|
|
59
|
+
const parts = tx
|
|
60
|
+
.select({ testFile: verifiedFiles.testFile, path: testFiles.path, candidatesHash: verifiedFiles.candidatesHash })
|
|
61
|
+
.from(verifiedFiles)
|
|
62
|
+
.innerJoin(testFiles, eq(verifiedFiles.testFile, testFiles.id))
|
|
63
|
+
.all()
|
|
64
|
+
.map(({ testFile, path, candidatesHash }) => ({
|
|
65
|
+
file: path,
|
|
66
|
+
candidates: candidatesHash,
|
|
67
|
+
dropped: (drops.get(testFile) ?? []).map(({ id, site }) => ({ key: entryAt(keyOf, site, 'a dropped crush'), tests: (tests.get(id) ?? []).map(({ test }) => entryAt(testKeyOf, test, 'a test that failed with a dropped crush')) })),
|
|
68
|
+
}));
|
|
69
|
+
return byPath(parts);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Judged } from '../judge/judge.schema.ts';
|
|
2
|
+
export declare const byPath: <T extends {
|
|
3
|
+
file: string;
|
|
4
|
+
}>(parts: T[]) => T[];
|
|
5
|
+
type PartRows = {
|
|
6
|
+
runs: object[];
|
|
7
|
+
taken: string[];
|
|
8
|
+
entered: object[];
|
|
9
|
+
passes: object[];
|
|
10
|
+
reads: object[];
|
|
11
|
+
outside: object[];
|
|
12
|
+
changed: object[];
|
|
13
|
+
properties: object[];
|
|
14
|
+
};
|
|
15
|
+
export declare const partTextOf: ({ taken, ...rows }: PartRows) => string;
|
|
16
|
+
export declare const hitTextOf: (site: number, side: Judged['hits'][number]['side'], testKey: string | undefined) => string;
|
|
17
|
+
type PartFromInput = Pick<Judged, 'entered' | 'reads' | 'passes' | 'outside' | 'changed' | 'properties'> & {
|
|
18
|
+
runs: {
|
|
19
|
+
testKey: string;
|
|
20
|
+
ns: number;
|
|
21
|
+
}[];
|
|
22
|
+
taken: Judged['hits'];
|
|
23
|
+
siteOf: ReadonlyMap<string, number>;
|
|
24
|
+
};
|
|
25
|
+
export declare const partFrom: ({ runs, taken, entered, reads, passes, outside, changed, properties, siteOf }: PartFromInput) => string;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const byPath = (parts) => parts.toSorted((left, right) => left.file.localeCompare(right.file));
|
|
2
|
+
// One row as comparable text, its fields in name order and a flag as the integer stored, so a row read back and one about to be written compare whatever order or type either lists them in.
|
|
3
|
+
const rowTextOf = (row) => {
|
|
4
|
+
return JSON.stringify(Object.entries(row)
|
|
5
|
+
// oxlint-disable-next-line typescript/no-unsafe-return -- a row of any table is compared field by field, whatever its columns hold
|
|
6
|
+
.map(([name, value]) => [name, typeof value === 'boolean' ? Number(value) : value])
|
|
7
|
+
.toSorted(([left], [right]) => String(left).localeCompare(String(right))));
|
|
8
|
+
};
|
|
9
|
+
export const partTextOf = ({ taken, ...rows }) => JSON.stringify([taken.toSorted(), ...Object.values(rows).map((table) => table.map(rowTextOf).toSorted())]);
|
|
10
|
+
// Hits have a fixed shape. Comparing tuples avoids sorting three property names for every hit in both copies of a part.
|
|
11
|
+
export const hitTextOf = (site, side, testKey) => JSON.stringify([site, side, testKey]);
|
|
12
|
+
// The part a run is about to write without its verdicts, which `setJudged` writes apart, leaving out a row for a site no plan names and a hit by a test this file did not run.
|
|
13
|
+
export const partFrom = ({ runs, taken, entered, reads, passes, outside, changed, properties, siteOf }) => {
|
|
14
|
+
const keys = new Set(runs.map(({ testKey }) => testKey));
|
|
15
|
+
return partTextOf({
|
|
16
|
+
runs: runs.map(({ ns: _ns, ...run }) => run),
|
|
17
|
+
taken: taken.flatMap(({ siteKey, side, testKey }) => {
|
|
18
|
+
const site = siteOf.get(siteKey);
|
|
19
|
+
return site && keys.has(testKey) ? [hitTextOf(site, side, testKey)] : [];
|
|
20
|
+
}),
|
|
21
|
+
entered: entered.filter(({ testKey }) => keys.has(testKey)).map(({ unit, testKey }) => ({ unit, testKey })),
|
|
22
|
+
passes: passes.flatMap(({ siteKey, side, passes: count }) => {
|
|
23
|
+
const site = siteOf.get(siteKey);
|
|
24
|
+
return site ? [{ site, side, passes: count }] : [];
|
|
25
|
+
}),
|
|
26
|
+
reads: reads.map(({ path, hash }) => ({ path, hash })),
|
|
27
|
+
outside: outside.map((path) => ({ path })),
|
|
28
|
+
changed: changed.map((path) => ({ path })),
|
|
29
|
+
properties: [...new Set(properties)].map((name) => ({ name })),
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExportCallOutput } from '../capture/capture.schema.ts';
|
|
2
|
+
type SameResult = {
|
|
3
|
+
exportKey: string;
|
|
4
|
+
siteKey: string;
|
|
5
|
+
result: ExportCallOutput['result'];
|
|
6
|
+
};
|
|
7
|
+
export declare const uncomparedOf: (calls: readonly ExportCallOutput[]) => Map<string, number>;
|
|
8
|
+
export declare const sameResultsOf: (calls: readonly ExportCallOutput[]) => SameResult[];
|
|
9
|
+
type NoSplit = {
|
|
10
|
+
exportKey: string;
|
|
11
|
+
siteKey: string;
|
|
12
|
+
result: ExportCallOutput['result'];
|
|
13
|
+
};
|
|
14
|
+
export declare const noSplitsOf: (calls: readonly ExportCallOutput[], loops: ReadonlySet<string>) => NoSplit[];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { encodedOf, snapshotOf, uncloned } from '../capture/capture.operations.js';
|
|
2
|
+
import { itemAt } from '../utils/lookup.js';
|
|
3
|
+
const replayableExportsOf = (calls) => {
|
|
4
|
+
return Map.groupBy(calls.filter(({ args, isPathCut }) => !isPathCut && !args.includes(uncloned)), ({ exportKey }) => exportKey);
|
|
5
|
+
};
|
|
6
|
+
// How many calls of each export the path checks leave out for an argument crush could not copy, which no verdict compared.
|
|
7
|
+
export const uncomparedOf = (calls) => {
|
|
8
|
+
const counts = new Map();
|
|
9
|
+
for (const { exportKey, args, isPathCut } of calls) {
|
|
10
|
+
if (!isPathCut && args.includes(uncloned))
|
|
11
|
+
counts.set(exportKey, (counts.get(exportKey) ?? 0) + 1);
|
|
12
|
+
}
|
|
13
|
+
return counts;
|
|
14
|
+
};
|
|
15
|
+
const outputOf = ({ outcome, result }) => (outcome === 'returned' && result !== uncloned ? encodedOf(snapshotOf(result)) : null);
|
|
16
|
+
const pathKeyOf = (steps) => JSON.stringify(steps.map(({ siteKey, side, passes }) => [siteKey, side, passes]));
|
|
17
|
+
const partingOf = (left, right) => {
|
|
18
|
+
for (const [index, step] of left.entries()) {
|
|
19
|
+
const other = right[index];
|
|
20
|
+
if (other?.siteKey !== step.siteKey || other.side !== step.side || other.passes !== step.passes)
|
|
21
|
+
return step.siteKey;
|
|
22
|
+
}
|
|
23
|
+
return itemAt(right, left.length).siteKey;
|
|
24
|
+
};
|
|
25
|
+
// Finds the forks where observed paths with a shared return part.
|
|
26
|
+
export const sameResultsOf = (calls) => {
|
|
27
|
+
const findings = [];
|
|
28
|
+
for (const [exportKey, own] of replayableExportsOf(calls)) {
|
|
29
|
+
// Only the export's own steps determine its path. A callee's unrelated forks cannot make two paths here.
|
|
30
|
+
const paths = Map.groupBy(own, ({ steps }) => pathKeyOf(steps));
|
|
31
|
+
const constants = [];
|
|
32
|
+
for (const [key, path] of paths) {
|
|
33
|
+
const first = itemAt(path, 0);
|
|
34
|
+
const outputs = new Set(path.map(outputOf));
|
|
35
|
+
if (outputs.size !== 1 || outputs.has(null))
|
|
36
|
+
continue;
|
|
37
|
+
constants.push({ key, output: itemAt([...outputs], 0), steps: first.steps, result: first.result });
|
|
38
|
+
}
|
|
39
|
+
for (const sharing of Map.groupBy(constants, ({ output }) => output).values()) {
|
|
40
|
+
// Sorting keeps paths with a common prefix adjacent, so each divergence has an adjacent pair.
|
|
41
|
+
sharing.sort((left, right) => (left.key < right.key ? -1 : 1));
|
|
42
|
+
const sites = new Set();
|
|
43
|
+
for (let index = 1; index < sharing.length; index++) {
|
|
44
|
+
const { result, steps } = itemAt(sharing, index - 1);
|
|
45
|
+
const siteKey = partingOf(steps, itemAt(sharing, index).steps);
|
|
46
|
+
if (!sites.has(siteKey))
|
|
47
|
+
findings.push({ exportKey, result, siteKey });
|
|
48
|
+
sites.add(siteKey);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return findings;
|
|
53
|
+
};
|
|
54
|
+
// Both sides need evidence with one shared return. A call counts once on each side it took.
|
|
55
|
+
// A loop's test is taken both ways by any call that iterates, so a site in `loops` is never asked of.
|
|
56
|
+
export const noSplitsOf = (calls, loops) => {
|
|
57
|
+
const findings = [];
|
|
58
|
+
for (const [exportKey, own] of replayableExportsOf(calls)) {
|
|
59
|
+
const forks = new Map();
|
|
60
|
+
for (const call of own) {
|
|
61
|
+
for (const [siteKey, steps] of Map.groupBy(call.steps, ({ siteKey }) => siteKey)) {
|
|
62
|
+
const sides = forks.get(siteKey) ?? new Map();
|
|
63
|
+
for (const side of new Set(steps.map((step) => step.side))) {
|
|
64
|
+
const takingSide = sides.get(side) ?? [];
|
|
65
|
+
takingSide.push(call);
|
|
66
|
+
sides.set(side, takingSide);
|
|
67
|
+
}
|
|
68
|
+
forks.set(siteKey, sides);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const [siteKey, sides] of forks) {
|
|
72
|
+
if (loops.has(siteKey))
|
|
73
|
+
continue;
|
|
74
|
+
const onTrue = sides.get('true');
|
|
75
|
+
const onFalse = sides.get('false');
|
|
76
|
+
if (!onTrue || !onFalse)
|
|
77
|
+
continue;
|
|
78
|
+
const outputs = new Set([...onTrue, ...onFalse].map(outputOf));
|
|
79
|
+
if (outputs.size === 1 && !outputs.has(null))
|
|
80
|
+
findings.push({ exportKey, siteKey, result: itemAt(onTrue, 0).result });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return findings;
|
|
84
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MutationSettings } from '../instrument/instrument.schema.ts';
|
|
2
|
+
export declare const hashOf: (text: string) => string;
|
|
3
|
+
export declare const unitKeyOf: (path: string, name: string) => string;
|
|
4
|
+
export declare const unitFieldsOf: (key: string) => [string, string];
|
|
5
|
+
export type BasisInput = {
|
|
6
|
+
rules: string;
|
|
7
|
+
riders: {
|
|
8
|
+
key: string;
|
|
9
|
+
ticks: number;
|
|
10
|
+
answers: string[];
|
|
11
|
+
}[];
|
|
12
|
+
isReachedUntold: boolean;
|
|
13
|
+
reads: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const basisOf: ({ rules, riders, isReachedUntold, reads }: BasisInput) => string;
|
|
16
|
+
export type RulesKeyInput = {
|
|
17
|
+
version: string;
|
|
18
|
+
tool: string;
|
|
19
|
+
settings: object;
|
|
20
|
+
};
|
|
21
|
+
export declare const rulesKeyOf: ({ version, tool, settings }: RulesKeyInput) => string;
|
|
22
|
+
export type PlanCacheKeyInput = {
|
|
23
|
+
files: {
|
|
24
|
+
path: string;
|
|
25
|
+
hash: string;
|
|
26
|
+
}[];
|
|
27
|
+
settings: {
|
|
28
|
+
entries: string[];
|
|
29
|
+
jsx: boolean;
|
|
30
|
+
steps: boolean;
|
|
31
|
+
mutation: MutationSettings;
|
|
32
|
+
};
|
|
33
|
+
plugins: string;
|
|
34
|
+
tool: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const planCacheKeyOf: ({ files, settings, plugins, tool }: PlanCacheKeyInput) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const hashOf = (text) => createHash('sha256').update(text).digest('hex');
|
|
4
|
+
// A unit's key in a verdict's reads: its file's path and its function's name, empty for the file's top level.
|
|
5
|
+
export const unitKeyOf = (path, name) => JSON.stringify([path, name]);
|
|
6
|
+
const unitFieldsInput = z.tuple([z.string(), z.string()]);
|
|
7
|
+
export const unitFieldsOf = (key) => unitFieldsInput.parse(JSON.parse(key));
|
|
8
|
+
export const basisOf = ({ rules, riders, isReachedUntold, reads }) => hashOf(JSON.stringify([rules, riders.map(({ key, ticks, answers }) => [key, ticks, answers]), isReachedUntold, reads]));
|
|
9
|
+
export const rulesKeyOf = ({ version, tool, settings }) => hashOf(JSON.stringify([version, tool, settings]));
|
|
10
|
+
// The key a plan's instrumented code is kept under, the same only while nothing planning reads has changed.
|
|
11
|
+
export const planCacheKeyOf = ({ files, settings, plugins, tool }) => hashOf(JSON.stringify([files.map(({ path, hash }) => `${path}:${hash}`), settings, plugins, tool]));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { functionsOf, judgedSitesOf, mergedOf, verdictBasesOf } from '../../judge/judge.operations.js';
|
|
2
|
+
import { readJustifications } from '../../justify/edges/load.js';
|
|
3
|
+
import { justifiedOf } from '../../justify/justify.operations.js';
|
|
4
|
+
import { siteQuestionsOf } from '../../questions/questions.operations.js';
|
|
5
|
+
import { getJudged } from '../../record/edges/parts.db.js';
|
|
6
|
+
import { getPlan } from '../../record/edges/plan.db.js';
|
|
7
|
+
import { readCurrentRecord } from '../../record/edges/record.db.js';
|
|
8
|
+
import { entryAt } from '../../utils/lookup.js';
|
|
9
|
+
import { checksOf, stressesOf } from '../stresses.operations.js';
|
|
10
|
+
const rowsOf = (record) => {
|
|
11
|
+
const { files } = getPlan(record);
|
|
12
|
+
const runs = getJudged(record, { withHits: false });
|
|
13
|
+
const merged = mergedOf(runs.map(({ verdicts }) => verdicts));
|
|
14
|
+
const sites = judgedSitesOf(files, merged);
|
|
15
|
+
const { data: entries, error } = readJustifications(runs);
|
|
16
|
+
if (error)
|
|
17
|
+
return { data: null, error };
|
|
18
|
+
const justified = new Set();
|
|
19
|
+
if (entries.length) {
|
|
20
|
+
const { all, open } = siteQuestionsOf(sites, new Set(), new Set(), functionsOf(files, runs));
|
|
21
|
+
const sourceHashes = new Map(files.map(({ path, hash }) => [path, hash]));
|
|
22
|
+
const { accepted } = justifiedOf({ entries, questions: all, sourceHashes, bases: verdictBasesOf(runs) });
|
|
23
|
+
const acceptedIds = new Set(accepted.map(({ id }) => id));
|
|
24
|
+
for (const { id, sites: keys } of open) {
|
|
25
|
+
if (acceptedIds.has(id))
|
|
26
|
+
for (const key of keys)
|
|
27
|
+
justified.add(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const checks = checksOf(files);
|
|
31
|
+
const counted = sites.map(({ key, status }) => ({ key, status, check: entryAt(checks, key, 'a planned site'), catcher: merged.get(key)?.catcher ?? null }));
|
|
32
|
+
return { data: stressesOf({ sites: counted, justified }), error: null };
|
|
33
|
+
};
|
|
34
|
+
export const stressesIn = (path) => {
|
|
35
|
+
const { data, error } = readCurrentRecord(path, rowsOf);
|
|
36
|
+
return error ? { data: null, error } : data;
|
|
37
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type StressRow = {
|
|
2
|
+
check: string;
|
|
3
|
+
cases: number;
|
|
4
|
+
caught: number;
|
|
5
|
+
mutants: number;
|
|
6
|
+
};
|
|
7
|
+
export type StressSite = {
|
|
8
|
+
key: string;
|
|
9
|
+
check: string;
|
|
10
|
+
status: string;
|
|
11
|
+
catcher: string | null;
|
|
12
|
+
};
|
|
13
|
+
type StressesInput = {
|
|
14
|
+
sites: StressSite[];
|
|
15
|
+
justified: ReadonlySet<string>;
|
|
16
|
+
};
|
|
17
|
+
type ChecksInput = {
|
|
18
|
+
switches: {
|
|
19
|
+
key: string;
|
|
20
|
+
mutator: string;
|
|
21
|
+
}[];
|
|
22
|
+
crushes: {
|
|
23
|
+
key: string;
|
|
24
|
+
}[];
|
|
25
|
+
}[];
|
|
26
|
+
export declare const checksOf: (files: ChecksInput) => Map<string, string>;
|
|
27
|
+
export declare const stressesOf: ({ sites, justified }: StressesInput) => StressRow[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { outcomeMutatorName } from '../mutators/mutator.names.js';
|
|
2
|
+
const byName = (left, right) => (left < right ? -1 : Number(left > right));
|
|
3
|
+
// Rows most tests first, then by name.
|
|
4
|
+
const byCasesThenName = (left, right) => right.cases - left.cases || byName(left.check, right.check);
|
|
5
|
+
// Each planned site's row: a switch's under its mutator, an outcome's under `outcomes`, a crush's under `forkMutants`.
|
|
6
|
+
export const checksOf = (files) => {
|
|
7
|
+
const switched = files.flatMap(({ switches }) => switches.map(({ key, mutator }) => [key, mutator === outcomeMutatorName ? 'outcomes' : mutator]));
|
|
8
|
+
const crushed = files.flatMap(({ crushes }) => crushes.map(({ key }) => [key, 'forkMutants']));
|
|
9
|
+
return new Map([...switched, ...crushed]);
|
|
10
|
+
};
|
|
11
|
+
// Each check's row: the distinct tests that first caught its sites, never a backup, beside its caught sites out of all, most tests first, then by name.
|
|
12
|
+
// A justified site is accepted on purpose, so it counts in no row.
|
|
13
|
+
export const stressesOf = ({ sites, justified }) => {
|
|
14
|
+
const byCheck = Map.groupBy(sites.filter(({ key }) => !justified.has(key)), ({ check }) => check);
|
|
15
|
+
const rows = [...byCheck].map(([check, list]) => ({
|
|
16
|
+
check,
|
|
17
|
+
cases: new Set(list.flatMap(({ catcher }) => (catcher ? [catcher] : []))).size,
|
|
18
|
+
caught: list.filter(({ status }) => status === 'caught').length,
|
|
19
|
+
mutants: list.length,
|
|
20
|
+
}));
|
|
21
|
+
return rows.toSorted(byCasesThenName);
|
|
22
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Node, type Program } from 'oxc-parser';
|
|
2
|
+
import { type CrushError } from './errors.ts';
|
|
3
|
+
import type { Safe } from './safe.ts';
|
|
4
|
+
export { entryAt, itemAt, present } from './lookup.ts';
|
|
5
|
+
export type { Node };
|
|
6
|
+
export type Visit = {
|
|
7
|
+
node: Node;
|
|
8
|
+
parent: Node;
|
|
9
|
+
ancestors: readonly Node[];
|
|
10
|
+
key: string;
|
|
11
|
+
chain: Node | null;
|
|
12
|
+
inFunction: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Parsed = {
|
|
15
|
+
program: Program;
|
|
16
|
+
comments: {
|
|
17
|
+
value: string;
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
}[];
|
|
21
|
+
path: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const holdsRuntime: (node: Node) => boolean;
|
|
24
|
+
export declare const parse: (source: string, path: string) => Safe<Parsed, CrushError>;
|
|
25
|
+
export type NodeOf<T extends Node['type']> = Node extends infer N ? (N extends {
|
|
26
|
+
type: infer K;
|
|
27
|
+
} ? (T extends K ? N : never) : never) : never;
|
|
28
|
+
export declare const ofType: <T extends Node['type']>(node: Node, type: T) => NodeOf<T>;
|
|
29
|
+
export declare const visitorOf: (root: Node, onNode: (visit: Visit) => void) => {
|
|
30
|
+
enter: (node: Node, parent: Node, key: string) => void;
|
|
31
|
+
exit: () => void;
|
|
32
|
+
};
|
|
33
|
+
export declare const walk: (root: Node, onNode: (visit: Visit) => void) => void;
|
|
34
|
+
export declare const namesProperty: (parent: Node, key: string) => boolean;
|
|
35
|
+
type Span = {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
};
|
|
39
|
+
export declare const isInComment: (comments: readonly Span[], at: number) => boolean;
|
|
40
|
+
export type TokenInput = {
|
|
41
|
+
source: string;
|
|
42
|
+
comments: readonly Span[];
|
|
43
|
+
token: string;
|
|
44
|
+
from: number;
|
|
45
|
+
to: number;
|
|
46
|
+
};
|
|
47
|
+
export declare const tokenAt: ({ source, comments, token, from, to }: TokenInput) => number;
|
|
48
|
+
export declare const lineBreakPattern: RegExp;
|
|
49
|
+
export declare const lineStartsOf: (source: string) => number[];
|
|
50
|
+
export declare const lineStartOf: (source: string, offset: number) => number;
|
|
51
|
+
type Position = {
|
|
52
|
+
line: number;
|
|
53
|
+
column: number;
|
|
54
|
+
};
|
|
55
|
+
export declare const locate: (source: string) => ((offset: number) => Position);
|