@cosyte/terminology 0.0.9 → 0.0.10

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 CHANGED
@@ -9,6 +9,266 @@ this file is maintained by hand (Changesets handles the version bump and publish
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ### Fixed
13
+
14
+ - **The PHI scan had NO observation rule at all, so the all-mode sweep reported clean over a scan
15
+ root it never opened (`PHI-SCAN-OBSERVED-NOTHING-IS-GLOBAL`).** Development tooling only:
16
+ `scripts/phi-scan.ts` ships in no tarball, and the public surface, build output and runtime
17
+ behaviour are unchanged. `pnpm phi-scan` with no arguments is what CI runs. It walked two roots,
18
+ `test/fixtures` and `src`, and refused nothing on the strength of what it had read — not the
19
+ global "observed zero files in total" rule the siblings carried, but no rule of any kind.
20
+
21
+ **The starved state was LIVE here, not hypothetical.** `test/fixtures` has never existed in this
22
+ repository (`git log -- test/fixtures` is empty; every test is inline TypeScript and
23
+ `find test -type f -not -name '*.ts'` returns nothing; the throwaway-repo helper in
24
+ `test/scripts/phi-scan.test.ts` has only ever created `scripts/` and `src/`), so one of the two
25
+ declared roots was unopened on every run this gate has ever made. **Reproduced on `0fe4b84` on a
26
+ clone, three ways**, each printing `[phi-scan] OK — no hits` and exiting **0**: `src` moved aside,
27
+ `src` replaced by a **dangling symlink** — each leaving all 39 source files unread — and the
28
+ fixture root, which needed no manipulation at all.
29
+
30
+ **The dangling case is the sharpest, and nothing else in the scanner can see it.** `existsSync`
31
+ **follows** the link and answers false, so `walk()` returns before `readdirSync` and the
32
+ not-a-regular-file refusal never fires: that rule only classifies entries found **inside** a root,
33
+ and this is the root itself. Absent, dangling and empty are one state to the walk. **This reporter
34
+ prints no denominator either** — `report` writes `OK — no hits` and no file count — so nothing on
35
+ stdout looked wrong. Adding a count would be a real improvement and is **not** part of this
36
+ change.
37
+
38
+ **The rule is now per-root.** All-mode refuses (exit **2**) unless **every** declared root yielded
39
+ at least one file that was actually read, and the refusal names the starved roots. It is written
40
+ per-root rather than in the global form the siblings started from, so that shape — one surviving
41
+ file vouching for every other root — cannot arrive along with the second root.
42
+
43
+ **`test/fixtures` is no longer declared as a walk root, and its removal is not a narrowing.** If
44
+ readable, non-ignored content arrives there, all-mode **refuses** (exit 2) and names the
45
+ declaration rather than reporting clean over content nothing walks. **That refusal fires only
46
+ where the remedy it prints would help.** It uses the two predicates the walk already has:
47
+ `rootOf`, so declaring the path silences it by construction, and a content test mirroring the
48
+ walk's own rules, so an **empty** `test/fixtures`, a **markdown-only** one (the walk skips
49
+ markdown) and a **gitignored** one are all left alone at exit 0, exactly as before this change. An
50
+ `existsSync`-only guard refused over all three and kept refusing after the printed remedy was
51
+ followed — a gate that cannot be satisfied — and it invented a second, stricter gitignore boundary
52
+ beside the single one this file keeps. **Two exceptions are recorded rather than papered over**,
53
+ both counting as content because a scan that cannot account for something must not report clean: a
54
+ path the walk cannot list, where declaring it exits 1; and a path holding only a non-regular
55
+ entry, where declaring it lands on the not-a-regular-entry refusal at exit 2. Both behave the same
56
+ before this change, so neither is a regression. The `--staged` predicate is deliberately
57
+ untouched and still enumerates `test/fixtures/**` and that path's own name, so the pre-commit
58
+ route is unchanged in both directions.
59
+
60
+ **The STARVATION refusal never swallows a finding.** Hits from the roots that DID yield are
61
+ printed before it, and the exit code is still 2. That is scoped to the starvation branch and no
62
+ wider: the reappearing-corpus refusal, like the not-a-regular-entry and unmerged refusals beside
63
+ it, throws out of `buildTargetsForAll` before anything is scanned and so reports nothing found on
64
+ the way — fail-closed, and unchanged in that respect. With one root declared, starved means an empty target list, so that
65
+ line is unreachable from this repository's own configuration — it is therefore exercised against a
66
+ copy of the scanner with a second root declared, rather than shipped as an untested promise, which
67
+ is exactly how the defect being fixed here survived.
68
+
69
+ **Deliberately unchanged:** `--staged` and named-path mode make no per-root promise, because
70
+ neither enumerates a root. Both boundaries are pinned, and widening the rule to them was run as a
71
+ mutation rather than argued — dropping the mode guard reds 10 cases; removing the per-root rule
72
+ reds 4; removing the reappearing-corpus refusal reds 3; removing the print-hits-first line reds 1;
73
+ emptying `SCAN_ROOTS` reds 14.
74
+
75
+ **The granularity is the declared root and nothing finer, which is a real bound, not a slogan.**
76
+ Four states are still not refused, each measured **with** the rule in place, each now in the
77
+ scanner's own limits list with the command that produced it and each pinned by a characterization
78
+ test: a directory missing from **inside** a root (`mv src/ucum ..` still prints `OK — no hits`
79
+ with 6 sources unread, while a planted violator in it exits 1 with it present); a root that is
80
+ **itself a symlink** to a directory, which is followed, so the rule is satisfied by whatever is on
81
+ the other side; the floor is **one** file, whatever the root used to hold; and **any directory the
82
+ walk cannot list** exits **1** — the code this gate reserves for hits — because `walk()` does not
83
+ wrap `readdirSync` and the error reaches node's default handler with a v8 stack trace in place of
84
+ the scanner's own diagnostic. That last one is **not only about roots**: measured as `ENOTDIR` on
85
+ a root that is a regular file and on a root linking to one, and as `EACCES` on a `chmod 000`
86
+ directory at depth with the per-root rule otherwise satisfied. **It is CLOSED in the sibling this
87
+ rule was ported from and OPEN here**, and it is recorded so it is not ported back out as though it
88
+ were fixed; it belongs to the separate exit-code work.
89
+
90
+ **Two more bounds are recorded so none of the above reads as completeness, and both are
91
+ `PRE-EXISTING`.** The reappearing-corpus refusal sees only what `existsSync` can resolve: silent
92
+ on a dangling link, which is deliberate because a dangling link holds no corpus, but also silent
93
+ when a real corpus sits behind a directory that cannot be traversed (`chmod 000 test` with
94
+ `test/fixtures/leak.txt` present — measured, and identical before this change). And **all-mode
95
+ walks `src` and nothing else**, so the observation rule can be fully satisfied while every tracked
96
+ file under `test/` goes unread: measured back to back, `pnpm phi-scan` clean at exit 0 while
97
+ naming a file under `test/` directly returns hits at exit 1 over the same bytes
98
+ (`PHI-SCAN-WALK-ROOT-SCOPE`). Widening the walk is separate work with its own two-sided trap,
99
+ because this floor is SSN/email only.
100
+
101
+ Tests were added on throwaway repositories only, so no starved root, no dangling link and no
102
+ violator is ever written into the committed corpus. **No count of them is recorded here**: one
103
+ was, it was correct when written, two more cases were added in the same slice, and it was then
104
+ wrong. Several are red against the superseded scanner — every case asserting one of the new
105
+ refusals — and one is an explicit **anti-vacuity** control asserting the starved corpus really did
106
+ hold a detectable hit, because a starvation test over an empty corpus proves exactly nothing,
107
+ which is the defect itself.
108
+
109
+ - **The PHI commit-gate's `--staged` route was blind to a staged RENAME or COPY, so an ordinary
110
+ `git mv` into a scan root printed its clean line and exited 0 at pre-commit**
111
+ (`PHI-SCAN-RENAME-BLIND-AT-PRECOMMIT`). Development tooling only: `scripts/phi-scan.ts` ships in
112
+ no tarball, and the public surface, build output and runtime behaviour are unchanged.
113
+
114
+ **The hole.** Rename detection is on by git's default, and `git diff --cached --raw
115
+ --diff-filter=AMT` returns neither `R` (rename) nor `C` (copy). So `git mv <tracked link>
116
+ test/fixtures/<name>` staged as `:120000 120000 <sha> <sha> R100` with **two** paths and the
117
+ status filter deleted the record outright: measured on git 2.39.5 in a throwaway repository, the
118
+ index held a mode-120000 entry under a scan root and `pnpm phi-scan --staged` reported clean. It
119
+ was never only a **mode** gap. A rename that also SUBSTITUTES a real-looking value into the moved
120
+ file passed identically, measured at mode 100644, while naming the same destination
121
+ directly returned a hit. The gap was at **pre-commit**, where `simple-git-hooks` runs
122
+ `pnpm phi-scan --staged`; the all-mode sweep is the backstop and saw both.
123
+
124
+ **The remedy is `--no-renames`, with no record-stride work.** With detection off git emits no `R`
125
+ and no `C` at all: the destination arrives as an ordinary single-path `A` and the source as a `D`
126
+ the filter already drops. **This route's own previous disclosure — that admitting `R`/`C` needed
127
+ the two-path record shape handled, "which is a scope decision" — was measured FALSE and is
128
+ withdrawn in place rather than deleted, because it shipped.** Verified under
129
+ `diff.renames=true|copies|false|1` with `diff.renameLimit=1`: every one yields the same
130
+ single-path records, so the two-field stride is STRUCTURAL rather than conditional on the caller's
131
+ configuration. **State the relation exactly, and SCOPE it. Of `--no-renames` alone, holding the
132
+ rest of the argv fixed: the new enumeration CONTAINS the old one — EQUAL whenever git emitted no
133
+ `R` and no `C`, larger only when it did.** It is a superset, not a strictly larger set. **That
134
+ equality is NOT a claim about the route as a whole** — the whole-argv change also adds the
135
+ unmerged and gitlink records below, so on an index holding an unmerged path the two enumerations
136
+ differ while git emitted no `R` and no `C` at all. The corollary, because it is easy to misread as "nobody was affected": a
137
+ caller who had already set `diff.renames=false` was covered before this, and everybody on git's
138
+ default was not.
139
+
140
+ **The `C` half is real and no rename fixture reaches it.** Under `diff.renames=copies`, copying an
141
+ out-of-scope file carrying the same payload INTO a scan root stages as a genuine `C100` two-path
142
+ record and was dropped identically: exit 0 before, exit 1 after. One precondition, recorded because
143
+ it is easy to state too broadly: configuration-only copy detection also needs the copy SOURCE
144
+ modified in the same staged diff, or git finds no copy source, the record arrives as an ordinary
145
+ `A` that even the previous argv enumerated, and the fixture proves nothing.
146
+
147
+ **Three further enumeration holes in the same route, each measured open here rather than assumed.**
148
+ An index entry at exactly `test/fixtures` or exactly `src` escaped a prefix test that required the
149
+ trailing slash (exit 0 over a staged mode-120000 entry at each), so a whole scan root replaced by a
150
+ link went unjudged — **the one ADDITION to this route's path scope in this change, named as an
151
+ addition rather than filed under narrowing.** `diff.ignoreSubmodules=all` ERASED a staged gitlink
152
+ from the enumeration entirely, so a refusal the route already had never fired (exit 2 on the
153
+ default, exit 0 with that config, same index); closed by `--ignore-submodules=none`, the same
154
+ remedy family. And an UNMERGED path was returned by neither `AM` nor `AMT`, so a conflicted
155
+ in-scope path made the route report clean over an index it structurally cannot read; it is now
156
+ enumerated so it can be REFUSED. **`U` is closed by a DIFFERENT mechanism and the two must not be
157
+ conflated: by being in `--diff-filter=AMTU`, not by `--no-renames`.** Git itself refuses to commit
158
+ while a path is unmerged, so that one was never a route to a committed leak; what it was is the
159
+ gate attesting clean over a state it never observed.
160
+
161
+ **One refusal message was false and is corrected, not softened.** It asserted that `git show
162
+ :<path>` "hands back its target path rather than any content", which holds only for mode 120000;
163
+ on a staged gitlink it fails outright, and the same sentence was emitted for gitlinks and for the
164
+ mode fallback. It now says what the INDEX holds instead of what `git show` would answer.
165
+
166
+ **Twelve cases added**, most of them asserting git's own premise before the scanner's behaviour,
167
+ because the remedy rests on what git emits. Eight run red against the previous scanner; the other four
168
+ are the configuration sweep, two flag-coupling premises and an out-of-scope control, green on both
169
+ by design. **The argv coupling is pinned, and a first draft of this entry had half of it BACKWARDS.**
170
+ `-M`, `-C` and `--find-copies-harder` each turn detection back on over the top of `--no-renames`
171
+ and empty the route again; `--find-copies-harder` does so in EITHER order, so nothing here says a
172
+ later `--no-renames` undoes them. **`-B` IS NOT INERT, AND CALLING IT SO WAS THE PERMISSIVE HALF OF
173
+ A STANDING DIRECTIVE.** That reading came from a rename stage, the one stage where `-B` does
174
+ nothing. On a COMPLETE REWRITE `-B` breaks the pairing, the `--diff-filter` letter is `B` and not
175
+ `M`, `AMTU` drops the record outright, and the gate reports clean over a staged dashed SSN
176
+ (measured, same index: exit 1 without the flag, exit 0 with it). It empties this route through the
177
+ status FILTER rather than by re-enabling detection — a different mechanism, the same answer: do not
178
+ add it. Corrected in place rather than deleted, because an "inert" reading is exactly what gets
179
+ ported onward, and a case now pins it. That case guards GIT's premise rather than the scanner's argv, so it does not by
180
+ itself fail if someone adds `-M` to the scanner; the suite as a whole does. **Every flag is
181
+ counterfactually measured against the final suite of 34:** injecting `-M` reds 2 cases, `-C` reds
182
+ 3, `--find-copies-harder` reds 3 and `-B` reds 1; removing `--ignore-submodules=none` reds 1, and
183
+ dropping `U` from the filter reds 1. Before the `-B` case was added, injecting `-B` red nothing,
184
+ which is how the false "inert" claim survived a first pass. Every case builds a
185
+ throwaway git repository, so no rename, copy, conflict or violator enters the committed corpus.
186
+ **No case runs `git merge`:** it resolves the COMMITTER IDENTITY up front and exits 128 before
187
+ merging anything when it cannot find one, which passes on a developer's box and fails on a runner,
188
+ so the unmerged fixtures are built with `git update-index --index-info` against an index state —
189
+ what this route actually reads, and `git status` still reports `UU`. The suite was re-run under
190
+ `env -i` with no discoverable git identity: 34 pass.
191
+
192
+ **Measured and deliberately NOT closed here, both PRE-EXISTING and identical before this change.**
193
+ With a scan root replaced by a link to a regular file the all-mode walk raises an uncaught
194
+ `ENOTDIR` and exits **1**, a code this contract reserves for HITS, with a stack trace in place of
195
+ the scanner's own diagnostic; a missing allow-list throws out of the same route the same way. Both
196
+ are fail-closed rather than silent, and belong to the separate exit-code work. And one property
197
+ that is newly true rather than unchanged, because such a blob was previously out of scope
198
+ entirely: a
199
+ regular blob staged at exactly a scan root is scanned at the SAME tier as one under it, which is
200
+ true **here** only because `scanTarget` has one tier — the SSN/email floor — and keys on nothing
201
+ about the path. Implementing the fenced TODO section with a path-keyed dispatch would break that,
202
+ and a case now says so.
203
+
204
+ - **Nothing pinned that the publish gate FORWARDS `--no-definitely-typed`, so a gate that accepted
205
+ the flag and then dropped it would have looked exactly like one that forwards it**
206
+ (`TERMINOLOGY-ATTW-FORWARDING-UNPINNED`). Development tooling only: `scripts/attw.mjs` ships in no
207
+ tarball, and the public surface, build output and runtime behaviour are unchanged. No executable
208
+ line of the gate moved; the only edit to that file is one docblock paragraph.
209
+
210
+ **The gap was structural, not one forgotten assertion.** Every case in
211
+ `test/scripts/attw-gate.test.ts` passes `--no-definitely-typed`, to keep the gate off the network,
212
+ so the flag rode along on every run and no assertion ever depended on it arriving. The allow-list
213
+ covered the acceptance half incidentally, since removing the flag from it kills every other case at
214
+ the argument guard; the forwarding half was covered by nothing at all. The one test whose name said
215
+ otherwise, `"forwards the two arguments it does accept"`, measured `--profile` alone, and its name
216
+ is corrected here rather than left overclaiming.
217
+
218
+ **`attw` itself cannot settle it, which is why the answer is a shim.** The CLI reports on a packed
219
+ tarball, never on its own arguments, and on the `--pack` path this gate always takes the flag
220
+ suppresses a DefinitelyTyped lookup that is never made. Inert means unobservable: accepting the
221
+ flag and dropping it produces byte-identical output to forwarding it. The pin therefore runs this
222
+ repo's own `scripts/attw.mjs` against a fixture package whose `node_modules/.bin/attw` prints the
223
+ argv it was handed. The wrapper resolves its binary beside its own file rather than from the
224
+ working directory, so the probe needs its own copy of the script, and the suite asserts that copy
225
+ is byte-identical to the real one instead of trusting it.
226
+
227
+ **The negative controls are the load-bearing half, and they are committed rather than merely run.**
228
+ A test that would pass whether or not the flag is forwarded proves nothing. Given no arguments the
229
+ shim must see `--pack .` and nothing else, which reds a gate that hard-codes the flag into its own
230
+ spawn, which a positive assertion alone cannot tell apart. A second control
231
+ asserts that a refused argument never reaches the shim at all; that one sharpens the existing
232
+ refusal cases rather than catching anything they miss.
233
+
234
+ **Three counterfactuals were run against the real script, over the whole of
235
+ `test/scripts/attw-gate.test.ts` rather than the new block alone.** Dropping the forwarding reds
236
+ three cases, the new positive pin among them, and leaves both new controls green. Hard-coding the
237
+ flag into the spawn and discarding the argv also reds three, but the pairing is what matters: the
238
+ positive pin stays GREEN while the bare-`--pack .` control reds. That is the precise failure this
239
+ change exists to make visible.
240
+ Bypassing the allow-list so the whole argv is forwarded reds eighteen, of which seventeen are
241
+ refusal cases that were here already; the new refusal control is the eighteenth and adds only "and
242
+ `attw` never saw it". **So that control sharpens an existing guard rather than being what stops a
243
+ forward-everything gate from passing**, and it is recorded that way instead of being credited with
244
+ the catch.
245
+
246
+ **Unchanged, and not claimed to be closed: the `.attw.json` route.** `readConfig()` applies a
247
+ committed config file after argv and sets an option value for every key it carries, so a config
248
+ file wins regardless of the argument allow-list and no argv-level pin can reach it. This change
249
+ narrows nothing there, and the gate's docblock keeps stating it as the known limit it is.
250
+
251
+ ## Released, pending a per-version split
252
+
253
+ > **Everything between this heading and `[0.0.1]` has already SHIPPED.** It accumulated under
254
+ > `[Unreleased]` across the releases from `0.0.2` through `0.0.9`, because this file is maintained by
255
+ > hand and the Changesets changelog generator is off (`"changelog": false` in
256
+ > `.changeset/config.json`), so no release run ever moved an entry out of that section. Reading any
257
+ > of it as work still awaiting a release was wrong, which is why the heading changed and the entries
258
+ > did not.
259
+ >
260
+ > **What is deliberately NOT done here, and is tracked as `TERMINOLOGY-CHANGELOG-GAP`:** splitting
261
+ > this into one `## [x.y.z]` section per published version, and the founder-owned question of whether
262
+ > to turn the generator on across the repos that share this layout. No version from `0.0.2` to
263
+ > `0.0.9` has a section of its own below, and none has a compare link. The `[Unreleased]` link at the
264
+ > foot of this file now spans `v0.0.9...HEAD`, which is what that section actually holds; it spanned
265
+ > `v0.0.1...HEAD` while this block was mislabelled.
266
+ >
267
+ > **`0.0.3` never reached npm, and LEAVING it that way is the deliberate part.** The gap itself was
268
+ > a consequence, not a choice: a leftover changeset meant that release run only opened the next
269
+ > version PR, and the content shipped in `0.0.4`. It is not a hole to be filled, because publishing a
270
+ > `0.0.3` now would place it after `0.0.4` in registry order.
271
+
12
272
  ### Changed
