@hublo/sentinel 1.7.0-alpha.7 → 1.7.0-alpha.8

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.
@@ -6,7 +6,7 @@ import {
6
6
  readNxProjectName,
7
7
  readOwnPackage,
8
8
  readProjectPackageJson
9
- } from "./chunk-ZNANJEMK.js";
9
+ } from "./chunk-JT7ZMH44.js";
10
10
  import {
11
11
  matchesTsconfigPattern
12
12
  } from "./chunk-O7REVMOC.js";
@@ -9956,20 +9956,19 @@ function fromWorkspaceRoot(moduleDir, options, paths) {
9956
9956
  }
9957
9957
 
9958
9958
  export {
9959
- BaseAdapter,
9960
9959
  moduleScripts,
9961
9960
  selfCommand,
9962
9961
  adoptedPackageName,
9963
9962
  manifestOperation,
9964
9963
  projectTargets,
9965
- nxTargetOperations,
9966
- RESOLVABLE_EXTENSIONS,
9964
+ BaseAdapter,
9967
9965
  splitToolArgs,
9968
9966
  separateToolArgs,
9969
9967
  resolveBin,
9970
9968
  binFromOwnInstall,
9971
9969
  binSearchPath,
9972
9970
  scriptPath,
9971
+ nxTargetOperations,
9973
9972
  FORMAT_CONFIG_FILE,
9974
9973
  FORMAT_SCRIPT_NAME,
9975
9974
  PROVENANCE_KEY,
@@ -10025,7 +10024,9 @@ export {
10025
10024
  oxlintPath,
10026
10025
  oxlintSearchPath,
10027
10026
  walk,
10027
+ MEMBER_TYPES,
10028
10028
  writtenFileFormatter,
10029
+ RESOLVABLE_EXTENSIONS,
10029
10030
  readTestAdoption,
10030
10031
  resolveContext,
10031
10032
  moduleEnvironment,
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ declare function registerAdapters(): void;
32
32
  declare const VERBS: readonly ["run", "inspect", "init", "migrate", "validate", "report", "status"];
33
33
  type Verb = (typeof VERBS)[number];
34
34
  /** Targets: the kind of check. The CLI `--<target>` flags map 1:1 to these. */
35
- declare const TARGETS: readonly ["lint", "format", "typescript", "build", "dev", "test", "static-analysis", "env", "runtime-analysis", "arch"];
35
+ declare const TARGETS: readonly ["lint", "format", "typescript", "build", "dev", "test", "static-analysis", "sql", "env", "runtime-analysis", "arch"];
36
36
  type Target = (typeof TARGETS)[number];
37
37
  /** Presets: the stack preset a project resolves to (strict by default). */
38
38
  declare const PRESET_NAMES: readonly ["react", "nest", "svelte", "node", "tools"];
package/dist/index.js CHANGED
@@ -6,12 +6,14 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-NSILXJWF.js";
9
+ } from "./chunk-VZZ3DOC3.js";
10
10
  import {
11
11
  BaseAdapter
12
- } from "./chunk-2LLRSWG2.js";
13
- import "./chunk-ZNANJEMK.js";
14
- import "./chunk-7E6YTTAK.js";
12
+ } from "./chunk-ZASD5YPF.js";
13
+ import "./chunk-JT7ZMH44.js";
14
+ import "./chunk-LX7EG6PJ.js";
15
+ import "./chunk-LU4E4TVD.js";
16
+ import "./chunk-PXTU5MPW.js";
15
17
  import "./chunk-4EIY7TTR.js";
16
18
  import "./chunk-O7REVMOC.js";
17
19
  import "./chunk-QXFCZON7.js";
