@stateward/core 1.2.1 → 1.3.0
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/dist/analyses.d.ts +37 -0
- package/dist/analyses.js +57 -0
- package/dist/backend/program-record.d.ts +7 -0
- package/dist/backend/typescript6.d.ts +35 -32
- package/dist/backend/typescript6.js +3804 -163
- package/dist/baseline.d.ts +1 -1
- package/dist/baseline.js +14 -10
- package/dist/cache.d.ts +89 -5
- package/dist/cache.js +271 -40
- package/dist/checker.d.ts +11 -1
- package/dist/checker.js +32 -2
- package/dist/class-id.d.ts +34 -0
- package/dist/class-id.js +93 -0
- package/dist/code-text.d.ts +8 -0
- package/dist/code-text.js +66 -0
- package/dist/config-file.js +7 -5
- package/dist/config.d.ts +10 -2
- package/dist/config.js +541 -49
- package/dist/define.d.ts +8 -2
- package/dist/disk-cache.d.ts +2 -0
- package/dist/disk-cache.js +77 -11
- package/dist/engine.d.ts +51 -1
- package/dist/engine.js +517 -42
- package/dist/fact-lines.d.ts +31 -0
- package/dist/fact-lines.js +197 -0
- package/dist/facts-versions.d.ts +27 -0
- package/dist/facts-versions.js +99 -0
- package/dist/fixes.js +9 -4
- package/dist/guarantees.d.ts +63 -11
- package/dist/guarantees.js +151 -21
- package/dist/ignores.d.ts +11 -0
- package/dist/ignores.js +74 -27
- package/dist/implementation.d.ts +0 -6
- package/dist/implementation.js +0 -17
- package/dist/index.d.ts +10 -9
- package/dist/index.js +14 -7
- package/dist/internal.d.ts +9 -5
- package/dist/internal.js +6 -3
- package/dist/lazy.d.ts +8 -1
- package/dist/lazy.js +27 -2
- package/dist/ledger.d.ts +77 -0
- package/dist/ledger.js +423 -0
- package/dist/off-by-default.d.ts +13 -0
- package/dist/off-by-default.js +15 -0
- package/dist/options.d.ts +21 -5
- package/dist/options.js +22 -7
- package/dist/package-facts.d.ts +211 -17
- package/dist/package-facts.js +520 -38
- package/dist/plan.d.ts +1 -1
- package/dist/plan.js +7 -2
- package/dist/release.d.ts +12 -21
- package/dist/release.js +28 -38
- package/dist/renamed.d.ts +22 -3
- package/dist/renamed.js +50 -16
- package/dist/rollout.js +7 -4
- package/dist/safe-calls.d.ts +26 -0
- package/dist/safe-calls.js +345 -0
- package/dist/severity.d.ts +1 -1
- package/dist/severity.js +17 -3
- package/dist/stated.d.ts +37 -0
- package/dist/stated.js +123 -0
- package/dist/test-runner.d.ts +18 -0
- package/dist/test-runner.js +483 -0
- package/dist/testing-tsc.d.ts +16 -0
- package/dist/testing-tsc.js +86 -0
- package/dist/testing.d.ts +5 -4
- package/dist/testing.js +6 -6
- package/dist/timing.d.ts +15 -0
- package/dist/timing.js +41 -2
- package/dist/types.d.ts +1068 -16
- package/dist/unread.d.ts +90 -0
- package/dist/unread.js +405 -0
- package/dist/vocabulary.d.ts +1 -1
- package/dist/vocabulary.js +1 -1
- package/package.json +4 -2
package/dist/timing.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export type RuleCost = {
|
|
|
20
20
|
* triggers first, which later questions of any rule then reuse.
|
|
21
21
|
*/
|
|
22
22
|
readonly typeMs: number;
|
|
23
|
+
/**
|
|
24
|
+
* Of `typeMs`, the first answer to each question (a method asked about the same node, symbol or
|
|
25
|
+
* value): the shared type checking, which later questions of any rule reuse. The rest of `ms` is
|
|
26
|
+
* the rule's own work.
|
|
27
|
+
*/
|
|
28
|
+
readonly firstTypeMs: number;
|
|
23
29
|
/** Files the rule ran on (not counting results reused from the cache). */
|
|
24
30
|
readonly files: number;
|
|
25
31
|
/**
|
|
@@ -48,8 +54,15 @@ export type RunTiming = {
|
|
|
48
54
|
readonly programMs: number;
|
|
49
55
|
/** Of the rules' time, inside type questions: the type checking the rules ask for. */
|
|
50
56
|
readonly typeMs: number;
|
|
57
|
+
/** Of `typeMs`, the first answer to each question: the shared type checking (`RuleCost.firstTypeMs`). */
|
|
58
|
+
readonly firstTypeMs: number;
|
|
51
59
|
/** Dependency fingerprints for the results cache. */
|
|
52
60
|
readonly fingerprintMs: number;
|
|
61
|
+
/**
|
|
62
|
+
* The reference ledger: every reference to each stated declaration, in the files whose ledger is
|
|
63
|
+
* not in the cache (its type questions included).
|
|
64
|
+
*/
|
|
65
|
+
readonly ledgerMs: number;
|
|
53
66
|
/** Everything else: syntax and import findings, ignore comments, sorting, the cache. */
|
|
54
67
|
readonly otherMs: number;
|
|
55
68
|
/** The second pass's time (not part of the check's result), when there was one. */
|
|
@@ -61,6 +74,8 @@ export type TimingRecorder = {
|
|
|
61
74
|
/** The time of building programs, added to `programMs`. */
|
|
62
75
|
program(ms: number): void;
|
|
63
76
|
fingerprint(ms: number): void;
|
|
77
|
+
/** The time of the reference ledger on one file, added to `ledgerMs`. */
|
|
78
|
+
ledger(ms: number): void;
|
|
64
79
|
/** Runs `run` as `ruleId`'s file side on one file and records its cost. */
|
|
65
80
|
fileSide<T>(ruleId: string, kind: "file" | "project", run: () => T): T;
|
|
66
81
|
/** Counts one result of `ruleId` reused from the cache. */
|
package/dist/timing.js
CHANGED
|
@@ -5,9 +5,36 @@ export function createTimingRecorder({ secondPass = false, } = {}) {
|
|
|
5
5
|
let started = performance.now();
|
|
6
6
|
let programMs = 0;
|
|
7
7
|
let fingerprintMs = 0;
|
|
8
|
+
let ledgerMs = 0;
|
|
8
9
|
/** The type time of the rule that is running; undefined between rules. */
|
|
9
10
|
let current;
|
|
10
11
|
const wrapped = new WeakMap();
|
|
12
|
+
/** The questions asked so far, by their first argument, then the method: a second ask is not first. */
|
|
13
|
+
const askedOn = new WeakMap();
|
|
14
|
+
const askedBy = new Map();
|
|
15
|
+
/** Whether this is the first time `method` is asked about `subject` in the run; notes it. */
|
|
16
|
+
const firstAsk = (method, subject) => {
|
|
17
|
+
let methods;
|
|
18
|
+
if (typeof subject === "object" && subject !== null) {
|
|
19
|
+
methods = askedOn.get(subject);
|
|
20
|
+
if (methods === undefined) {
|
|
21
|
+
methods = new Set();
|
|
22
|
+
askedOn.set(subject, methods);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const key = `${typeof subject}:${String(subject)}`;
|
|
27
|
+
methods = askedBy.get(key);
|
|
28
|
+
if (methods === undefined) {
|
|
29
|
+
methods = new Set();
|
|
30
|
+
askedBy.set(key, methods);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (methods.has(method))
|
|
34
|
+
return false;
|
|
35
|
+
methods.add(method);
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
11
38
|
const costOf = (ruleId, kind) => {
|
|
12
39
|
let found = rules.get(ruleId);
|
|
13
40
|
if (found === undefined) {
|
|
@@ -19,6 +46,7 @@ export function createTimingRecorder({ secondPass = false, } = {}) {
|
|
|
19
46
|
fileMs: 0,
|
|
20
47
|
projectMs: 0,
|
|
21
48
|
typeMs: 0,
|
|
49
|
+
firstTypeMs: 0,
|
|
22
50
|
files: 0,
|
|
23
51
|
reused: 0,
|
|
24
52
|
allocatedBytes: 0,
|
|
@@ -55,6 +83,9 @@ export function createTimingRecorder({ secondPass = false, } = {}) {
|
|
|
55
83
|
fingerprint(ms) {
|
|
56
84
|
fingerprintMs += ms;
|
|
57
85
|
},
|
|
86
|
+
ledger(ms) {
|
|
87
|
+
ledgerMs += ms;
|
|
88
|
+
},
|
|
58
89
|
fileSide(ruleId, kind, run) {
|
|
59
90
|
const cost = costOf(ruleId, kind);
|
|
60
91
|
cost.files += 1;
|
|
@@ -90,13 +121,18 @@ export function createTimingRecorder({ secondPass = false, } = {}) {
|
|
|
90
121
|
}
|
|
91
122
|
// A question asked inside another (none today) is counted once, by the outer one.
|
|
92
123
|
current = undefined;
|
|
124
|
+
// The second pass asks everything again: only the check's first asks are shared.
|
|
125
|
+
const first = typeSide === "typeMs" && firstAsk(key, args[0]);
|
|
93
126
|
const at = performance.now();
|
|
94
127
|
try {
|
|
95
128
|
const answer = Reflect.apply(value, target, args);
|
|
96
129
|
return answer;
|
|
97
130
|
}
|
|
98
131
|
finally {
|
|
99
|
-
|
|
132
|
+
const spent = performance.now() - at;
|
|
133
|
+
cost[typeSide] += spent;
|
|
134
|
+
if (first)
|
|
135
|
+
cost.firstTypeMs += spent;
|
|
100
136
|
current = cost;
|
|
101
137
|
}
|
|
102
138
|
};
|
|
@@ -124,14 +160,17 @@ export function createTimingRecorder({ secondPass = false, } = {}) {
|
|
|
124
160
|
const ruleMs = costs.reduce((sum, cost) => sum + cost.ms, 0);
|
|
125
161
|
const warmMs = costs.reduce((sum, cost) => sum + (cost.warmMs ?? 0), 0);
|
|
126
162
|
const typeMs = costs.reduce((sum, cost) => sum + cost.typeMs, 0);
|
|
163
|
+
const firstTypeMs = costs.reduce((sum, cost) => sum + cost.firstTypeMs, 0);
|
|
127
164
|
// The second pass is not part of the check: the total is what the check alone took.
|
|
128
165
|
const totalMs = elapsed - warmMs;
|
|
129
166
|
return {
|
|
130
167
|
totalMs,
|
|
131
168
|
programMs,
|
|
132
169
|
typeMs,
|
|
170
|
+
firstTypeMs,
|
|
133
171
|
fingerprintMs,
|
|
134
|
-
|
|
172
|
+
ledgerMs,
|
|
173
|
+
otherMs: Math.max(0, totalMs - programMs - fingerprintMs - ledgerMs - ruleMs),
|
|
135
174
|
secondPassMs: secondPass ? warmMs : undefined,
|
|
136
175
|
rules: costs,
|
|
137
176
|
};
|