13
273
 
14
274
  - **Breaking: `ExpansionDiagnostic.system` is replaced by `ExpansionDiagnostic.path`.** The field
@@ -177,7 +437,11 @@ this file is maintained by hand (Changesets handles the version bump and publish
177
437
  still **not** enumerated by `--staged` at all, so a staged rename that also appends PHI passes that
178
438
  route — pre-existing, unchanged here, and admitting it needs the two-path record shape handled,
179
439
  which is a scope decision rather than this one; CI's all-mode sweep does read the resulting
180
- worktree file. A tracked file **absent from the worktree** is still caught at `git add` time only.
440
+ worktree file. **[Superseded — see the `[Unreleased]` entry above. `R`/`C` ARE now enumerated, and
441
+ the reason given here for deferring them — that it needs the two-path record shape handled, "which
442
+ is a scope decision" — was MEASURED FALSE: `--no-renames` closes it with no stride work. This
443
+ sentence is left standing rather than rewritten because it shipped, and because it is the sentence
444
+ this repo exported to the ecosystem backlog and to sibling repos.]** A tracked file **absent from the worktree** is still caught at `git add` time only.
181
445
  And the scanner still has no tolerance for a file that vanishes between enumeration and read, so an
182
446
  untracked transient appearing under a walk root can still refuse a whole sweep; that is a different
183
447
  defect, it fails closed, and it is not addressed here.
@@ -1058,5 +1322,5 @@ ladder (`0.0.x` until first alpha).
1058
1322
  `WARNING_CODES` entry, and the parse-oriented option/warning types). This package is an engine, not
1059
1323
  a parser; that placeholder surface never shipped.
1060
1324
 
1061
- [Unreleased]: https://github.com/cosyte/terminology/compare/v0.0.1...HEAD
1325
+ [Unreleased]: https://github.com/cosyte/terminology/compare/v0.0.9...HEAD
1062
1326
  [0.0.1]: https://github.com/cosyte/terminology/releases/tag/v0.0.1
package/dist/index.cjs CHANGED
@@ -4776,7 +4776,7 @@ function approximateMatch(graph, query, options = {}) {
4776
4776
  }
4777
4777
 
4778
4778
  // src/index.ts
4779
- var VERSION = "0.0.9";
4779
+ var VERSION = "0.0.10";
4780
4780
 
4781
4781
  exports.COMPLEX_MAP_SOURCE_SYSTEM = COMPLEX_MAP_SOURCE_SYSTEM;
4782
4782
  exports.DIAGNOSTIC_CODES = DIAGNOSTIC_CODES;