@@ -0,0 +1,68 @@
1
+ /** A rule's level. `off` is a module's decision, and the report prints it as one. */
2
+ type Severity = 'off' | 'warn' | 'error';
3
+ interface SqlDefaults {
4
+ /** The migration files squawk reads, as globs relative to the module. */
5
+ migrations: {
6
+ /**
7
+ * ⛔ `migration.sql` BY NAME, and that is what keeps the rollback scripts out. Beside the 871
8
+ * migrations sit 385 `down.sql`, 2 `drop.sql` and one `donw.sql`: scripts a human runs by hand,
9
+ * which Prisma never applies. Reading them would report every `DROP` they are made of, for a
10
+ * file that never reaches production through a deploy. Naming the file Prisma applies, rather
11
+ * than excluding the others, also keeps out the misspelling nobody would think to exclude.
12
+ */
13
+ include: string[];
14
+ /** Migrations a module chooses not to read. Empty by default. */
15
+ exclude: string[];
16
+ };
17
+ /** What the `Unsafe` rule reads. */
18
+ unsafe: {
19
+ /**
20
+ * Read the tests too. ON by default: 203 of the 226 `Unsafe` calls are in tests, and a call
21
+ * that is safe today is not safe by construction tomorrow. A module that decides otherwise sets
22
+ * it to false, and the report says so; the decision is the team's.
23
+ */
24
+ includeTests: boolean;
25
+ /**
26
+ * What counts as a test, by PATH. Measured on the monorepo before it was written: the filter
27
+ * `*.spec.*` alone let 149 test calls through as production, because `*.integration-spec.ts`,
28
+ * `*.steps.ts`, `tests/database/` and `*.test-util.ts` are all test code and none of them
29
+ * matches it.
30
+ */
31
+ tests: string[];
32
+ };
33
+ /** Directories never read, whatever the includes say. */
34
+ ignore: string[];
35
+ /**
36
+ * The PostgreSQL version squawk checks against, since some rules depend on it.
37
+ *
38
+ * 16.8 is the version the monorepo pins (`postgres:16.8`, in its integration tests and its
39
+ * database tooling). The role reads what the repository declares and never asks production.
40
+ */
41
+ pgVersion: string;
42
+ /**
43
+ * Each rule's level, by name. Empty means every rule at its default, `warn` in this version: the
44
+ * role refuses nothing while its adoption runs.
45
+ */
46
+ rules: Record<string, Severity>;
47
+ }
48
+
49
+ type DeepPartial<T> = {
50
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
51
+ };
52
+ /** What a module's config file passes. Everything is optional, including the file itself. */
53
+ interface SqlInput {
54
+ /** The module's own directory, normally `import.meta.dirname`. */
55
+ root?: string;
56
+ /** The seam. Replaces whatever it names, and every path it sets lands in `moved`. */
57
+ overrides?: DeepPartial<SqlDefaults>;
58
+ }
59
+ interface ResolvedSqlConfig extends SqlDefaults {
60
+ /** The module's directory, or null when its config file did not say. */
61
+ root: string | null;
62
+ /** Dotted paths the module set through `overrides`, sorted so two runs print the same report. */
63
+ moved: string[];
64
+ }
65
+ /** Resolve a module's declaration against this role's defaults. */
66
+ declare function defineSql(input?: SqlInput): ResolvedSqlConfig;
67
+
68
+ export { type ResolvedSqlConfig, type SqlInput, defineSql };
@@ -0,0 +1,8 @@
1
+ import {
2
+ defineSql
3
+ } from "../../chunk-LU4E4TVD.js";
4
+ import "../../chunk-PXTU5MPW.js";
5
+ export {
6
+ defineSql
7
+ };
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  defineStaticAnalysis
3
- } from "../../chunk-7E6YTTAK.js";
3
+ } from "../../chunk-LX7EG6PJ.js";
4
+ import "../../chunk-PXTU5MPW.js";
4
5
  export {
5
6
  defineStaticAnalysis
6
7
  };
@@ -7,9 +7,9 @@ import {
7
7
  } from "../../../chunk-NUOQXAYR.js";
8
8
  import {
9
9
  installWorkspaceSetup
10
- } from "../../../chunk-4YQXLPJ5.js";
10
+ } from "../../../chunk-PMRL4MH6.js";
11
11
  import "../../../chunk-ELZHIN6E.js";
12
- import "../../../chunk-ZNANJEMK.js";
12
+ import "../../../chunk-JT7ZMH44.js";
13
13
 
14
14
  // src/roles/test/setup/jest-parity.ts
15
15
  import { expect, vi } from "vitest";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  pinWorkspaceTimezone
3
- } from "../../../chunk-4YQXLPJ5.js";
3
+ } from "../../../chunk-PMRL4MH6.js";
4
4
  import "../../../chunk-ELZHIN6E.js";
5
- import "../../../chunk-ZNANJEMK.js";
5
+ import "../../../chunk-JT7ZMH44.js";
6
6
 
7
7
  // src/roles/test/setup/workspace-entry.ts
8
8
  await pinWorkspaceTimezone();
