@prestack/thread 0.1.3 → 0.1.5
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/CHANGELOG.md +563 -0
- package/dist/core/actor.d.ts +1 -1
- package/dist/core/actor.js +5 -4
- package/dist/core/actor.ts +5 -4
- package/dist/core/attach.d.ts +0 -7
- package/dist/core/attach.js +38 -67
- package/dist/core/attach.ts +34 -80
- package/dist/core/chain.js +13 -17
- package/dist/core/chain.ts +11 -15
- package/dist/core/condition.d.ts +4 -4
- package/dist/core/condition.js +2 -2
- package/dist/core/descend.d.ts +4 -2
- package/dist/core/descend.js +91 -23
- package/dist/core/descend.ts +90 -21
- package/dist/core/errors/catalogue.d.ts +52 -0
- package/dist/{operations/errors/errors.js → core/errors/catalogue.js} +1 -1
- package/dist/{operations/errors/errors.ts → core/errors/catalogue.ts} +1 -1
- package/dist/{operations/errors/catalog.d.ts → core/errors/error.d.ts} +2 -3
- package/dist/{operations/errors/catalog.js → core/errors/error.js} +1 -16
- package/dist/{operations/errors/catalog.ts → core/errors/error.ts} +3 -19
- package/dist/core/errors/namespaces.d.ts +3 -0
- package/dist/core/errors/namespaces.js +15 -0
- package/dist/core/errors/namespaces.ts +19 -0
- package/dist/core/finding.js +2 -2
- package/dist/core/finding.ts +1 -2
- package/dist/core/init.d.ts +1 -1
- package/dist/core/init.js +51 -5
- package/dist/core/init.ts +58 -5
- package/dist/core/invoked.d.ts +1 -1
- package/dist/core/invoked.js +3 -1
- package/dist/core/invoked.ts +5 -2
- package/dist/core/round.js +36 -22
- package/dist/core/round.ts +26 -9
- package/dist/core/rows.d.ts +4 -0
- package/dist/core/rows.js +31 -2
- package/dist/core/rows.ts +33 -1
- package/dist/core/scope.d.ts +1 -0
- package/dist/core/scope.js +1 -0
- package/dist/core/scope.ts +2 -0
- package/dist/core/thread.d.ts +3 -3
- package/dist/core/tree.d.ts +4 -1
- package/dist/core/tree.js +26 -6
- package/dist/core/tree.ts +29 -6
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +3 -1
- package/dist/core/types.ts +2 -1
- package/dist/derivation/attach.js +3 -2
- package/dist/derivation/attach.ts +2 -1
- package/dist/derivation/generators/build.js +6 -6
- package/dist/derivation/generators/build.ts +1 -1
- package/dist/derivation/generators/check.js +1 -1
- package/dist/derivation/generators/determinism.js +1 -1
- package/dist/derivation/generators/release.js +60 -47
- package/dist/derivation/generators/release.ts +66 -43
- package/dist/derivation/release.d.ts +7 -3
- package/dist/derivation/release.js +14 -1
- package/dist/derivation/release.ts +22 -2
- package/dist/integrations/attach.d.ts +4 -0
- package/dist/integrations/attach.js +37 -56
- package/dist/integrations/attach.ts +54 -60
- package/dist/integrations/cli.d.ts +37 -0
- package/dist/integrations/cli.js +440 -0
- package/dist/integrations/cli.ts +543 -0
- package/dist/{core/files.d.ts → integrations/disk.d.ts} +16 -24
- package/dist/integrations/disk.js +435 -0
- package/dist/integrations/disk.ts +465 -0
- package/dist/integrations/generators/read.js +6 -6
- package/dist/integrations/generators/read.ts +4 -4
- package/dist/integrations/generators/vault.js +10 -11
- package/dist/integrations/generators/vault.ts +4 -5
- package/dist/{operations/http.d.ts → integrations/https.d.ts} +10 -6
- package/dist/integrations/https.js +170 -0
- package/dist/integrations/https.ts +216 -0
- package/dist/integrations/pglite.d.ts +26 -0
- package/dist/integrations/pglite.js +143 -0
- package/dist/integrations/pglite.ts +206 -0
- package/dist/integrations/secret.d.ts +8 -2
- package/dist/integrations/secret.js +3 -5
- package/dist/integrations/secret.ts +10 -6
- package/dist/integrations/target.d.ts +155 -14
- package/dist/integrations/target.js +171 -50
- package/dist/integrations/target.ts +377 -61
- package/dist/integrations/vault.d.ts +1 -0
- package/dist/integrations/vault.js +20 -5
- package/dist/integrations/vault.ts +17 -5
- package/dist/integrity/attach.js +8 -77
- package/dist/integrity/attach.ts +7 -76
- package/dist/integrity/check-threads.js +5 -5
- package/dist/integrity/check-threads.ts +2 -2
- package/dist/integrity/constraint.d.ts +0 -1
- package/dist/integrity/constraint.js +267 -366
- package/dist/integrity/constraint.ts +267 -375
- package/dist/integrity/generators/compiler.js +14 -17
- package/dist/integrity/generators/compiler.ts +10 -15
- package/dist/integrity/generators/gate.js +15 -15
- package/dist/integrity/generators/gate.ts +10 -10
- package/dist/integrity/generators/issues.js +7 -7
- package/dist/integrity/generators/publish.js +39 -57
- package/dist/integrity/generators/publish.ts +44 -55
- package/dist/integrity/generators/trial.d.ts +3 -3
- package/dist/integrity/generators/trial.js +133 -165
- package/dist/integrity/generators/trial.ts +145 -169
- package/dist/integrity/lint.js +9 -13
- package/dist/integrity/lint.ts +7 -10
- package/dist/integrity/lsp/bin.js +5 -4
- package/dist/integrity/lsp/bin.ts +3 -1
- package/dist/integrity/lsp/diagnostics.js +3 -3
- package/dist/integrity/lsp/diagnostics.ts +1 -1
- package/dist/integrity/lsp/lint.js +19 -30
- package/dist/integrity/lsp/lint.ts +16 -32
- package/dist/integrity/lsp/server.js +3 -3
- package/dist/integrity/slopnator.d.ts +3 -13
- package/dist/integrity/slopnator.js +59 -38
- package/dist/integrity/slopnator.ts +54 -38
- package/dist/integrity/slopnators/sl_broken_lineage.js +2 -2
- package/dist/integrity/slopnators/sl_declared_elsewhere.js +1 -1
- package/dist/integrity/slopnators/sl_derived_drift.js +4 -4
- package/dist/integrity/slopnators/sl_derived_drift.ts +1 -1
- package/dist/integrity/slopnators/sl_door_in_a_node.js +220 -0
- package/dist/integrity/slopnators/sl_door_in_a_node.ts +250 -0
- package/dist/integrity/slopnators/sl_inert_island.js +10 -8
- package/dist/integrity/slopnators/sl_inert_island.ts +8 -6
- package/dist/integrity/slopnators/sl_missing_row.js +6 -51
- package/dist/integrity/slopnators/sl_missing_row.ts +4 -50
- package/dist/integrity/slopnators/sl_no_barrel.js +1 -1
- package/dist/integrity/slopnators/sl_no_child_process.js +36 -18
- package/dist/integrity/slopnators/sl_no_child_process.ts +44 -18
- package/dist/integrity/slopnators/sl_no_dispatch_bypass.js +80 -149
- package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +95 -147
- package/dist/integrity/slopnators/sl_no_import_cycle.js +15 -4
- package/dist/integrity/slopnators/sl_no_import_cycle.ts +20 -4
- package/dist/integrity/slopnators/sl_no_such_command.js +2 -2
- package/dist/integrity/slopnators/sl_no_such_command.ts +1 -1
- package/dist/integrity/slopnators/sl_outside_an_operation.js +20 -0
- package/dist/integrity/slopnators/sl_outside_an_operation.ts +25 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.d.ts +2 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.js +61 -0
- package/dist/integrity/slopnators/sl_screen_holds_only_declared.ts +70 -0
- package/dist/integrity/slopnators/sl_secret_literal.js +1 -33
- package/dist/integrity/slopnators/sl_secret_literal.ts +1 -33
- package/dist/integrity/slopnators/sl_stale_path.js +5 -22
- package/dist/integrity/slopnators/sl_stale_path.ts +4 -20
- package/dist/integrity/slopnators/sl_twice_meant.js +1 -1
- package/dist/integrity/slopnators/sl_twice_parented.js +29 -5
- package/dist/integrity/slopnators/sl_twice_parented.ts +28 -4
- package/dist/integrity/slopnators/sl_undeclared_crossing.d.ts +4 -1
- package/dist/integrity/slopnators/sl_undeclared_crossing.js +426 -62
- package/dist/integrity/slopnators/sl_undeclared_crossing.ts +454 -70
- package/dist/integrity/slopnators/sl_undeclared_destination.js +59 -25
- package/dist/integrity/slopnators/sl_undeclared_destination.ts +69 -21
- package/dist/integrity/slopnators/sl_undeclared_list.d.ts +2 -0
- package/dist/integrity/slopnators/sl_undeclared_list.js +363 -0
- package/dist/integrity/slopnators/sl_undeclared_list.ts +358 -0
- package/dist/integrity/slopnators/sl_undeclared_node.js +1 -11
- package/dist/integrity/slopnators/sl_undeclared_node.ts +0 -10
- package/dist/integrity/slopnators/sl_undeclared_operation.js +111 -29
- package/dist/integrity/slopnators/sl_undeclared_operation.ts +134 -26
- package/dist/integrity/slopnators/sl_undeclared_variant.js +2 -2
- package/dist/integrity/slopnators/sl_undeclared_webhook.d.ts +2 -0
- package/dist/integrity/slopnators/sl_undeclared_webhook.js +90 -0
- package/dist/integrity/slopnators/sl_undeclared_webhook.ts +108 -0
- package/dist/integrity/slopnators/sl_underived_route.d.ts +2 -0
- package/dist/integrity/slopnators/sl_underived_route.js +61 -0
- package/dist/integrity/slopnators/sl_underived_route.ts +72 -0
- package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -3
- package/dist/integrity/slopnators/sl_ungoverned_island.ts +1 -1
- package/dist/integrity/slopnators/sl_unlisted_program.d.ts +2 -0
- package/dist/integrity/slopnators/sl_unlisted_program.js +39 -0
- package/dist/integrity/slopnators/sl_unlisted_program.ts +40 -0
- package/dist/integrity/slopnators/sl_unnamed_island.js +1 -1
- package/dist/integrity/slopnators/sl_unpaired_member.js +3 -3
- package/dist/integrity/slopnators/sl_unpaired_member.ts +1 -1
- package/dist/integrity/slopnators/sl_unpaired_slopnator.js +4 -4
- package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +1 -1
- package/dist/integrity/slopnators/sl_unprefixed_member.js +5 -31
- package/dist/integrity/slopnators/sl_unprefixed_member.ts +2 -28
- package/dist/integrity/slopnators/sl_unthreaded.js +11 -7
- package/dist/integrity/slopnators/sl_unthreaded.ts +6 -7
- package/dist/integrity/slopnators/sl_untranslated_key.js +2 -25
- package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -25
- package/dist/integrity/slopnators/sl_unvaulted_secret.d.ts +2 -0
- package/dist/integrity/slopnators/sl_unvaulted_secret.js +107 -0
- package/dist/integrity/slopnators/sl_unvaulted_secret.ts +132 -0
- package/dist/integrity/slopnators/sl_unversioned.js +6 -4
- package/dist/integrity/slopnators/sl_unversioned.ts +5 -3
- package/dist/integrity/sweep.d.ts +1 -0
- package/dist/integrity/sweep.js +105 -42
- package/dist/integrity/sweep.ts +115 -42
- package/dist/knowledge/attach.js +4 -3
- package/dist/knowledge/attach.ts +3 -2
- package/dist/knowledge/generators/docsgen.js +8 -6
- package/dist/knowledge/generators/docsgen.ts +4 -2
- package/dist/knowledge/generators/glossary.js +4 -4
- package/dist/knowledge/generators/glossary.ts +1 -1
- package/dist/operations/access.d.ts +23 -0
- package/dist/operations/access.js +28 -1
- package/dist/operations/access.ts +43 -0
- package/dist/operations/attach.js +33 -113
- package/dist/operations/attach.ts +51 -117
- package/dist/operations/capabilities.d.ts +14 -5
- package/dist/operations/capabilities.js +13 -4
- package/dist/operations/capabilities.ts +27 -8
- package/dist/operations/dispatch.d.ts +8 -2
- package/dist/operations/dispatch.js +128 -185
- package/dist/operations/dispatch.ts +138 -191
- package/dist/operations/error-results.d.ts +1 -1
- package/dist/operations/error-results.js +2 -2
- package/dist/operations/error-results.ts +2 -2
- package/dist/operations/generators/capability.d.ts +11 -1
- package/dist/operations/generators/capability.js +481 -224
- package/dist/operations/generators/capability.ts +562 -233
- package/dist/operations/generators/compile.js +66 -39
- package/dist/operations/generators/compile.ts +78 -39
- package/dist/operations/generators/permits.js +11 -12
- package/dist/operations/generators/permits.ts +3 -4
- package/dist/operations/generators/seed.d.ts +1 -0
- package/dist/operations/generators/seed.js +19 -17
- package/dist/operations/generators/seed.ts +22 -14
- package/dist/operations/generators/trial.d.ts +6 -8
- package/dist/operations/generators/trial.js +200 -70
- package/dist/operations/generators/trial.ts +230 -93
- package/dist/operations/nodes.d.ts +15 -16
- package/dist/operations/nodes.ts +16 -17
- package/dist/operations/operations.d.ts +40 -4
- package/dist/operations/operations.js +1 -0
- package/dist/operations/operations.ts +61 -4
- package/dist/operations/result.d.ts +2 -2
- package/dist/operations/result.ts +2 -2
- package/package.json +1 -4
- package/dist/core/answers.d.ts +0 -171
- package/dist/core/answers.js +0 -789
- package/dist/core/answers.ts +0 -999
- package/dist/core/client.d.ts +0 -63
- package/dist/core/client.js +0 -249
- package/dist/core/client.ts +0 -289
- package/dist/core/files.js +0 -171
- package/dist/core/files.ts +0 -222
- package/dist/integrations/module.d.ts +0 -6
- package/dist/integrations/module.js +0 -153
- package/dist/integrations/module.ts +0 -191
- package/dist/integrity/slopnators/sl_unkept_rows.js +0 -104
- package/dist/integrity/slopnators/sl_unkept_rows.ts +0 -111
- package/dist/integrity/slopnators/sl_unseamed_reach.js +0 -73
- package/dist/integrity/slopnators/sl_unseamed_reach.ts +0 -79
- package/dist/operations/cost.d.ts +0 -14
- package/dist/operations/cost.js +0 -37
- package/dist/operations/cost.ts +0 -58
- package/dist/operations/errors/errors.d.ts +0 -52
- package/dist/operations/http.js +0 -124
- package/dist/operations/http.ts +0 -169
- package/dist/operations/memory.d.ts +0 -104
- package/dist/operations/memory.js +0 -365
- package/dist/operations/memory.ts +0 -470
- package/dist/operations/metering.d.ts +0 -55
- package/dist/operations/metering.js +0 -247
- package/dist/operations/metering.ts +0 -328
- package/dist/operations/queue-policy.d.ts +0 -3
- package/dist/operations/queue-policy.js +0 -8
- package/dist/operations/queue-policy.ts +0 -10
- package/dist/operations/seams.d.ts +0 -239
- package/dist/operations/seams.js +0 -45
- package/dist/operations/seams.ts +0 -364
- package/dist/operations/store.d.ts +0 -14
- package/dist/operations/store.js +0 -1
- package/dist/operations/store.ts +0 -29
- /package/dist/{operations → core}/errors/classes.d.ts +0 -0
- /package/dist/{operations → core}/errors/classes.js +0 -0
- /package/dist/{operations → core}/errors/classes.ts +0 -0
- /package/dist/integrity/slopnators/{sl_unkept_rows.d.ts → sl_door_in_a_node.d.ts} +0 -0
- /package/dist/integrity/slopnators/{sl_unseamed_reach.d.ts → sl_outside_an_operation.d.ts} +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import type { Constraint, Sourced } from '../constraint.ts';
|
|
3
|
-
import { type
|
|
4
|
-
export declare const TRIALS_PATH: string;
|
|
3
|
+
import { type Slopnator } from '../slopnator.ts';
|
|
5
4
|
export interface Scenario {
|
|
6
5
|
readonly files: readonly Sourced[];
|
|
7
6
|
readonly at: string;
|
|
@@ -31,9 +30,10 @@ export interface Run {
|
|
|
31
30
|
readonly passed: number;
|
|
32
31
|
readonly failed: number;
|
|
33
32
|
readonly measured: number;
|
|
33
|
+
readonly spent: ReadonlyMap<string, number>;
|
|
34
34
|
}
|
|
35
35
|
export declare function probeAt(rule: Constraint): string;
|
|
36
36
|
export declare function deriveTrials(all: readonly Constraint[], slopnators: ReadonlyMap<string, Slopnator>): Derivation;
|
|
37
|
-
export declare function trialsByproduct(derivation: Derivation): Byproduct;
|
|
38
37
|
export declare function runTrial(trial: Trial, rule: Constraint, module: Rule.RuleModule, parser: unknown, slopnator?: Slopnator): Outcome;
|
|
38
|
+
export declare function crossed(trials: readonly Trial[], all: readonly Constraint[], rules: Readonly<Record<string, Rule.RuleModule>>, parser: unknown, slopnators?: ReadonlyMap<string, Slopnator>, spent?: Map<string, number>): readonly Outcome[];
|
|
39
39
|
export declare function runTrials(trials: readonly Trial[], all: readonly Constraint[], rules: Readonly<Record<string, Rule.RuleModule>>, parser: unknown, slopnators?: ReadonlyMap<string, Slopnator>): Run;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { basename, dirname, join, resolve } from 'node:path';
|
|
4
|
-
import { exit, invoked } from "../../core/invoked.js";
|
|
1
|
+
import { answeredBy, standing } from '../../integrations/disk.js';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
5
3
|
import { Linter } from 'eslint';
|
|
6
4
|
const TREE = findTree();
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { findTree } from "../../core/tree.js";
|
|
11
|
-
export const TRIALS_PATH = `${findTree().name}/_generated/trials.ts`;
|
|
5
|
+
import { NOT_WRITTEN, ROOT, governs, proofsOf, reads, slopnatorName, sweeps, visits } from '../slopnator.js';
|
|
6
|
+
import { forget } from '../slopnators/sl_unthreaded.js';
|
|
7
|
+
import { findTree } from '../../core/tree.js';
|
|
12
8
|
const PROBE = 'probe.tsx';
|
|
13
9
|
const WRAPPINGS = [
|
|
14
10
|
(source) => source,
|
|
@@ -61,13 +57,6 @@ export function deriveTrials(all, slopnators) {
|
|
|
61
57
|
}
|
|
62
58
|
return { trials: trials.sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)) };
|
|
63
59
|
}
|
|
64
|
-
export function trialsByproduct(derivation) {
|
|
65
|
-
return {
|
|
66
|
-
path: TRIALS_PATH,
|
|
67
|
-
content: `export const RULE_TRIALS = ${JSON.stringify(derivation.trials, null, 2)} as const
|
|
68
|
-
`,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
60
|
function config(rule, module, parser) {
|
|
72
61
|
return [
|
|
73
62
|
{
|
|
@@ -81,95 +70,6 @@ function config(rule, module, parser) {
|
|
|
81
70
|
},
|
|
82
71
|
];
|
|
83
72
|
}
|
|
84
|
-
const flat = (at) => (at.length > 1 && at.endsWith('/') ? at.replace(/\/+$/, '') : at);
|
|
85
|
-
const under = (at) => at.startsWith(ROOT) || `${at}/` === ROOT;
|
|
86
|
-
const own = (at) => under(at) && !at.slice(ROOT.length).split('/').includes('node_modules');
|
|
87
|
-
function beside(at) {
|
|
88
|
-
try {
|
|
89
|
-
return disk.readdirSync(at, { withFileTypes: true });
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function outside(at) {
|
|
96
|
-
const one = disk.statSync(at, { throwIfNoEntry: false });
|
|
97
|
-
if (one === undefined)
|
|
98
|
-
return 'none';
|
|
99
|
-
return one.isFile() ? 'file' : one.isDirectory() ? 'folder' : 'other';
|
|
100
|
-
}
|
|
101
|
-
const GONE = 'is not in the scenario this trial stands, and while it runs the scenario is the whole tree.';
|
|
102
|
-
function answering(files) {
|
|
103
|
-
const held = new Map(files.map((one) => [resolve(ROOT, one.at), one.source]));
|
|
104
|
-
const folders = new Set();
|
|
105
|
-
const parents = (at) => {
|
|
106
|
-
for (let up = dirname(at); under(`${up}/`); up = dirname(up))
|
|
107
|
-
folders.add(up);
|
|
108
|
-
};
|
|
109
|
-
for (const at of held.keys())
|
|
110
|
-
parents(at);
|
|
111
|
-
const answers = {
|
|
112
|
-
kind: (at) => (held.has(at) ? 'file' : folders.has(at) ? 'folder' : own(at) ? 'none' : outside(at)),
|
|
113
|
-
read: (at) => {
|
|
114
|
-
const said = held.get(at);
|
|
115
|
-
if (said !== undefined)
|
|
116
|
-
return said;
|
|
117
|
-
if (own(at))
|
|
118
|
-
throw new Error(`${at} ${GONE}`);
|
|
119
|
-
return disk.readFileSync(at, 'utf8');
|
|
120
|
-
},
|
|
121
|
-
write: (at, said) => {
|
|
122
|
-
held.set(at, said);
|
|
123
|
-
parents(at);
|
|
124
|
-
},
|
|
125
|
-
list: (at) => {
|
|
126
|
-
const inside = new Map();
|
|
127
|
-
const found = own(at) ? [] : folders.has(at) ? beside(at) : disk.readdirSync(at, { withFileTypes: true });
|
|
128
|
-
for (const one of found)
|
|
129
|
-
inside.set(one.name, { name: one.name, kind: one.isDirectory() ? 'folder' : 'file' });
|
|
130
|
-
for (const path of folders)
|
|
131
|
-
if (dirname(path) === at)
|
|
132
|
-
inside.set(basename(path), { name: basename(path), kind: 'folder' });
|
|
133
|
-
for (const path of held.keys())
|
|
134
|
-
if (dirname(path) === at)
|
|
135
|
-
inside.set(basename(path), { name: basename(path), kind: 'file' });
|
|
136
|
-
return [...inside.values()];
|
|
137
|
-
},
|
|
138
|
-
stat: (at) => {
|
|
139
|
-
const said = held.get(at);
|
|
140
|
-
if (said !== undefined)
|
|
141
|
-
return { size: said.length, modified: 0 };
|
|
142
|
-
if (folders.has(at))
|
|
143
|
-
return { size: 0, modified: 0 };
|
|
144
|
-
if (own(at))
|
|
145
|
-
throw new Error(`${at} ${GONE}`);
|
|
146
|
-
const one = disk.statSync(at);
|
|
147
|
-
return { size: one.size, modified: one.mtimeMs };
|
|
148
|
-
},
|
|
149
|
-
remove: (at) => {
|
|
150
|
-
held.delete(at);
|
|
151
|
-
folders.delete(at);
|
|
152
|
-
},
|
|
153
|
-
real: (at) => (own(at) || held.has(at) || folders.has(at) ? at : disk.realpathSync(at)),
|
|
154
|
-
fetch: () => {
|
|
155
|
-
throw new Error('a trial answers orders against a tree it made up, so there is nowhere here to install anything into.');
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
return {
|
|
159
|
-
kind: (at) => answers.kind(flat(at)),
|
|
160
|
-
read: (at) => answers.read(flat(at)),
|
|
161
|
-
write: (at, said) => {
|
|
162
|
-
answers.write(flat(at), said);
|
|
163
|
-
},
|
|
164
|
-
list: (at) => answers.list(flat(at)),
|
|
165
|
-
stat: (at) => answers.stat(flat(at)),
|
|
166
|
-
remove: (at) => {
|
|
167
|
-
answers.remove(flat(at));
|
|
168
|
-
},
|
|
169
|
-
real: (at) => answers.real(flat(at)),
|
|
170
|
-
fetch: (at) => answers.fetch(flat(at)),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
73
|
export function runTrial(trial, rule, module, parser, slopnator) {
|
|
174
74
|
const linter = new Linter();
|
|
175
75
|
const failures = [];
|
|
@@ -185,7 +85,7 @@ export function runTrial(trial, rule, module, parser, slopnator) {
|
|
|
185
85
|
const target = trial.scenario.files.find((file) => file.at === trial.scenario.at);
|
|
186
86
|
let parsed = false;
|
|
187
87
|
let satisfied = false;
|
|
188
|
-
answeredBy(
|
|
88
|
+
answeredBy(standing(ROOT, new Map(trial.scenario.files.map((one) => [resolve(ROOT, one.at), one.source]))));
|
|
189
89
|
forget();
|
|
190
90
|
try {
|
|
191
91
|
if (slopnator !== undefined && !reads(slopnator)) {
|
|
@@ -234,8 +134,129 @@ export function runTrial(trial, rule, module, parser, slopnator) {
|
|
|
234
134
|
}
|
|
235
135
|
return { id: trial.id, rule: rule.id, passed: failures.length === 0, parsed, failures };
|
|
236
136
|
}
|
|
137
|
+
const judged = (who, rules, parser) => [
|
|
138
|
+
{
|
|
139
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
140
|
+
languageOptions: {
|
|
141
|
+
parser,
|
|
142
|
+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module', ecmaFeatures: { jsx: true } },
|
|
143
|
+
},
|
|
144
|
+
plugins: { rule: { rules: Object.fromEntries(who.map((one) => [one.id, rules[one.id]])) } },
|
|
145
|
+
rules: Object.fromEntries(who.map((one) => ['rule/' + one.id, 'error'])),
|
|
146
|
+
},
|
|
147
|
+
];
|
|
148
|
+
const failed = (thrown) => 'could not run on it: ' + (thrown instanceof Error ? thrown.message : String(thrown));
|
|
149
|
+
const parseable = (source, at, parser) => WRAPPINGS.find((wrap) => !new Linter().verify(wrap(source), judged([], {}, parser), at).some((one) => one.fatal === true)) ??
|
|
150
|
+
((said) => said);
|
|
151
|
+
function refusals(scenario, source, judges, rules, parser, slopnators) {
|
|
152
|
+
const found = new Map();
|
|
153
|
+
const note = (who, said) => {
|
|
154
|
+
const held = found.get(who) ?? new Set();
|
|
155
|
+
held.add(said);
|
|
156
|
+
found.set(who, held);
|
|
157
|
+
};
|
|
158
|
+
const walking = judges.filter((one) => {
|
|
159
|
+
const held = slopnators.get(slopnatorName(one.id));
|
|
160
|
+
return held !== undefined && visits(held) && rules[one.id] !== undefined;
|
|
161
|
+
});
|
|
162
|
+
const linted = (who) => {
|
|
163
|
+
const messages = new Linter().verify(source, judged(who, rules, parser), scenario.at);
|
|
164
|
+
if (messages.some((one) => one.fatal === true))
|
|
165
|
+
return;
|
|
166
|
+
for (const one of messages) {
|
|
167
|
+
const by = String(one.ruleId ?? '').replace('rule/', '');
|
|
168
|
+
if (by !== '')
|
|
169
|
+
note(by, one.message);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const files = scenario.files.map((one) => (one.at === scenario.at ? { at: one.at, source } : one));
|
|
173
|
+
answeredBy(standing(ROOT, new Map(files.map((one) => [resolve(ROOT, one.at), one.source]))));
|
|
174
|
+
forget();
|
|
175
|
+
try {
|
|
176
|
+
try {
|
|
177
|
+
linted(walking);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
for (const one of walking) {
|
|
181
|
+
try {
|
|
182
|
+
linted([one]);
|
|
183
|
+
}
|
|
184
|
+
catch (thrown) {
|
|
185
|
+
note(one.id, failed(thrown));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const one of judges) {
|
|
190
|
+
const held = slopnators.get(slopnatorName(one.id));
|
|
191
|
+
if (held === undefined)
|
|
192
|
+
continue;
|
|
193
|
+
if (visits(held))
|
|
194
|
+
continue;
|
|
195
|
+
try {
|
|
196
|
+
if (sweeps(held)) {
|
|
197
|
+
const said = held.holds(undefined, { filename: scenario.at, text: source, ancestors: () => [], comments: () => [] });
|
|
198
|
+
if (said !== false && said !== NOT_WRITTEN)
|
|
199
|
+
note(one.id, typeof said === 'string' ? said : slopnatorName(one.id));
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (!reads(held))
|
|
203
|
+
for (const said of held.checks(ROOT))
|
|
204
|
+
note(one.id, said);
|
|
205
|
+
}
|
|
206
|
+
catch (thrown) {
|
|
207
|
+
note(one.id, failed(thrown));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
answeredBy(undefined);
|
|
213
|
+
forget();
|
|
214
|
+
}
|
|
215
|
+
return found;
|
|
216
|
+
}
|
|
217
|
+
export function crossed(trials, all, rules, parser, slopnators = new Map(), spent = new Map()) {
|
|
218
|
+
const found = [];
|
|
219
|
+
const blanks = new Map();
|
|
220
|
+
for (const trial of trials) {
|
|
221
|
+
if (trial.verdict.reports)
|
|
222
|
+
continue;
|
|
223
|
+
const target = trial.scenario.files.find((one) => one.at === trial.scenario.at);
|
|
224
|
+
if (target === undefined)
|
|
225
|
+
continue;
|
|
226
|
+
const judges = all.filter((one) => governs(one, trial.scenario.at));
|
|
227
|
+
if (!judges.some((one) => one.id !== trial.rule))
|
|
228
|
+
continue;
|
|
229
|
+
const began = Date.now();
|
|
230
|
+
const wrap = parseable(target.source, trial.scenario.at, parser);
|
|
231
|
+
const emptied = JSON.stringify([wrap(''), trial.scenario.files.map((one) => (one.at === trial.scenario.at ? { at: one.at, source: '' } : one))]);
|
|
232
|
+
const blank = blanks.get(emptied) ?? refusals(trial.scenario, wrap(''), judges, rules, parser, slopnators);
|
|
233
|
+
blanks.set(emptied, blank);
|
|
234
|
+
const said = refusals(trial.scenario, wrap(target.source), judges, rules, parser, slopnators);
|
|
235
|
+
spent.set(trial.rule, (spent.get(trial.rule) ?? 0) + Date.now() - began);
|
|
236
|
+
for (const [who, messages] of said) {
|
|
237
|
+
if (who === trial.rule)
|
|
238
|
+
continue;
|
|
239
|
+
for (const message of messages) {
|
|
240
|
+
if (blank.get(who)?.has(message) === true)
|
|
241
|
+
continue;
|
|
242
|
+
found.push({
|
|
243
|
+
id: trial.id + '_under_' + who.replace(/-/g, '_'),
|
|
244
|
+
rule: trial.rule,
|
|
245
|
+
passed: false,
|
|
246
|
+
parsed: true,
|
|
247
|
+
failures: [
|
|
248
|
+
'the form it recommends is refused by ' + who + ', so this law tells somebody to write what another law bans. ' +
|
|
249
|
+
who + ' said: ' + (message.split('Found: ').pop() ?? message),
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return found;
|
|
256
|
+
}
|
|
237
257
|
export function runTrials(trials, all, rules, parser, slopnators) {
|
|
238
258
|
const byName = new Map(all.map((rule) => [rule.id, rule]));
|
|
259
|
+
const spent = new Map();
|
|
239
260
|
const outcomes = trials.map((trial) => {
|
|
240
261
|
const rule = byName.get(trial.rule);
|
|
241
262
|
const module = rules[trial.rule];
|
|
@@ -245,72 +266,19 @@ export function runTrials(trials, all, rules, parser, slopnators) {
|
|
|
245
266
|
rule: trial.rule,
|
|
246
267
|
passed: false,
|
|
247
268
|
parsed: false,
|
|
248
|
-
failures: [`
|
|
269
|
+
failures: [`the rule "${trial.rule}" has no slopnator on disk, so this trial is about nothing — the file to write is the one its row names in \`at\``],
|
|
249
270
|
};
|
|
250
271
|
}
|
|
251
|
-
|
|
272
|
+
const began = Date.now();
|
|
273
|
+
const outcome = runTrial(trial, rule, module, parser, slopnators?.get(slopnatorName(rule.id)));
|
|
274
|
+
spent.set(trial.rule, (spent.get(trial.rule) ?? 0) + Date.now() - began);
|
|
275
|
+
return outcome;
|
|
252
276
|
});
|
|
253
277
|
return {
|
|
254
278
|
outcomes,
|
|
255
279
|
passed: outcomes.filter((outcome) => outcome.passed).length,
|
|
256
280
|
failed: outcomes.filter((outcome) => !outcome.passed).length,
|
|
257
281
|
measured: outcomes.filter((outcome) => outcome.parsed).length,
|
|
282
|
+
spent,
|
|
258
283
|
};
|
|
259
284
|
}
|
|
260
|
-
if (invoked(import.meta.url)) {
|
|
261
|
-
const own = await rules();
|
|
262
|
-
const governing = own ?? CONSTRAINTS;
|
|
263
|
-
const source = own === undefined
|
|
264
|
-
? `the ${String(CONSTRAINTS.length)} constraint(s) this tree authors`
|
|
265
|
-
: `the ${String(own.length)} rule(s) this tree declares — a shipped constraint is proved in the package that ships it, against the paths that package governs`;
|
|
266
|
-
const slopnators = await load(ROOT, governing);
|
|
267
|
-
const derivation = deriveTrials(governing, slopnators);
|
|
268
|
-
const byproduct = trialsByproduct(derivation);
|
|
269
|
-
if (process.argv.includes('--check')) {
|
|
270
|
-
const path = join(ROOT, byproduct.path);
|
|
271
|
-
const current = existsSync(path) ? readFileSync(path, 'utf8') : '';
|
|
272
|
-
const drifted = current !== byproduct.content;
|
|
273
|
-
if (drifted)
|
|
274
|
-
console.error(`trial: ${byproduct.path} is not what the rules derive. Run \`thread trials\` and commit the result.`);
|
|
275
|
-
console.log(`trial: ${String(derivation.trials.length)} derived from ${source}, ${String(drifted ? 1 : 0)} findings.`);
|
|
276
|
-
exit(drifted ? 1 : 0);
|
|
277
|
-
}
|
|
278
|
-
if (process.argv.includes('--try')) {
|
|
279
|
-
const at = process.argv.indexOf('--rule');
|
|
280
|
-
const only = at === -1 ? undefined : (process.argv[at + 1] ?? '').split(',').map((one) => one.trim()).filter(Boolean);
|
|
281
|
-
const unknown = (only ?? []).filter((id) => !governing.some((rule) => rule.id === id));
|
|
282
|
-
if (unknown.length > 0) {
|
|
283
|
-
console.error(`trial: no rule is called ${unknown.join(', ')} — a filter naming nothing would measure nothing and exit 0`);
|
|
284
|
-
exit(1);
|
|
285
|
-
}
|
|
286
|
-
const chosen = only === undefined ? derivation.trials : derivation.trials.filter((trial) => only.includes(trial.rule));
|
|
287
|
-
if (chosen.length === 0) {
|
|
288
|
-
if (only !== undefined) {
|
|
289
|
-
console.error('trial: the filter selected no trials, and measuring nothing must not exit 0');
|
|
290
|
-
exit(1);
|
|
291
|
-
}
|
|
292
|
-
if (governing.length > 0) {
|
|
293
|
-
console.error(`trial: ${String(governing.length)} rule(s) govern and none derived a trial — every rule owes a \`wrong\` and a \`right\`, so measuring nothing must not exit 0`);
|
|
294
|
-
exit(1);
|
|
295
|
-
}
|
|
296
|
-
console.log(`trial: nothing to prove — ${source}.`);
|
|
297
|
-
exit(0);
|
|
298
|
-
}
|
|
299
|
-
const { default: plugin } = await import("../lint.js");
|
|
300
|
-
const parser = (await import('typescript-eslint')).parser;
|
|
301
|
-
const run = runTrials(chosen, governing, plugin.rules, parser, slopnators);
|
|
302
|
-
for (const outcome of run.outcomes) {
|
|
303
|
-
if (outcome.passed)
|
|
304
|
-
continue;
|
|
305
|
-
for (const failure of outcome.failures)
|
|
306
|
-
console.error(`trial: ${outcome.id} — ${failure}`);
|
|
307
|
-
}
|
|
308
|
-
console.log(`trial: ${String(run.passed)} of ${String(run.outcomes.length)} passed, ${String(run.measured)} measured.`);
|
|
309
|
-
if (only !== undefined) {
|
|
310
|
-
console.log(`trial: PARTIAL RUN — ${String(derivation.trials.length - chosen.length)} of ${String(derivation.trials.length)} derived trials did not run. \`thread trials\` with no arguments runs every one.`);
|
|
311
|
-
}
|
|
312
|
-
exit(run.failed === 0 ? 0 : 1);
|
|
313
|
-
}
|
|
314
|
-
write(ROOT, byproduct);
|
|
315
|
-
console.log(`trial: wrote ${byproduct.path} — ${String(derivation.trials.length)} trials from ${source}.`);
|
|
316
|
-
}
|