@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.
Files changed (270) hide show
  1. package/CHANGELOG.md +563 -0
  2. package/dist/core/actor.d.ts +1 -1
  3. package/dist/core/actor.js +5 -4
  4. package/dist/core/actor.ts +5 -4
  5. package/dist/core/attach.d.ts +0 -7
  6. package/dist/core/attach.js +38 -67
  7. package/dist/core/attach.ts +34 -80
  8. package/dist/core/chain.js +13 -17
  9. package/dist/core/chain.ts +11 -15
  10. package/dist/core/condition.d.ts +4 -4
  11. package/dist/core/condition.js +2 -2
  12. package/dist/core/descend.d.ts +4 -2
  13. package/dist/core/descend.js +91 -23
  14. package/dist/core/descend.ts +90 -21
  15. package/dist/core/errors/catalogue.d.ts +52 -0
  16. package/dist/{operations/errors/errors.js → core/errors/catalogue.js} +1 -1
  17. package/dist/{operations/errors/errors.ts → core/errors/catalogue.ts} +1 -1
  18. package/dist/{operations/errors/catalog.d.ts → core/errors/error.d.ts} +2 -3
  19. package/dist/{operations/errors/catalog.js → core/errors/error.js} +1 -16
  20. package/dist/{operations/errors/catalog.ts → core/errors/error.ts} +3 -19
  21. package/dist/core/errors/namespaces.d.ts +3 -0
  22. package/dist/core/errors/namespaces.js +15 -0
  23. package/dist/core/errors/namespaces.ts +19 -0
  24. package/dist/core/finding.js +2 -2
  25. package/dist/core/finding.ts +1 -2
  26. package/dist/core/init.d.ts +1 -1
  27. package/dist/core/init.js +51 -5
  28. package/dist/core/init.ts +58 -5
  29. package/dist/core/invoked.d.ts +1 -1
  30. package/dist/core/invoked.js +3 -1
  31. package/dist/core/invoked.ts +5 -2
  32. package/dist/core/round.js +36 -22
  33. package/dist/core/round.ts +26 -9
  34. package/dist/core/rows.d.ts +4 -0
  35. package/dist/core/rows.js +31 -2
  36. package/dist/core/rows.ts +33 -1
  37. package/dist/core/scope.d.ts +1 -0
  38. package/dist/core/scope.js +1 -0
  39. package/dist/core/scope.ts +2 -0
  40. package/dist/core/thread.d.ts +3 -3
  41. package/dist/core/tree.d.ts +4 -1
  42. package/dist/core/tree.js +26 -6
  43. package/dist/core/tree.ts +29 -6
  44. package/dist/core/types.d.ts +3 -3
  45. package/dist/core/types.js +3 -1
  46. package/dist/core/types.ts +2 -1
  47. package/dist/derivation/attach.js +3 -2
  48. package/dist/derivation/attach.ts +2 -1
  49. package/dist/derivation/generators/build.js +6 -6
  50. package/dist/derivation/generators/build.ts +1 -1
  51. package/dist/derivation/generators/check.js +1 -1
  52. package/dist/derivation/generators/determinism.js +1 -1
  53. package/dist/derivation/generators/release.js +60 -47
  54. package/dist/derivation/generators/release.ts +66 -43
  55. package/dist/derivation/release.d.ts +7 -3
  56. package/dist/derivation/release.js +14 -1
  57. package/dist/derivation/release.ts +22 -2
  58. package/dist/integrations/attach.d.ts +4 -0
  59. package/dist/integrations/attach.js +37 -56
  60. package/dist/integrations/attach.ts +54 -60
  61. package/dist/integrations/cli.d.ts +37 -0
  62. package/dist/integrations/cli.js +440 -0
  63. package/dist/integrations/cli.ts +543 -0
  64. package/dist/{core/files.d.ts → integrations/disk.d.ts} +16 -24
  65. package/dist/integrations/disk.js +435 -0
  66. package/dist/integrations/disk.ts +465 -0
  67. package/dist/integrations/generators/read.js +6 -6
  68. package/dist/integrations/generators/read.ts +4 -4
  69. package/dist/integrations/generators/vault.js +10 -11
  70. package/dist/integrations/generators/vault.ts +4 -5
  71. package/dist/{operations/http.d.ts → integrations/https.d.ts} +10 -6
  72. package/dist/integrations/https.js +170 -0
  73. package/dist/integrations/https.ts +216 -0
  74. package/dist/integrations/pglite.d.ts +26 -0
  75. package/dist/integrations/pglite.js +143 -0
  76. package/dist/integrations/pglite.ts +206 -0
  77. package/dist/integrations/secret.d.ts +8 -2
  78. package/dist/integrations/secret.js +3 -5
  79. package/dist/integrations/secret.ts +10 -6
  80. package/dist/integrations/target.d.ts +155 -14
  81. package/dist/integrations/target.js +171 -50
  82. package/dist/integrations/target.ts +377 -61
  83. package/dist/integrations/vault.d.ts +1 -0
  84. package/dist/integrations/vault.js +20 -5
  85. package/dist/integrations/vault.ts +17 -5
  86. package/dist/integrity/attach.js +8 -77
  87. package/dist/integrity/attach.ts +7 -76
  88. package/dist/integrity/check-threads.js +5 -5
  89. package/dist/integrity/check-threads.ts +2 -2
  90. package/dist/integrity/constraint.d.ts +0 -1
  91. package/dist/integrity/constraint.js +267 -366
  92. package/dist/integrity/constraint.ts +267 -375
  93. package/dist/integrity/generators/compiler.js +14 -17
  94. package/dist/integrity/generators/compiler.ts +10 -15
  95. package/dist/integrity/generators/gate.js +15 -15
  96. package/dist/integrity/generators/gate.ts +10 -10
  97. package/dist/integrity/generators/issues.js +7 -7
  98. package/dist/integrity/generators/publish.js +39 -57
  99. package/dist/integrity/generators/publish.ts +44 -55
  100. package/dist/integrity/generators/trial.d.ts +3 -3
  101. package/dist/integrity/generators/trial.js +133 -165
  102. package/dist/integrity/generators/trial.ts +145 -169
  103. package/dist/integrity/lint.js +9 -13
  104. package/dist/integrity/lint.ts +7 -10
  105. package/dist/integrity/lsp/bin.js +5 -4
  106. package/dist/integrity/lsp/bin.ts +3 -1
  107. package/dist/integrity/lsp/diagnostics.js +3 -3
  108. package/dist/integrity/lsp/diagnostics.ts +1 -1
  109. package/dist/integrity/lsp/lint.js +19 -30
  110. package/dist/integrity/lsp/lint.ts +16 -32
  111. package/dist/integrity/lsp/server.js +3 -3
  112. package/dist/integrity/slopnator.d.ts +3 -13
  113. package/dist/integrity/slopnator.js +59 -38
  114. package/dist/integrity/slopnator.ts +54 -38
  115. package/dist/integrity/slopnators/sl_broken_lineage.js +2 -2
  116. package/dist/integrity/slopnators/sl_declared_elsewhere.js +1 -1
  117. package/dist/integrity/slopnators/sl_derived_drift.js +4 -4
  118. package/dist/integrity/slopnators/sl_derived_drift.ts +1 -1
  119. package/dist/integrity/slopnators/sl_door_in_a_node.js +220 -0
  120. package/dist/integrity/slopnators/sl_door_in_a_node.ts +250 -0
  121. package/dist/integrity/slopnators/sl_inert_island.js +10 -8
  122. package/dist/integrity/slopnators/sl_inert_island.ts +8 -6
  123. package/dist/integrity/slopnators/sl_missing_row.js +6 -51
  124. package/dist/integrity/slopnators/sl_missing_row.ts +4 -50
  125. package/dist/integrity/slopnators/sl_no_barrel.js +1 -1
  126. package/dist/integrity/slopnators/sl_no_child_process.js +36 -18
  127. package/dist/integrity/slopnators/sl_no_child_process.ts +44 -18
  128. package/dist/integrity/slopnators/sl_no_dispatch_bypass.js +80 -149
  129. package/dist/integrity/slopnators/sl_no_dispatch_bypass.ts +95 -147
  130. package/dist/integrity/slopnators/sl_no_import_cycle.js +15 -4
  131. package/dist/integrity/slopnators/sl_no_import_cycle.ts +20 -4
  132. package/dist/integrity/slopnators/sl_no_such_command.js +2 -2
  133. package/dist/integrity/slopnators/sl_no_such_command.ts +1 -1
  134. package/dist/integrity/slopnators/sl_outside_an_operation.js +20 -0
  135. package/dist/integrity/slopnators/sl_outside_an_operation.ts +25 -0
  136. package/dist/integrity/slopnators/sl_screen_holds_only_declared.d.ts +2 -0
  137. package/dist/integrity/slopnators/sl_screen_holds_only_declared.js +61 -0
  138. package/dist/integrity/slopnators/sl_screen_holds_only_declared.ts +70 -0
  139. package/dist/integrity/slopnators/sl_secret_literal.js +1 -33
  140. package/dist/integrity/slopnators/sl_secret_literal.ts +1 -33
  141. package/dist/integrity/slopnators/sl_stale_path.js +5 -22
  142. package/dist/integrity/slopnators/sl_stale_path.ts +4 -20
  143. package/dist/integrity/slopnators/sl_twice_meant.js +1 -1
  144. package/dist/integrity/slopnators/sl_twice_parented.js +29 -5
  145. package/dist/integrity/slopnators/sl_twice_parented.ts +28 -4
  146. package/dist/integrity/slopnators/sl_undeclared_crossing.d.ts +4 -1
  147. package/dist/integrity/slopnators/sl_undeclared_crossing.js +426 -62
  148. package/dist/integrity/slopnators/sl_undeclared_crossing.ts +454 -70
  149. package/dist/integrity/slopnators/sl_undeclared_destination.js +59 -25
  150. package/dist/integrity/slopnators/sl_undeclared_destination.ts +69 -21
  151. package/dist/integrity/slopnators/sl_undeclared_list.d.ts +2 -0
  152. package/dist/integrity/slopnators/sl_undeclared_list.js +363 -0
  153. package/dist/integrity/slopnators/sl_undeclared_list.ts +358 -0
  154. package/dist/integrity/slopnators/sl_undeclared_node.js +1 -11
  155. package/dist/integrity/slopnators/sl_undeclared_node.ts +0 -10
  156. package/dist/integrity/slopnators/sl_undeclared_operation.js +111 -29
  157. package/dist/integrity/slopnators/sl_undeclared_operation.ts +134 -26
  158. package/dist/integrity/slopnators/sl_undeclared_variant.js +2 -2
  159. package/dist/integrity/slopnators/sl_undeclared_webhook.d.ts +2 -0
  160. package/dist/integrity/slopnators/sl_undeclared_webhook.js +90 -0
  161. package/dist/integrity/slopnators/sl_undeclared_webhook.ts +108 -0
  162. package/dist/integrity/slopnators/sl_underived_route.d.ts +2 -0
  163. package/dist/integrity/slopnators/sl_underived_route.js +61 -0
  164. package/dist/integrity/slopnators/sl_underived_route.ts +72 -0
  165. package/dist/integrity/slopnators/sl_ungoverned_island.js +3 -3
  166. package/dist/integrity/slopnators/sl_ungoverned_island.ts +1 -1
  167. package/dist/integrity/slopnators/sl_unlisted_program.d.ts +2 -0
  168. package/dist/integrity/slopnators/sl_unlisted_program.js +39 -0
  169. package/dist/integrity/slopnators/sl_unlisted_program.ts +40 -0
  170. package/dist/integrity/slopnators/sl_unnamed_island.js +1 -1
  171. package/dist/integrity/slopnators/sl_unpaired_member.js +3 -3
  172. package/dist/integrity/slopnators/sl_unpaired_member.ts +1 -1
  173. package/dist/integrity/slopnators/sl_unpaired_slopnator.js +4 -4
  174. package/dist/integrity/slopnators/sl_unpaired_slopnator.ts +1 -1
  175. package/dist/integrity/slopnators/sl_unprefixed_member.js +5 -31
  176. package/dist/integrity/slopnators/sl_unprefixed_member.ts +2 -28
  177. package/dist/integrity/slopnators/sl_unthreaded.js +11 -7
  178. package/dist/integrity/slopnators/sl_unthreaded.ts +6 -7
  179. package/dist/integrity/slopnators/sl_untranslated_key.js +2 -25
  180. package/dist/integrity/slopnators/sl_untranslated_key.ts +1 -25
  181. package/dist/integrity/slopnators/sl_unvaulted_secret.d.ts +2 -0
  182. package/dist/integrity/slopnators/sl_unvaulted_secret.js +107 -0
  183. package/dist/integrity/slopnators/sl_unvaulted_secret.ts +132 -0
  184. package/dist/integrity/slopnators/sl_unversioned.js +6 -4
  185. package/dist/integrity/slopnators/sl_unversioned.ts +5 -3
  186. package/dist/integrity/sweep.d.ts +1 -0
  187. package/dist/integrity/sweep.js +105 -42
  188. package/dist/integrity/sweep.ts +115 -42
  189. package/dist/knowledge/attach.js +4 -3
  190. package/dist/knowledge/attach.ts +3 -2
  191. package/dist/knowledge/generators/docsgen.js +8 -6
  192. package/dist/knowledge/generators/docsgen.ts +4 -2
  193. package/dist/knowledge/generators/glossary.js +4 -4
  194. package/dist/knowledge/generators/glossary.ts +1 -1
  195. package/dist/operations/access.d.ts +23 -0
  196. package/dist/operations/access.js +28 -1
  197. package/dist/operations/access.ts +43 -0
  198. package/dist/operations/attach.js +33 -113
  199. package/dist/operations/attach.ts +51 -117
  200. package/dist/operations/capabilities.d.ts +14 -5
  201. package/dist/operations/capabilities.js +13 -4
  202. package/dist/operations/capabilities.ts +27 -8
  203. package/dist/operations/dispatch.d.ts +8 -2
  204. package/dist/operations/dispatch.js +128 -185
  205. package/dist/operations/dispatch.ts +138 -191
  206. package/dist/operations/error-results.d.ts +1 -1
  207. package/dist/operations/error-results.js +2 -2
  208. package/dist/operations/error-results.ts +2 -2
  209. package/dist/operations/generators/capability.d.ts +11 -1
  210. package/dist/operations/generators/capability.js +481 -224
  211. package/dist/operations/generators/capability.ts +562 -233
  212. package/dist/operations/generators/compile.js +66 -39
  213. package/dist/operations/generators/compile.ts +78 -39
  214. package/dist/operations/generators/permits.js +11 -12
  215. package/dist/operations/generators/permits.ts +3 -4
  216. package/dist/operations/generators/seed.d.ts +1 -0
  217. package/dist/operations/generators/seed.js +19 -17
  218. package/dist/operations/generators/seed.ts +22 -14
  219. package/dist/operations/generators/trial.d.ts +6 -8
  220. package/dist/operations/generators/trial.js +200 -70
  221. package/dist/operations/generators/trial.ts +230 -93
  222. package/dist/operations/nodes.d.ts +15 -16
  223. package/dist/operations/nodes.ts +16 -17
  224. package/dist/operations/operations.d.ts +40 -4
  225. package/dist/operations/operations.js +1 -0
  226. package/dist/operations/operations.ts +61 -4
  227. package/dist/operations/result.d.ts +2 -2
  228. package/dist/operations/result.ts +2 -2
  229. package/package.json +1 -4
  230. package/dist/core/answers.d.ts +0 -171
  231. package/dist/core/answers.js +0 -789
  232. package/dist/core/answers.ts +0 -999
  233. package/dist/core/client.d.ts +0 -63
  234. package/dist/core/client.js +0 -249
  235. package/dist/core/client.ts +0 -289
  236. package/dist/core/files.js +0 -171
  237. package/dist/core/files.ts +0 -222
  238. package/dist/integrations/module.d.ts +0 -6
  239. package/dist/integrations/module.js +0 -153
  240. package/dist/integrations/module.ts +0 -191
  241. package/dist/integrity/slopnators/sl_unkept_rows.js +0 -104
  242. package/dist/integrity/slopnators/sl_unkept_rows.ts +0 -111
  243. package/dist/integrity/slopnators/sl_unseamed_reach.js +0 -73
  244. package/dist/integrity/slopnators/sl_unseamed_reach.ts +0 -79
  245. package/dist/operations/cost.d.ts +0 -14
  246. package/dist/operations/cost.js +0 -37
  247. package/dist/operations/cost.ts +0 -58
  248. package/dist/operations/errors/errors.d.ts +0 -52
  249. package/dist/operations/http.js +0 -124
  250. package/dist/operations/http.ts +0 -169
  251. package/dist/operations/memory.d.ts +0 -104
  252. package/dist/operations/memory.js +0 -365
  253. package/dist/operations/memory.ts +0 -470
  254. package/dist/operations/metering.d.ts +0 -55
  255. package/dist/operations/metering.js +0 -247
  256. package/dist/operations/metering.ts +0 -328
  257. package/dist/operations/queue-policy.d.ts +0 -3
  258. package/dist/operations/queue-policy.js +0 -8
  259. package/dist/operations/queue-policy.ts +0 -10
  260. package/dist/operations/seams.d.ts +0 -239
  261. package/dist/operations/seams.js +0 -45
  262. package/dist/operations/seams.ts +0 -364
  263. package/dist/operations/store.d.ts +0 -14
  264. package/dist/operations/store.js +0 -1
  265. package/dist/operations/store.ts +0 -29
  266. /package/dist/{operations → core}/errors/classes.d.ts +0 -0
  267. /package/dist/{operations → core}/errors/classes.js +0 -0
  268. /package/dist/{operations → core}/errors/classes.ts +0 -0
  269. /package/dist/integrity/slopnators/{sl_unkept_rows.d.ts → sl_door_in_a_node.d.ts} +0 -0
  270. /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 Byproduct, type Slopnator } from '../slopnator.ts';
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 * as disk from 'node:fs';
2
- import { answeredBy, existsSync, readFileSync } from "../../core/files.js";
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 { CONSTRAINTS } from "../constraint.js";
8
- import { NOT_WRITTEN, ROOT, governs, load, proofsOf, reads, rules, slopnatorName, sweeps, write } from "../slopnator.js";
9
- import { forget } from "../slopnators/sl_unthreaded.js";
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(answering(trial.scenario.files));
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: [`no rule named "${trial.rule}" is registered, so this trial is about nothing — regenerate with \`thread trials\``],
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
- return runTrial(trial, rule, module, parser, slopnators?.get(slopnatorName(rule.id)));
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
- }