@@ -7,8 +7,8 @@ import {
7
7
  readTestAdoption,
8
8
  resolveVitest,
9
9
  suiteOf
10
- } from "./chunk-2LLRSWG2.js";
11
- import "./chunk-ZNANJEMK.js";
10
+ } from "./chunk-ZASD5YPF.js";
11
+ import "./chunk-JT7ZMH44.js";
12
12
  import "./chunk-O7REVMOC.js";
13
13
  import "./chunk-QXFCZON7.js";
14
14
 
@@ -0,0 +1,282 @@
1
+ # SQL adoption cheat sheet
2
+
3
+ A quick reference for adopting the sentinel `sql` role on a module, for knowing what it checks, and
4
+ for moving a rule's level in `sql.config.mjs`. Why the role exists, and the measurements behind
5
+ its scope, are in [`sql-verification-study.md`](sql-verification-study.md); this page is what you
6
+ need to run it.
7
+
8
+ The role reads what a branch adds or changes:
9
+
10
+ - **the Prisma migrations** (`**/migrations/*/migration.sql`), checked by
11
+ [squawk](https://squawkhq.com) 2.72.0 against PostgreSQL 16.8;
12
+ - **the calls to `$queryRawUnsafe` / `$executeRawUnsafe`** in the module's TypeScript, checked by
13
+ sentinel's own rule, `unsafe-sql-pasted-value`;
14
+ - **the calls to `Prisma.raw`**, checked the same way under a rule of their own,
15
+ `unsafe-sql-raw-fragment`.
16
+
17
+ **Every finding is a warning until the module decides otherwise.** Nothing fails a run by default,
18
+ so adopting the role, or a sentinel upgrade that brings a new squawk rule, never turns a module red.
19
+ A module that wants a rule to block sets it to `error` (see [Rule levels](#rule-levels)).
20
+
21
+ ## Adopt a module in two steps
22
+
23
+ Run from the **module's own directory**, the one that holds `prisma/migrations` or the raw SQL
24
+ calls. You do not need to install sentinel first: use `npx --yes` for a one-off.
25
+
26
+ ```bash
27
+ # 1. write the module's config + the pinned devDependency
28
+ cd apps/.../<module>
29
+ npx --yes @hublo/sentinel@<version> --init --sql
30
+
31
+ # 2. fetch what step 1 declared
32
+ pnpm install
33
+ ```
34
+
35
+ `--init` writes `sql.config.mjs`, adds the three scripts below and the `sql` nx target to the
36
+ module's `package.json`, and pins `@hublo/sentinel` into its `devDependencies`. It prints:
37
+
38
+ ```
39
+ wrote sql.config.mjs
40
+ wrote package.json
41
+ added sql.config.mjs; added the 3 `sql` scripts; every finding is a warning while the role is being adopted
42
+ ```
43
+
44
+ A module that holds no migration and no `Unsafe` or `Prisma.raw` call is skipped by name: there is nothing for the
45
+ role to read. An existing `sql.config.mjs` is the team's and is never rewritten by a re-init.
46
+
47
+ ## Everyday use
48
+
49
+ ```bash
50
+ pnpm run sql # the summary, in your terminal. Writes nothing
51
+ pnpm run sql:json # sql-report/sql.json, for a machine
52
+ pnpm run sql:html # sql-report/sql.html, for a reader
53
+ ```
54
+
55
+ Or without the scripts:
56
+
57
+ ```bash
58
+ sentinel --run --sql # same as the first script
59
+ sentinel --run --sql --output markdown # sql-report/sql.md, the pull-request recap
60
+ sentinel --inspect --sql --json # every setting and every rule's level, without running
61
+ ```
62
+
63
+ ## What it reads: only what the branch adds or changes
64
+
65
+ The role compares the branch with `origin/main` and reads the migrations and the TypeScript files
66
+ the branch **adds or modifies**. An old migration has already run in production; reporting it again
67
+ on every pull request would bury the one that has not. The console says what was read and what
68
+ was not:
69
+
70
+ ```
71
+ read 1 migration(s) this branch adds or changes, compared with origin/main at 63d1ee7. The 1 other(s) in this module are unchanged and not read.
72
+ checked 1 call(s) to $queryRawUnsafe / $executeRawUnsafe and 2 to Prisma.raw in the 2 file(s) this branch adds or changes.
73
+ ```
74
+
75
+ This is how the role reads, not a setting.
76
+
77
+ ## What is checked, out of the box
78
+
79
+ | Source | Rules | On by default |
80
+ | ----------------------------------------------------------------- | ----- | --------------------------------------------- |
81
+ | squawk 2.72.0, its default rules | 50 | **yes**, at `warn` |
82
+ | squawk 2.72.0, its opt-in rules | 26 | no: one runs once the module gives it a level |
83
+ | sentinel, `unsafe-sql-pasted-value` and `unsafe-sql-raw-fragment` | 2 | **yes**, at `warn` |
84
+
85
+ **52 rules run on every module**, the set squawk itself runs, plus sentinel's two. sentinel turns
86
+ no squawk rule off and turns no opt-in rule on: the choice of what runs by default is squawk's, and
87
+ a module moves it in its own config. `pnpm exec sentinel --inspect --sql --json` lists all 78 rules
88
+ with the level each has in this module.
89
+
90
+ <details>
91
+ <summary>The 50 squawk rules on by default</summary>
92
+
93
+ `adding-field-with-default`, `adding-foreign-key-constraint`, `adding-not-nullable-field`,
94
+ `adding-required-field`, `adding-serial-primary-key-field`, `ban-alter-domain-with-add-constraint`,
95
+ `ban-alter-identity`, `ban-char-field`, `ban-concurrent-index-creation-in-transaction`,
96
+ `ban-create-domain-with-constraint`, `ban-drop-column`, `ban-drop-constraint`, `ban-drop-database`,
97
+ `ban-drop-default`, `ban-drop-domain`, `ban-drop-extension`, `ban-drop-function`,
98
+ `ban-drop-generated-expression`, `ban-drop-not-null`, `ban-drop-schema`, `ban-drop-sequence`,
99
+ `ban-drop-table`, `ban-drop-type`, `ban-drop-view`, `ban-duplicate-column-assignments`,
100
+ `ban-set-schema`, `ban-truncate-cascade`, `ban-uncommitted-transaction`, `changing-column-type`,
101
+ `constraint-missing-not-valid`, `disallowed-unique-constraint`, `identifier-too-long`,
102
+ `prefer-bigint-over-int`, `prefer-bigint-over-smallint`, `prefer-identity`, `prefer-repack`,
103
+ `prefer-robust-stmts`, `prefer-text-field`, `prefer-timestamp-tz`, `renaming-column`,
104
+ `renaming-object`, `renaming-table`, `require-concurrent-index-creation`,
105
+ `require-concurrent-index-deletion`, `require-concurrent-partition-detach`,
106
+ `require-concurrent-reindex`, `require-enum-value-ordering`, `require-lock-timeout`,
107
+ `require-statement-timeout`, `transaction-nesting`.
108
+
109
+ </details>
110
+
111
+ <details>
112
+ <summary>The 26 opt-in squawk rules, off until given a level</summary>
113
+
114
+ `ban-add-column`, `ban-add-composite-attribute`, `ban-add-enum-value`, `ban-alter-database-options`,
115
+ `ban-alter-extension`, `ban-alter-function-options`, `ban-alter-generated-expression`,
116
+ `ban-alter-policy-condition`, `ban-alter-policy-roles`, `ban-alter-role-options`,
117
+ `ban-alter-row-level-security`, `ban-alter-sequence-values`, `ban-alter-system-options`,
118
+ `ban-alter-view-options`, `ban-create-policy`, `ban-detach-inheritance`, `ban-disable-trigger`,
119
+ `ban-drop-index`, `ban-drop-policy`, `ban-drop-trigger`, `ban-new-write-restriction`,
120
+ `ban-replace-view-function`, `ban-replica-identity`, `ban-revoke`, `ban-set-default`,
121
+ `require-table-schema`.
122
+
123
+ </details>
124
+
125
+ The rule pages are squawk's: `https://squawkhq.com/docs/<rule>`.
126
+
127
+ ## Rule levels
128
+
129
+ A rule has one of three levels, the meanings lint already uses:
130
+
131
+ | Level | The rule runs? | A finding fails the run? | In the report |
132
+ | ---------------- | -------------- | ------------------------ | ---------------------------------------------------------------- |
133
+ | `warn` (default) | yes | no | listed |
134
+ | `error` | yes | **yes**, exit code 1 | listed first, marked `error` |
135
+ | `off` | no | no | named in a line of its own, so a reviewer sees it was turned off |
136
+
137
+ ## The config file, `sql.config.mjs`
138
+
139
+ The one file a module writes, the shape of `static-analysis.config.mjs`. `--init` writes it with
140
+ every setting the module can move and the role's value today, generated from the defaults so it
141
+ cannot drift from them. A setting the module leaves out keeps the role's value; a setting it writes
142
+ **replaces** it, including inside a list, and the html report shows it as overridden by this module.
143
+
144
+ | Setting | Default | What it moves |
145
+ | --------------------- | ------------------------------------------ | ------------------------------------------------------ |
146
+ | `migrations.include` | `["**/migrations/*/migration.sql"]` | which files are migrations |
147
+ | `migrations.exclude` | `[]` | migrations never read |
148
+ | `unsafe.includeTests` | `true` | whether calls in test files are checked, by both rules |
149
+ | `unsafe.tests` | test folders and `*.spec`/`*.test`/… files | what counts as a test file |
150
+ | `ignore` | `node_modules`, `dist`, `coverage` | never read, by either check |
151
+ | `pgVersion` | `"16.8"` | the PostgreSQL version squawk checks against |
152
+ | `rules` | `{}`, every rule at its default | a level per rule, by its name |
153
+
154
+ An example that blocks two rules, silences one and turns an opt-in rule on:
155
+
156
+ ```js
157
+ // sql.config.mjs
158
+ import { defineSql } from '@hublo/sentinel/sql'
159
+
160
+ export default defineSql({
161
+ root: import.meta.dirname,
162
+ overrides: {
163
+ rules: {
164
+ 'require-concurrent-index-creation': 'error',
165
+ 'unsafe-sql-pasted-value': 'error',
166
+ 'prefer-robust-stmts': 'off',
167
+ 'ban-drop-index': 'warn',
168
+ },
169
+ },
170
+ })
171
+ ```
172
+
173
+ What the run prints with it:
174
+
175
+ ```
176
+ this module turns off 1 rule(s) in sql.config.mjs, so squawk does not check them: prefer-robust-stmts.
177
+ ✗ 6 finding(s): 2 error(s), from the rule(s) this module sets to "error" in sql.config.mjs, which fail this run, and 4 warning(s):
178
+ require-concurrent-index-creation 1 error
179
+ sentinel's note: Prisma runs a multi-statement file in a transaction, where CONCURRENTLY fails: give the statement its own migration.
180
+ unsafe-sql-pasted-value 1 error
181
+ changing-column-type 1
182
+ ...
183
+ ```
184
+
185
+ `rules` names a rule by **squawk's name for it**, the name the report prints. A name that is not a
186
+ rule is refused in the module's own file, before anything runs, with the closest name:
187
+
188
+ ```
189
+ sql.config.mjs: `rules['prefer-robust-stmt']` is not a rule of squawk 2.72.0 or of sentinel. Did you mean 'prefer-robust-stmts'? The names are listed by `pnpm exec sentinel --inspect --sql --json`.
190
+ ```
191
+
192
+ An older name squawk still accepts, such as `prefer-timestamptz`, is refused too, with the name to
193
+ write: squawk reports the rule under its new name, so a level on the old one would never apply.
194
+
195
+ ## sentinel's notes
196
+
197
+ squawk's advice is written for PostgreSQL in general. Under two rules, sentinel adds a note where
198
+ that advice meets the way Prisma runs a migration, each proven on PostgreSQL 16.8 with Prisma
199
+ 6.19.3. **A note is added beside a finding; it never removes or changes one.**
200
+
201
+ - **`require-concurrent-index-creation` / `-deletion`.** Prisma runs a file of several statements
202
+ inside a transaction, where `CONCURRENTLY` fails (`25001`), nothing is applied and the next deploy
203
+ is refused (`P3009`). The note says to give the statement a migration of its own, alone in its
204
+ file, which applies.
205
+ - **`changing-column-type`, to `varchar` or `text`.** Widening a `varchar`, or changing it to
206
+ `text`, rewrites neither the table nor its index (under 4 ms on 2 million rows), but still waits
207
+ for the table's lock and makes every query behind it wait. The note says to put
208
+ `SET lock_timeout` before the `ALTER`. The statement does not say the type before it, so the
209
+ finding stays for every type change: narrowing a `varchar`, or leaving a `uuid`, does rewrite the
210
+ table.
211
+
212
+ ## The `Unsafe` rule, `unsafe-sql-pasted-value`
213
+
214
+ Prisma's tagged `` $queryRaw`…${value}…` `` sends each `${}` as a parameter. `$queryRawUnsafe` and
215
+ `$executeRawUnsafe` take a plain string: whatever is pasted into it runs as SQL. The rule reports a
216
+ call whose SQL text holds a part sentinel **cannot show** is a constant.
217
+
218
+ It clears what cannot carry text a caller chose:
219
+
220
+ - a string literal, or a template without a value;
221
+ - a template, `+`, ternary, `??`, `||` or `&&` built only of safe parts;
222
+ - arithmetic and comparisons, whose result is a number or a boolean;
223
+ - a `const` of the file, declared once under that name, whose value is safe;
224
+ - a name imported from a relative path, from a file that says `export const NAME = <safe>`;
225
+ - generated placeholders, ``list.map((_, index) => `$${index + 1}`).join(', ')``.
226
+
227
+ It reports everything else, and names the part it could not see:
228
+
229
+ ```
230
+ `table` is pasted into the SQL text of $queryRawUnsafe, and sentinel cannot show it is constant: a quote in it would end the string and run the rest as SQL
231
+ ```
232
+
233
+ That includes a function parameter (the SQL arrives from a caller, unchecked where it is used), a
234
+ `let`, an object property, an enum member, a call, a name declared twice in the file, and an import
235
+ from a package. The rule never guesses: when it cannot see, it reports. The fix it prints is a
236
+ parameter (`$1` in the text, the value after it), or the tagged form; a table or column name cannot
237
+ be a parameter, so take it from a `const` of the file.
238
+
239
+ Measured on the monorepo's 219 calls before the rule was written: the 23 production calls match a
240
+ classification made by hand, one of them a real injection pasting data into a `VALUES` list.
241
+
242
+ ## The `Prisma.raw` rule, `unsafe-sql-raw-fragment`
243
+
244
+ `Prisma.raw(text)` puts its text into a tagged query **as SQL, never as a parameter**: the same
245
+ hazard as the `Unsafe` methods, inside the safe form. Its argument is checked exactly like theirs,
246
+ with the same list of what is cleared, and reported under its own rule, so a module can set the two
247
+ levels apart. `Prisma` is recognised by its import from a `@prisma/` package, under any name
248
+ (`import { Prisma as AgencyPrisma }` included); a `raw` of anything else, `String.raw` among them,
249
+ is not read.
250
+
251
+ ```
252
+ the SQL text of Prisma.raw is `sortOrder`, which sentinel cannot show is a constant: whatever was pasted into it, wherever it was built, runs as SQL
253
+ ```
254
+
255
+ The fix it prints: a value goes into `` Prisma.sql`…` `` as `${value}`, which binds it. A keyword or
256
+ a column name cannot be bound, so write each choice as a literal, which the rule clears:
257
+
258
+ ```ts
259
+ Prisma.sql`ORDER BY "lastName" ${order === 'DESC' ? Prisma.raw('DESC') : Prisma.raw('ASC')}`
260
+ ```
261
+
262
+ Measured on `main` (f12da701121): 97 calls, 20 cleared (all literals or ternaries of literals) and 77
263
+ reported. None of the 77 was found injectable, and none can be proven safe where it is written:
264
+
265
+ | What the call receives | Calls | Why the rule cannot clear it |
266
+ | --------------------------------------------------------------------------------------------------------------- | ----: | ------------------------------------------------------------ |
267
+ | a value validated elsewhere: an enum checked by the HTTP DTO, a key of a column map, a filtered list of numbers | 37 | the proof is a type or a validator, files away from the call |
268
+ | an alias or a column name, a parameter of a SQL helper | 19 | the callers pass literals, in other files |
269
+ | a fragment of SQL built elsewhere, by a query builder or a helper | 21 | the text is made in another function |
270
+
271
+ That is the rule's purpose: on a branch that changes one of these files, the reviewer is told that
272
+ the safety of the text rests on code the call does not show.
273
+
274
+ ## What the role does not read yet
275
+
276
+ Said here so that a clean report is not read as more than it is:
277
+
278
+ - **The SQL text itself** of a raw query is not parsed: a tagged `$queryRaw` with only parameters is
279
+ safe from injection, and its SQL is not checked against any rule.
280
+ - **Files outside a module.** The role runs on a module; a script at the repository's root that
281
+ belongs to no module is read by no role.
282
+ - **What the ORM generates** (`findMany`, `update`, …) is not seen: there is no SQL text to read.