@nielspeter/eess-ts 0.10.1 → 0.12.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/builders/class-rule-builder.d.ts +5 -4
- package/dist/builders/class-rule-builder.d.ts.map +1 -1
- package/dist/builders/class-rule-builder.js +5 -4
- package/dist/builders/class-rule-builder.js.map +1 -1
- package/dist/builders/type-rule-builder.d.ts +2 -1
- package/dist/builders/type-rule-builder.d.ts.map +1 -1
- package/dist/builders/type-rule-builder.js +2 -1
- package/dist/builders/type-rule-builder.js.map +1 -1
- package/dist/conditions/class.d.ts +6 -4
- package/dist/conditions/class.d.ts.map +1 -1
- package/dist/conditions/class.js +6 -4
- package/dist/conditions/class.js.map +1 -1
- package/dist/core/check-all.js +1 -1
- package/dist/core/diagnose.d.ts.map +1 -1
- package/dist/core/diagnose.js +22 -6
- package/dist/core/diagnose.js.map +1 -1
- package/dist/core/disk-set.d.ts +85 -22
- package/dist/core/disk-set.d.ts.map +1 -1
- package/dist/core/disk-set.js +223 -67
- package/dist/core/disk-set.js.map +1 -1
- package/dist/core/glob-diagnosis.d.ts +45 -11
- package/dist/core/glob-diagnosis.d.ts.map +1 -1
- package/dist/core/glob-diagnosis.js +98 -22
- package/dist/core/glob-diagnosis.js.map +1 -1
- package/dist/core/terminal-builder.d.ts.map +1 -1
- package/dist/core/terminal-builder.js +80 -21
- package/dist/core/terminal-builder.js.map +1 -1
- package/dist/core/vacuity-diagnosis.d.ts.map +1 -1
- package/dist/core/vacuity-diagnosis.js +161 -40
- package/dist/core/vacuity-diagnosis.js.map +1 -1
- package/dist/helpers/baseline.d.ts.map +1 -1
- package/dist/helpers/baseline.js +3 -7
- package/dist/helpers/baseline.js.map +1 -1
- package/dist/helpers/heritage.d.ts +19 -5
- package/dist/helpers/heritage.d.ts.map +1 -1
- package/dist/helpers/heritage.js +72 -8
- package/dist/helpers/heritage.js.map +1 -1
- package/dist/predicates/class.d.ts +7 -5
- package/dist/predicates/class.d.ts.map +1 -1
- package/dist/predicates/class.js +7 -5
- package/dist/predicates/class.js.map +1 -1
- package/dist/predicates/type.d.ts +3 -2
- package/dist/predicates/type.d.ts.map +1 -1
- package/dist/predicates/type.js +47 -13
- package/dist/predicates/type.js.map +1 -1
- package/package.json +2 -2
package/dist/core/disk-set.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import picomatch from 'picomatch';
|
|
4
|
-
import { discoverIdentityRoot } from '@nielspeter/eess/internal';
|
|
4
|
+
import { byCodepoint, discoverIdentityRoot } from '@nielspeter/eess/internal';
|
|
5
5
|
import { readsRootRelativePath, rootFromTsConfigPath } from './project-relative.js';
|
|
6
6
|
/**
|
|
7
7
|
* Directories never worth walking.
|
|
@@ -27,6 +27,34 @@ const PRUNE = new Set([
|
|
|
27
27
|
'.gradle',
|
|
28
28
|
'.yarn',
|
|
29
29
|
'.cache',
|
|
30
|
+
// Added for bug 0359. Pruning — not repository size — is what decides whether
|
|
31
|
+
// the walk finishes: measured on this repository, the list above removes
|
|
32
|
+
// **88.9%** of entries, and unpruned this small repo would sit at 41% of the
|
|
33
|
+
// old 50,000 budget by itself (spike 0368). The list named fourteen and missed
|
|
34
|
+
// the one that mattered — an adopter's `.wrangler` was **58% of their entries**
|
|
35
|
+
// in the monorepo that measured closest to the budget.
|
|
36
|
+
//
|
|
37
|
+
// Only the FIRST of these has a measured share; the rest are the same class of
|
|
38
|
+
// thing — build, cache and framework output no rule can usefully scope to — and
|
|
39
|
+
// are cheap to prune. Named individually rather than matched by a leading dot,
|
|
40
|
+
// because `.claude/`, `.changeset/` and `.github/` are content this repo's own
|
|
41
|
+
// corpus gate reads.
|
|
42
|
+
'.wrangler',
|
|
43
|
+
'.svelte-kit',
|
|
44
|
+
'.nuxt',
|
|
45
|
+
'.output',
|
|
46
|
+
'.parcel-cache',
|
|
47
|
+
'.vite',
|
|
48
|
+
'.astro',
|
|
49
|
+
'.docusaurus',
|
|
50
|
+
'.serverless',
|
|
51
|
+
'.terraform',
|
|
52
|
+
'storybook-static',
|
|
53
|
+
'.pnpm-store',
|
|
54
|
+
'.angular',
|
|
55
|
+
'.expo',
|
|
56
|
+
'.dart_tool',
|
|
57
|
+
'.sst',
|
|
30
58
|
]);
|
|
31
59
|
/**
|
|
32
60
|
* How many directory entries the walk will read before giving up.
|
|
@@ -46,7 +74,7 @@ const PRUNE = new Set([
|
|
|
46
74
|
* was a licence to lower the budget on the belief that nothing but wording
|
|
47
75
|
* depended on it.
|
|
48
76
|
*
|
|
49
|
-
* `
|
|
77
|
+
* `contradictsAbsence` below is the policy that consumes this classification to decide
|
|
50
78
|
* whether a cardinality rule (`.notExist()` and friends) reports at all. And the
|
|
51
79
|
* degradation is **whole-set, not per-glob** — `build()` returns the single
|
|
52
80
|
* `UNDETERMINED` object, whose `classify` answers `not-determined` for every
|
|
@@ -57,19 +85,60 @@ const PRUNE = new Set([
|
|
|
57
85
|
* That is not a regression — before 0355 those rules were silent everywhere —
|
|
58
86
|
* but it is an undisclosed limit on a fix, and nothing currently reports that
|
|
59
87
|
* the walk gave up. Surfacing exhaustion is
|
|
60
|
-
* [bug 0359](../../../../work/bugs/0359-a-disk-walk-that-gave-up-reports-nothing-and-now-decides-a-verdict.md)
|
|
88
|
+
* [bug 0359](../../../../work/bugs/fixed/0359-a-disk-walk-that-gave-up-reports-nothing-and-now-decides-a-verdict.md),
|
|
89
|
+
* and it is now surfaced: `exhaustion` on the returned `DiskSet` carries the
|
|
90
|
+
* fact and what consumed the walk, and the cardinality path reports it rather
|
|
91
|
+
* than going quiet.
|
|
92
|
+
*
|
|
93
|
+
* ## Why 500,000, and why the old 50,000 was far too low
|
|
94
|
+
*
|
|
95
|
+
* The justification above is a claim about TIME — a 5s vitest timeout. Measured
|
|
96
|
+
* at **2.09 µs/entry** (spike 0367; spike 0360 got 1.55 µs/entry by a different
|
|
97
|
+
* method, which is what makes either trustworthy), 50,000 entries is about
|
|
98
|
+
* **105 ms of work**. The cutoff fired roughly **48× below its own stated
|
|
99
|
+
* reason**, and silenced a gate to do it.
|
|
100
|
+
*
|
|
101
|
+
* 500,000 is 0.8–1.5s warm (spike 0360) and puts every repository measured so
|
|
102
|
+
* far far inside it: this one at ~2,300 entries after pruning, an adopter's
|
|
103
|
+
* 15-package monorepo at 16,770. **Not unbounded** — the cold-cache cost is
|
|
104
|
+
* still unmeasured, which is exactly why 0360 declined to recommend removing the
|
|
105
|
+
* bound, and raising it is supported by measurement where removing it is not.
|
|
61
106
|
*
|
|
62
|
-
* Anyone changing this number: it is the threshold at which a shipped gate
|
|
63
|
-
*
|
|
107
|
+
* Anyone changing this number: it is the threshold at which a shipped gate stops
|
|
108
|
+
* being able to answer. It no longer does so silently, which is the fix — but a
|
|
109
|
+
* reported degradation is still a degradation. Measure before you lower it.
|
|
64
110
|
*/
|
|
65
|
-
const ENTRY_BUDGET =
|
|
111
|
+
const ENTRY_BUDGET = 500_000;
|
|
66
112
|
// `.d.ts` and its `.d.mts`/`.d.cts` siblings count. They ARE TypeScript for
|
|
67
113
|
// the question this set answers — "does this path contain TypeScript your
|
|
68
114
|
// tsconfig is keeping out" — and excluding them made a `types/` directory of
|
|
69
115
|
// pure declarations report "this path exists but contains no TypeScript",
|
|
70
116
|
// which is false.
|
|
71
117
|
const TS_FILE = /\.(m|c)?tsx?$/;
|
|
72
|
-
|
|
118
|
+
let cache = new WeakMap();
|
|
119
|
+
/**
|
|
120
|
+
* Budget override for the MEMOIZED path. Tests only.
|
|
121
|
+
*
|
|
122
|
+
* `buildDiskSet` above already takes an injectable budget and is documented
|
|
123
|
+
* "exported for tests only" — but it bypasses the memo, and the production
|
|
124
|
+
* consumer of a classification is `deadSiteRoute` in `glob-diagnosis.ts`, which goes
|
|
125
|
+
* through `diskSet(project)`. So a test could construct an exhausted set and
|
|
126
|
+
* could not make a RULE see one, which left bug 0359's defect reachable only
|
|
127
|
+
* below the public entry point. A test that drives a stand-in instead of
|
|
128
|
+
* `violations()` is how a suite stays green while the defect survives.
|
|
129
|
+
*
|
|
130
|
+
* Reaching exhaustion honestly is not an option: the budget is 500,000 entries.
|
|
131
|
+
*
|
|
132
|
+
* This overrides the constant and clears the memo, so the walk really runs, the
|
|
133
|
+
* real `classify` answers, and the finding travels the real path — only the
|
|
134
|
+
* number differs from production.
|
|
135
|
+
*/
|
|
136
|
+
// eess-exclude eess/no-unused-exports: consumed by the test suite; the build tsconfig this gate reads excludes tests, so `src` is the only usage it can see
|
|
137
|
+
export function setDiskWalkBudgetForTests(limit) {
|
|
138
|
+
budgetForTests = limit;
|
|
139
|
+
cache = new WeakMap();
|
|
140
|
+
}
|
|
141
|
+
let budgetForTests;
|
|
73
142
|
/**
|
|
74
143
|
* The project's disk set, walked at most once and only when asked.
|
|
75
144
|
*
|
|
@@ -78,36 +147,6 @@ const cache = new WeakMap();
|
|
|
78
147
|
* never touches the filesystem. An eager version would charge every `check()`
|
|
79
148
|
* a recursive walk to answer a question no fault asked.
|
|
80
149
|
*/
|
|
81
|
-
/**
|
|
82
|
-
* Does the filesystem CONTRADICT a rule's claim that nothing matching this glob exists?
|
|
83
|
-
*
|
|
84
|
-
* The one owner of a policy two tools have to share — the gate's evidence floor
|
|
85
|
-
* (`vacuity-diagnosis.ts`) and the preview (`diagnose.ts`). It is written here, beside the
|
|
86
|
-
* classification it reads, because the pair has already grown two hand-maintained copies of one
|
|
87
|
-
* rule and had them disagree: `isFaultPosition` was inverse lists in both files, differing over
|
|
88
|
-
* exactly `discovery`, so `doctor` reported a dead layer glob and the build stayed green.
|
|
89
|
-
*
|
|
90
|
-
* ## Why only `holds-typescript`
|
|
91
|
-
*
|
|
92
|
-
* A rule asserting cardinality — `.notExist()` and friends — is SATISFIED by having no
|
|
93
|
-
* subjects, so examining zero is normally the rule working. The trouble is that a holding
|
|
94
|
-
* ratchet and a selector that silently stopped matching are identical from the glob and the
|
|
95
|
-
* path universe: both match nothing. Only disk tells them apart.
|
|
96
|
-
*
|
|
97
|
-
* | classification | verdict | why |
|
|
98
|
-
* | ------------------ | ------- | ---------------------------------------------------------------- |
|
|
99
|
-
* | `holds-typescript` | **contradicted** | the code being asserted away is right there, unexamined |
|
|
100
|
-
* | `absent` | consistent | the ratchet holding — the common case, and it must stay silent |
|
|
101
|
-
* | `no-typescript` | consistent | no TypeScript means no modules, which is what the rule asserts |
|
|
102
|
-
* | `not-determined` | consistent | the walk could not answer; blaming the author for that is the confidently-wrong remedy this module exists not to give |
|
|
103
|
-
*
|
|
104
|
-
* [Bug 0355](../../../../work/bugs/fixed/0355-a-cardinality-rule-cannot-tell-none-exist-from-my-selector-broke.md)
|
|
105
|
-
* for the gate half, [0357](../../../../work/bugs/fixed/0357-doctor-reports-a-healthy-ratchet-as-a-dead-glob.md)
|
|
106
|
-
* for the preview.
|
|
107
|
-
*/
|
|
108
|
-
function absenceClaimIsContradicted(project, glob) {
|
|
109
|
-
return contradictsAbsence(diskSet(project).classify(glob));
|
|
110
|
-
}
|
|
111
150
|
/**
|
|
112
151
|
* The policy alone, as a TOTAL function on the four classifications.
|
|
113
152
|
*
|
|
@@ -121,39 +160,14 @@ function absenceClaimIsContradicted(project, glob) {
|
|
|
121
160
|
* Exhaustive by construction: `OnDisk` is a four-value union, so a test that enumerates it
|
|
122
161
|
* cannot silently stop covering a case when a fifth is added — it stops compiling.
|
|
123
162
|
*/
|
|
124
|
-
// eess-exclude eess/no-unused-exports: consumed by the test suite; the build tsconfig this gate reads excludes tests, so `src` is the only usage it can see
|
|
125
163
|
export function contradictsAbsence(onDisk) {
|
|
126
164
|
return onDisk === 'holds-typescript';
|
|
127
165
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Is a dead site on a CARDINALITY rule a real fault, given the glob and the disk?
|
|
130
|
-
*
|
|
131
|
-
* Two independent ways to be one, and the second was missing for a release:
|
|
132
|
-
*
|
|
133
|
-
* 1. **The glob is broken in every possible project** — a syntactic fault, decided from the
|
|
134
|
-
* text with no filesystem and no universe. `'./src/**'` is one character wrong and matches
|
|
135
|
-
* nothing anywhere.
|
|
136
|
-
* 2. **The filesystem contradicts the absence claim** — `contradictsAbsence` above.
|
|
137
|
-
*
|
|
138
|
-
* Bug 0357 added the disk test and, by placing it after `isDeadSite`, dropped the first.
|
|
139
|
-
* Measured on a healthy project with `src/a.ts` loaded: a `.notExist()` over `'./src/**'`
|
|
140
|
-
* went green in `doctor` AND `check`, while the same glob on a positive-assertion rule
|
|
141
|
-
* reported — so a ratchet broken by one character said nothing in either tool, and the
|
|
142
|
-
* directory it names exists, is in the project, and holds TypeScript. Shipped in 0.10.0 and
|
|
143
|
-
* caught by a review of the review's own fixes.
|
|
144
|
-
*
|
|
145
|
-
* `diagnose.ts` states the principle twice about itself — syntactic faults "are properties of
|
|
146
|
-
* the glob text, not of what loaded", and survive even an empty project. They must survive
|
|
147
|
-
* this narrowing too.
|
|
148
|
-
*/
|
|
149
|
-
export function cardinalityDeadSiteIsAtFault(project, glob, hasSyntacticFault) {
|
|
150
|
-
return hasSyntacticFault || absenceClaimIsContradicted(project, glob);
|
|
151
|
-
}
|
|
152
166
|
export function diskSet(project) {
|
|
153
167
|
const cached = cache.get(project);
|
|
154
168
|
if (cached)
|
|
155
169
|
return cached;
|
|
156
|
-
const built = build(project, ENTRY_BUDGET);
|
|
170
|
+
const built = build(project, budgetForTests ?? ENTRY_BUDGET);
|
|
157
171
|
cache.set(project, built);
|
|
158
172
|
return built;
|
|
159
173
|
}
|
|
@@ -185,6 +199,23 @@ function build(project, budgetLimit) {
|
|
|
185
199
|
const root = discoverIdentityRoot(path.dirname(project.tsConfigPath));
|
|
186
200
|
if (!fs.existsSync(root))
|
|
187
201
|
return UNDETERMINED;
|
|
202
|
+
// The FILESYSTEM root is never a project root, and walking it is never
|
|
203
|
+
// meaningful. `discoverIdentityRoot` falls back to its own argument when it
|
|
204
|
+
// finds no marker, so a tsconfig path with nothing above it resolves to `/`
|
|
205
|
+
// and this walked the entire disk.
|
|
206
|
+
//
|
|
207
|
+
// Found by bug 0359's own fix: that walk always happened, exhausted, and
|
|
208
|
+
// returned the silent `UNDETERMINED`, so nobody could see it. The moment
|
|
209
|
+
// exhaustion started reporting, every in-memory double in this suite surfaced a
|
|
210
|
+
// finding — 0359's thesis landing in a second place. `not-determined` was the
|
|
211
|
+
// right answer all along; it now arrives without reading the whole disk first.
|
|
212
|
+
//
|
|
213
|
+
// Narrow on purpose. A first draft refused any root without a `.git` or
|
|
214
|
+
// `package.json` and reddened two legitimate fixtures: a bare directory holding
|
|
215
|
+
// only a tsconfig IS a project, and eess must not require a manifest it never
|
|
216
|
+
// asked for. The pathology is reaching `/`, not lacking a marker.
|
|
217
|
+
if (path.dirname(root) === root)
|
|
218
|
+
return UNDETERMINED;
|
|
188
219
|
const files = [];
|
|
189
220
|
/** Every file, TypeScript or not — so `absent` means absent, not "not TypeScript". */
|
|
190
221
|
const everyFile = [];
|
|
@@ -199,8 +230,28 @@ function build(project, budgetLimit) {
|
|
|
199
230
|
* beginning "a path segment is misspelled".
|
|
200
231
|
*/
|
|
201
232
|
const pruned = [];
|
|
233
|
+
/**
|
|
234
|
+
* Entries whose KIND the walk declined to resolve — symlinks.
|
|
235
|
+
*
|
|
236
|
+
* `Dirent.isDirectory()` is false for a symlink under `withFileTypes`, so a symlinked
|
|
237
|
+
* DIRECTORY is recorded as a file. That trade is deliberate and documented below: following
|
|
238
|
+
* the link risks a walk that never terminates, and for `classify` being wrong this way only
|
|
239
|
+
* weakens a message.
|
|
240
|
+
*
|
|
241
|
+
* `matchesOnlyFiles` cannot live with it, because it asserts "and NO directory" — and a
|
|
242
|
+
* symlink's kind is precisely what was not resolved. Kept as its own list rather than
|
|
243
|
+
* changing what `everyFile` holds, so `classify`'s documented behaviour is untouched.
|
|
244
|
+
*/
|
|
245
|
+
const kindUnknown = [];
|
|
202
246
|
let budget = budgetLimit;
|
|
203
247
|
let exhausted = false;
|
|
248
|
+
/**
|
|
249
|
+
* Entries read per top-level subtree of `root`, so exhaustion can name what
|
|
250
|
+
* consumed the walk instead of blaming the repository's size (spike 0368).
|
|
251
|
+
* Attributed to the FIRST segment below `root` and no deeper: the remedy is
|
|
252
|
+
* "stop walking this tree", which is a decision about a top-level directory.
|
|
253
|
+
*/
|
|
254
|
+
const perSubtree = new Map();
|
|
204
255
|
const walk = (dir) => {
|
|
205
256
|
if (exhausted)
|
|
206
257
|
return;
|
|
@@ -212,6 +263,13 @@ function build(project, budgetLimit) {
|
|
|
212
263
|
void err; // unreadable or gone: not a finding, just not walkable
|
|
213
264
|
return;
|
|
214
265
|
}
|
|
266
|
+
// Count BEFORE the budget check, so the subtree that pushed the walk over
|
|
267
|
+
// is the one the finding names. Counting after would attribute the
|
|
268
|
+
// decisive read to nobody — the directory that exhausted the budget would
|
|
269
|
+
// be missing from the list of what exhausted it.
|
|
270
|
+
const rel = path.relative(root, dir).replaceAll('\\', '/');
|
|
271
|
+
const top = rel === '' ? '.' : (rel.split('/')[0] ?? '.');
|
|
272
|
+
perSubtree.set(top, (perSubtree.get(top) ?? 0) + entries.length);
|
|
215
273
|
budget -= entries.length;
|
|
216
274
|
if (budget < 0) {
|
|
217
275
|
exhausted = true;
|
|
@@ -250,6 +308,8 @@ function build(project, budgetLimit) {
|
|
|
250
308
|
walk(full);
|
|
251
309
|
}
|
|
252
310
|
else {
|
|
311
|
+
if (entry.isSymbolicLink())
|
|
312
|
+
kindUnknown.push(full);
|
|
253
313
|
everyFile.push(full);
|
|
254
314
|
if (TS_FILE.test(entry.name))
|
|
255
315
|
files.push(full);
|
|
@@ -257,8 +317,14 @@ function build(project, budgetLimit) {
|
|
|
257
317
|
}
|
|
258
318
|
};
|
|
259
319
|
walk(root.replaceAll('\\', '/'));
|
|
320
|
+
// NOT the shared `UNDETERMINED` constant. It is deliberately identity-free so
|
|
321
|
+
// it can be returned from the guards above, where there is nothing to say; a
|
|
322
|
+
// walk that gave up has something to say, and bug 0359 is that it said
|
|
323
|
+
// nothing. `classify` still answers `not-determined` for every glob — the
|
|
324
|
+
// classification is unchanged and still honest. What changes is that the
|
|
325
|
+
// caller can now discover WHY.
|
|
260
326
|
if (exhausted)
|
|
261
|
-
return
|
|
327
|
+
return exhaustedDiskSet(root, budgetLimit, perSubtree);
|
|
262
328
|
// Containment is TRANSITIVE, and that is load-bearing. Using each file's
|
|
263
329
|
// immediate parent instead labels `docs/` "contains no TypeScript" while
|
|
264
330
|
// `docs/.vitepress/config.ts` sits one level below it — a false statement in
|
|
@@ -299,10 +365,69 @@ function build(project, budgetLimit) {
|
|
|
299
365
|
const prefixes = [root, rootFromTsConfigPath(project.tsConfigPath)]
|
|
300
366
|
.filter((r) => r !== undefined)
|
|
301
367
|
.map((r) => (r === '/' ? '/' : `${r.replaceAll('\\', '/')}/`));
|
|
368
|
+
/**
|
|
369
|
+
* Does this glob reach ground the walk refused to enter?
|
|
370
|
+
*
|
|
371
|
+
* Shared by `classify` and `matchesOnlyFiles`, deliberately: both have to refuse to answer
|
|
372
|
+
* over a pruned path, and this module already records what happened the last time one fact
|
|
373
|
+
* grew two hand-maintained copies.
|
|
374
|
+
*/
|
|
375
|
+
const matchesPruned = (glob) => {
|
|
376
|
+
// Deliberately NOT guarded by `readsRootRelativePath`, unlike the two consumers below.
|
|
377
|
+
// Being liberal here makes this answer `true` more often, and `true` means "refuse to
|
|
378
|
+
// answer" — so the error direction is fail-closed. The guard exists to stop a liberal view
|
|
379
|
+
// manufacturing a false POSITIVE claim; this one manufactures a false abstention.
|
|
380
|
+
const isMatch = picomatch(glob);
|
|
381
|
+
return pruned.some((dir) => isMatch(dir) ||
|
|
382
|
+
namedFromARoot(dir).some((view) => isMatch(view)) ||
|
|
383
|
+
glob.includes(dir.slice(root.length + 1)));
|
|
384
|
+
};
|
|
302
385
|
const namedFromARoot = (candidate) => prefixes
|
|
303
386
|
.filter((prefix) => candidate.startsWith(prefix))
|
|
304
387
|
.map((prefix) => candidate.slice(prefix.length));
|
|
305
388
|
return {
|
|
389
|
+
/**
|
|
390
|
+
* Files yes, directories no — the kind-aware answer `classify` cannot give.
|
|
391
|
+
*
|
|
392
|
+
* Both root views, exactly as `classify` does: a single view left this answering about a
|
|
393
|
+
* monorepo package's `'src/**'` from the wrong prefix, which is bug 0339's shape in the
|
|
394
|
+
* one producer whose whole defence is that it states only facts.
|
|
395
|
+
*/
|
|
396
|
+
matchesOnlyFiles(glob) {
|
|
397
|
+
const isMatch = picomatch(glob);
|
|
398
|
+
// The SAME guard `classify` applies below, and for the same reason (bug 0339): the
|
|
399
|
+
// root-relative view is only consulted for a glob that actually reads root-relative
|
|
400
|
+
// paths. Applying it unconditionally made this predicate more liberal than `classify`
|
|
401
|
+
// about the same paths — two derivations of one question, which is the defect this whole
|
|
402
|
+
// change exists to remove. Product review flagged the asymmetry without constructing an
|
|
403
|
+
// input; mirroring the guard costs one line and removes the question.
|
|
404
|
+
const readsRootRelative = readsRootRelativePath(glob);
|
|
405
|
+
const hits = (candidates) => candidates.some((candidate) => {
|
|
406
|
+
if (isMatch(candidate))
|
|
407
|
+
return true;
|
|
408
|
+
if (!readsRootRelative)
|
|
409
|
+
return false;
|
|
410
|
+
return namedFromARoot(candidate).some((view) => isMatch(view));
|
|
411
|
+
});
|
|
412
|
+
// A directory match means the glob is usable as a `parent-dir` glob, whatever else it
|
|
413
|
+
// also matches — so this is "files and NO directory", not "more files than directories".
|
|
414
|
+
//
|
|
415
|
+
// And NOT SEEN IS NOT NOT THERE. A pruned entry is recorded before `isDirectory()` is
|
|
416
|
+
// asked, so it is in neither `dirs` nor `everyFile` — reading its absence from `dirs` as
|
|
417
|
+
// evidence of "no directory" is exactly the inference `classify` refuses ten lines below.
|
|
418
|
+
// Measured by enforcement review: a glob naming `.../dist/**`, a real directory holding
|
|
419
|
+
// real TypeScript, was told it "matches a FILE but is used where a directory is read"
|
|
420
|
+
// because `dist` is pruned. This claim is a universal negative; a bounded walk cannot
|
|
421
|
+
// earn one over ground it declined to look at.
|
|
422
|
+
// Two ways the walk cannot witness "no directory", and both must refuse rather than
|
|
423
|
+
// answer. Pruned: the entry was recorded before `isDirectory()` was asked, so it is in
|
|
424
|
+
// neither list. Symlinked: the kind was never resolved and the entry sits in `everyFile`
|
|
425
|
+
// looking like a file — measured, a symlinked directory holding TypeScript was told
|
|
426
|
+
// "this matches a FILE but is used where a directory is read".
|
|
427
|
+
if (matchesPruned(glob) || hits(kindUnknown))
|
|
428
|
+
return false;
|
|
429
|
+
return hits(everyFile) && !hits(dirs);
|
|
430
|
+
},
|
|
306
431
|
classify(glob) {
|
|
307
432
|
const isMatch = picomatch(glob);
|
|
308
433
|
// Both views of each path, as every rule-facing matcher does since bug
|
|
@@ -326,9 +451,7 @@ function build(project, budgetLimit) {
|
|
|
326
451
|
const matched = everything.filter((candidate) => hits(candidate));
|
|
327
452
|
if (matched.length === 0) {
|
|
328
453
|
// Not seen is not the same as not there.
|
|
329
|
-
return
|
|
330
|
-
? 'not-determined'
|
|
331
|
-
: 'absent';
|
|
454
|
+
return matchesPruned(glob) ? 'not-determined' : 'absent';
|
|
332
455
|
}
|
|
333
456
|
// Per GLOB, not per path: one glob routinely matches paths in both
|
|
334
457
|
// categories — `**/tests/**` matched 44 directories of mixed kind on the
|
|
@@ -342,5 +465,38 @@ function build(project, budgetLimit) {
|
|
|
342
465
|
}
|
|
343
466
|
const UNDETERMINED = {
|
|
344
467
|
classify: () => 'not-determined',
|
|
468
|
+
// Not "no files" — "no evidence". The caller must not read a confident shape out of a
|
|
469
|
+
// walk that did not happen.
|
|
470
|
+
matchesOnlyFiles: () => false,
|
|
345
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* How many consuming directories the exhaustion finding names.
|
|
474
|
+
*
|
|
475
|
+
* Four, not all of them: the finding is a sentence an agent acts on, and a list
|
|
476
|
+
* of forty directories is the ADR-009 rule 4 noise problem moved inside one
|
|
477
|
+
* message. Four was enough to cover 91% of this repository's entries when
|
|
478
|
+
* measured (spike 0368), and the total is reported alongside so the reader can
|
|
479
|
+
* tell a dominated walk from an evenly-spread one.
|
|
480
|
+
*/
|
|
481
|
+
export const NAMED_CONSUMERS = 4;
|
|
482
|
+
/**
|
|
483
|
+
* The walk gave up, and says what it read.
|
|
484
|
+
*
|
|
485
|
+
* Its own object rather than the shared `UNDETERMINED`, because the consumers
|
|
486
|
+
* differ per project and a shared constant cannot carry them.
|
|
487
|
+
*/
|
|
488
|
+
function exhaustedDiskSet(root, budget, perSubtree) {
|
|
489
|
+
const consumers = [...perSubtree]
|
|
490
|
+
.map(([dir, entries]) => ({ dir, entries }))
|
|
491
|
+
// NOT `localeCompare`: this order decides which directories the message names,
|
|
492
|
+
// the message reaches a baseline identity, and the host locale would make the
|
|
493
|
+
// same finding hash differently on a laptop and in CI. The repo's own
|
|
494
|
+
// `scan-locale-ordering` gate caught this.
|
|
495
|
+
.sort((a, b) => b.entries - a.entries || byCodepoint(a.dir, b.dir));
|
|
496
|
+
return {
|
|
497
|
+
classify: () => 'not-determined',
|
|
498
|
+
matchesOnlyFiles: () => false,
|
|
499
|
+
exhaustion: { root, budget, consumers },
|
|
500
|
+
};
|
|
501
|
+
}
|
|
346
502
|
//# sourceMappingURL=disk-set.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disk-set.js","sourceRoot":"","sources":["../../src/core/disk-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"disk-set.js","sourceRoot":"","sources":["../../src/core/disk-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC7E,OAAO,EAAE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AC;QAC5C,+EAA+E;QAC/E,8EAA8E;QAC9E,sEAAsE;QACtE,2CAA2C;SAC1C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACrE,OAAO;QACL,QAAQ,EAAE,GAAG,EAAE,CAAC,gBAAgB;QAChC,gBAAgB,EAAE,GAAG,EAAE,CAAC,KAAK;QAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE;KACxC,CAAA;AACH,CAAC"}
|
|
@@ -60,22 +60,56 @@ export declare function syntacticFault(glob: string, kind: GlobSite['kind'], bas
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function diagnoseGlob(site: GlobSite, universe: PathUniverse, diskSet?: DiskSet): GlobDiagnosis;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
63
|
+
* WHY a dead site on a cardinality rule is a real fault — the route, not a boolean.
|
|
64
|
+
*
|
|
65
|
+
* One owner, consulted by the admission gate AND by both tools' messages, so the reason a
|
|
66
|
+
* finding was admitted and the reason its message gives cannot be two different derivations.
|
|
67
|
+
* Before this, the gate asked `classify(glob)` directly while the message read
|
|
68
|
+
* `diagnosis.onDisk`, and the two disagree for `file-not-folder`: the gate admitted the
|
|
69
|
+
* finding *because the disk contradicted the claim* and the message then offered to widen a
|
|
70
|
+
* tsconfig `include`, which can never make a glob naming a FILE match a directory read
|
|
71
|
+
* ([bug 0363](../../../../work/bugs/fixed/0363-a-remedy-that-cannot-remediate-survives-one-input-over.md)).
|
|
72
|
+
*
|
|
73
|
+
* `undefined` means "not a fault" — a holding ratchet, which is the common case and must stay
|
|
74
|
+
* green. Exhaustive over `GlobFault` **by the `never` witness in the default branch**, not by
|
|
75
|
+
* the shape of the switch — a distinction that was got wrong here and measured by architecture
|
|
76
|
+
* review. Because `undefined` is a legal return value, a switch missing a case falls off the end
|
|
77
|
+
* and **compiles**, so a fifth fault became silently "not a fault"; the module reddened at
|
|
78
|
+
* `FAULT_ADVICE` instead, a different line with a different fix. `isFaultPosition`
|
|
79
|
+
* (`packages/core/src/glob-site.ts:86`) carries the same witness for the same reason.
|
|
80
|
+
*
|
|
81
|
+
* _`contradictsAbsence` was cited here as a model and should not have been: it also compiles
|
|
82
|
+
* clean against a fifth `OnDisk`. What is exhaustive there is the TEST enumerating the union,
|
|
83
|
+
* not the function._
|
|
65
84
|
*/
|
|
85
|
+
export type DeadSiteRoute = 'syntactic' | 'names-a-file' | 'contradicted-by-disk';
|
|
86
|
+
export declare function deadSiteRoute(diagnosis: GlobDiagnosis): DeadSiteRoute | undefined;
|
|
66
87
|
/**
|
|
67
|
-
*
|
|
88
|
+
* The remedy a CARDINALITY rule gets on each route, owned once.
|
|
89
|
+
*
|
|
90
|
+
* `check` puts this in `suggestion` (the `Fix:` line) and `doctor` appends it to its own
|
|
91
|
+
* advice, so the two cannot drift — which is
|
|
92
|
+
* [bug 0364](../../../../work/bugs/fixed/0364-doctor-states-the-cause-and-never-the-remedy.md):
|
|
93
|
+
* three rounds of work on what this sentence must say reached only the tool an adopter
|
|
94
|
+
* reaches second.
|
|
68
95
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
* **None of them offers deletion.** On a finding no filter can suppress, deletion is the only
|
|
97
|
+
* achievable exit, and the rule is the thing that noticed — so an instruction to delete it is
|
|
98
|
+
* the ADR-009 rule 2 defect this family has already shipped once.
|
|
99
|
+
*/
|
|
100
|
+
export declare const CARDINALITY_REMEDY: Readonly<Record<DeadSiteRoute, string>>;
|
|
101
|
+
/**
|
|
102
|
+
* Does the route's fault hold in EVERY project, or only in this one?
|
|
74
103
|
*
|
|
75
|
-
*
|
|
76
|
-
* `
|
|
104
|
+
* A property of the glob text for the syntactic and file-naming routes, and of this project's
|
|
105
|
+
* `include` for the disk route. "in this project" understates the first two by exactly the
|
|
106
|
+
* scope that invites a tsconfig reading.
|
|
107
|
+
*/
|
|
108
|
+
export declare const ROUTE_HOLDS_IN_ANY_PROJECT: Readonly<Record<DeadSiteRoute, boolean>>;
|
|
109
|
+
/**
|
|
110
|
+
* The remedy for each fault, or an honest list of causes where no remedy is
|
|
111
|
+
* verifiable.
|
|
77
112
|
*/
|
|
78
|
-
export declare function isSyntacticFault(fault: GlobFault): boolean;
|
|
79
113
|
export declare const FAULT_ADVICE: Readonly<Record<GlobFault, string>>;
|
|
80
114
|
/**
|
|
81
115
|
* What the filesystem adds, when it adds anything.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glob-diagnosis.d.ts","sourceRoot":"","sources":["../../src/core/glob-diagnosis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"glob-diagnosis.d.ts","sourceRoot":"","sources":["../../src/core/glob-diagnosis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGpD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,YAAY,GAAG,iBAAiB,GAAG,UAAU,CAAA;AAErF,UAAU,aAAa;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,2EAA2E;AAC3E,eA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