@hublo/sentinel 1.7.0-alpha.34 → 1.7.0-alpha.35

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.
@@ -330,7 +330,6 @@ $ sentinel --report --json 2>/dev/null
330
330
  "migrations": 0,
331
331
  "codeFiles": 1,
332
332
  "unsafeFiles": 0,
333
- "templateFiles": 0,
334
333
  "base": null,
335
334
  "migrationsRead": 0,
336
335
  "migrationsUnchanged": 0,
@@ -339,9 +338,6 @@ $ sentinel --report --json 2>/dev/null
339
338
  "unsafeCalls": 0,
340
339
  "rawFragmentCalls": 0,
341
340
  "unsafeUnparsed": 0,
342
- "templateFilesRead": 0,
343
- "templatesRead": 0,
344
- "templatesUnread": 0,
345
341
  "findings": 0,
346
342
  "errors": 0,
347
343
  "rulesOff": [],
@@ -458,7 +454,6 @@ $ sentinel --report --json 2>/dev/null
458
454
  "migrations": 0,
459
455
  "codeFiles": 1,
460
456
  "unsafeFiles": 0,
461
- "templateFiles": 0,
462
457
  "base": null,
463
458
  "migrationsRead": 0,
464
459
  "migrationsUnchanged": 0,
@@ -467,9 +462,6 @@ $ sentinel --report --json 2>/dev/null
467
462
  "unsafeCalls": 0,
468
463
  "rawFragmentCalls": 0,
469
464
  "unsafeUnparsed": 0,
470
- "templateFilesRead": 0,
471
- "templatesRead": 0,
472
- "templatesUnread": 0,
473
465
  "findings": 0,
474
466
  "errors": 0,
475
467
  "rulesOff": [],
@@ -586,7 +578,6 @@ $ sentinel --report --json 2>/dev/null
586
578
  "migrations": 0,
587
579
  "codeFiles": 1,
588
580
  "unsafeFiles": 0,
589
- "templateFiles": 0,
590
581
  "base": null,
591
582
  "migrationsRead": 0,
592
583
  "migrationsUnchanged": 0,
@@ -595,9 +586,6 @@ $ sentinel --report --json 2>/dev/null
595
586
  "unsafeCalls": 0,
596
587
  "rawFragmentCalls": 0,
597
588
  "unsafeUnparsed": 0,
598
- "templateFilesRead": 0,
599
- "templatesRead": 0,
600
- "templatesUnread": 0,
601
589
  "findings": 0,
602
590
  "errors": 0,
603
591
  "rulesOff": [],
@@ -702,7 +690,6 @@ $ sentinel --report --json 2>/dev/null
702
690
  "migrations": 0,
703
691
  "codeFiles": 1,
704
692
  "unsafeFiles": 0,
705
- "templateFiles": 0,
706
693
  "base": null,
707
694
  "migrationsRead": 0,
708
695
  "migrationsUnchanged": 0,
@@ -711,9 +698,6 @@ $ sentinel --report --json 2>/dev/null
711
698
  "unsafeCalls": 0,
712
699
  "rawFragmentCalls": 0,
713
700
  "unsafeUnparsed": 0,
714
- "templateFilesRead": 0,
715
- "templatesRead": 0,
716
- "templatesUnread": 0,
717
701
  "findings": 0,
718
702
  "errors": 0,
719
703
  "rulesOff": [],
@@ -870,7 +854,6 @@ $ sentinel --report --all --json 2>/dev/null
870
854
  "migrations": 0,
871
855
  "codeFiles": 1,
872
856
  "unsafeFiles": 0,
873
- "templateFiles": 0,
874
857
  "base": null,
875
858
  "migrationsRead": 0,
876
859
  "migrationsUnchanged": 0,
@@ -879,9 +862,6 @@ $ sentinel --report --all --json 2>/dev/null
879
862
  "unsafeCalls": 0,
880
863
  "rawFragmentCalls": 0,
881
864
  "unsafeUnparsed": 0,
882
- "templateFilesRead": 0,
883
- "templatesRead": 0,
884
- "templatesUnread": 0,
885
865
  "findings": 0,
886
866
  "errors": 0,
887
867
  "rulesOff": [],
@@ -998,7 +978,6 @@ $ sentinel --report --all --json 2>/dev/null
998
978
  "migrations": 0,
999
979
  "codeFiles": 1,
1000
980
  "unsafeFiles": 0,
1001
- "templateFiles": 0,
1002
981
  "base": null,
1003
982
  "migrationsRead": 0,
1004
983
  "migrationsUnchanged": 0,
@@ -1007,9 +986,6 @@ $ sentinel --report --all --json 2>/dev/null
1007
986
  "unsafeCalls": 0,
1008
987
  "rawFragmentCalls": 0,
1009
988
  "unsafeUnparsed": 0,
1010
- "templateFilesRead": 0,
1011
- "templatesRead": 0,
1012
- "templatesUnread": 0,
1013
989
  "findings": 0,
1014
990
  "errors": 0,
1015
991
  "rulesOff": [],
@@ -1126,7 +1102,6 @@ $ sentinel --report --all --json 2>/dev/null
1126
1102
  "migrations": 0,
1127
1103
  "codeFiles": 1,
1128
1104
  "unsafeFiles": 0,
1129
- "templateFiles": 0,
1130
1105
  "base": null,
1131
1106
  "migrationsRead": 0,
1132
1107
  "migrationsUnchanged": 0,
@@ -1135,9 +1110,6 @@ $ sentinel --report --all --json 2>/dev/null
1135
1110
  "unsafeCalls": 0,
1136
1111
  "rawFragmentCalls": 0,
1137
1112
  "unsafeUnparsed": 0,
1138
- "templateFilesRead": 0,
1139
- "templatesRead": 0,
1140
- "templatesUnread": 0,
1141
1113
  "findings": 0,
1142
1114
  "errors": 0,
1143
1115
  "rulesOff": [],
@@ -1242,7 +1214,6 @@ $ sentinel --report --all --json 2>/dev/null
1242
1214
  "migrations": 0,
1243
1215
  "codeFiles": 1,
1244
1216
  "unsafeFiles": 0,
1245
- "templateFiles": 0,
1246
1217
  "base": null,
1247
1218
  "migrationsRead": 0,
1248
1219
  "migrationsUnchanged": 0,
@@ -1251,9 +1222,6 @@ $ sentinel --report --all --json 2>/dev/null
1251
1222
  "unsafeCalls": 0,
1252
1223
  "rawFragmentCalls": 0,
1253
1224
  "unsafeUnparsed": 0,
1254
- "templateFilesRead": 0,
1255
- "templatesRead": 0,
1256
- "templatesUnread": 0,
1257
1225
  "findings": 0,
1258
1226
  "errors": 0,
1259
1227
  "rulesOff": [],
@@ -2122,6 +2090,7 @@ $ sentinel --run --env
2122
2090
  env (level warning: report, and annotate in GitHub Actions; never fails)
2123
2091
  2 env file(s), 0 contract(s), 0 required and 0 optional variable(s) read, 1 Dockerfile(s), node 10.15.3
2124
2092
  settings: sentinel defaults (no env.config.mjs)
2093
+ compared with origin/main at 90d0ae1: only what this branch adds is listed
2125
2094
 
2126
2095
  ✗ [committed-env-file] rule 2, blocking, 2
2127
2096
  a real env file is committed: remove it from git (only .example contracts belong there; values come from a secret store)
@@ -2145,7 +2114,7 @@ env (level warning: report, and annotate in GitHub Actions; never fails)
2145
2114
  note: no required reader call found (getOrFail, requireEnv, requireEnvVariable): rule 1 had nothing to check; name the repository's own helper in readers.required
2146
2115
  note: not an nx workspace (no nx.json): rule 8 skipped
2147
2116
 
2148
- 5 blocking findings: reported, not failing
2117
+ 5 blocking findings added: reported, not failing
2149
2118
  ✓ serviceapp (repository) env — level=warning blocking=5
2150
2119
  1 repository [serviceapp] in <n>ms
2151
2120
  # exit: 0
@@ -2155,9 +2124,10 @@ env (level warning: report, and annotate in GitHub Actions; never fails)
2155
2124
 
2156
2125
  ```console
2157
2126
  $ sentinel --run --env
2158
- env (level error: fails on a blocking finding (rules 1, 2, 6, 7 to 10))
2127
+ env (level error: fails on a blocking finding this branch adds (rules 1, 2, 6, 7 to 10))
2159
2128
  2 env file(s), 0 contract(s), 0 required and 0 optional variable(s) read, 1 Dockerfile(s), node 10.15.3
2160
2129
  settings: sentinel defaults (no env.config.mjs)
2130
+ compared with origin/main at 90d0ae1: only what this branch adds is listed
2161
2131
 
2162
2132
  ✗ [committed-env-file] rule 2, blocking, 2
2163
2133
  a real env file is committed: remove it from git (only .example contracts belong there; values come from a secret store)
@@ -2181,7 +2151,7 @@ env (level error: fails on a blocking finding (rules 1, 2, 6, 7 to 10))
2181
2151
  note: no required reader call found (getOrFail, requireEnv, requireEnvVariable): rule 1 had nothing to check; name the repository's own helper in readers.required
2182
2152
  note: not an nx workspace (no nx.json): rule 8 skipped
2183
2153
 
2184
- 5 blocking findings: failing
2154
+ 5 blocking findings added: failing
2185
2155
  ✗ serviceapp (repository) env — level=error blocking=5
2186
2156
  1 repository [serviceapp] in <n>ms
2187
2157
  # exit: 1
@@ -2194,6 +2164,7 @@ $ sentinel --run --env
2194
2164
  env (level warning: report, and annotate in GitHub Actions; never fails)
2195
2165
  2 env file(s), 0 contract(s), 0 required and 0 optional variable(s) read, 1 Dockerfile(s), node 10.15.3
2196
2166
  settings: sentinel defaults (no env.config.mjs)
2167
+ compared with origin/main at 90d0ae1: only what this branch adds is listed
2197
2168
 
2198
2169
  ✗ [committed-env-file] rule 2, blocking, 2
2199
2170
  a real env file is committed: remove it from git (only .example contracts belong there; values come from a secret store)
@@ -2217,7 +2188,7 @@ env (level warning: report, and annotate in GitHub Actions; never fails)
2217
2188
  note: no required reader call found (getOrFail, requireEnv, requireEnvVariable): rule 1 had nothing to check; name the repository's own helper in readers.required
2218
2189
  note: not an nx workspace (no nx.json): rule 8 skipped
2219
2190
 
2220
- 5 blocking findings: reported, not failing
2191
+ 5 blocking findings added: reported, not failing
2221
2192
  ::warning file=variables/dev.variables.env,title=env rule 2%3A committed-env-file::variables/dev.variables.env: a real env file is committed: remove it from git (only .example contracts belong there; values come from a secret store)
2222
2193
  ::warning file=variables/production.variables.env,title=env rule 2%3A committed-env-file::variables/production.variables.env: a real env file is committed: remove it from git (only .example contracts belong there; values come from a secret store)
2223
2194
  ::warning file=variables/dev.variables.env,line=2,title=env rule 5%3A public-secret-to-review::REACT_APP_SEGMENT_API_KEY_ADMINS: a public-prefixed, secret-named variable carries a committed value: it ships to the browser by design, confirm it is genuinely public
@@ -2248,7 +2219,7 @@ $ sentinel --run --env --json 2>/dev/null
2248
2219
  "ok": true,
2249
2220
  "status": "ok",
2250
2221
  "level": "warning",
2251
- "verdict": "5 blocking findings: reported, not failing",
2222
+ "verdict": "5 blocking findings added: reported, not failing",
2252
2223
  "blocking": 5,
2253
2224
  "config": null,
2254
2225
  "scanned": [
@@ -2323,6 +2294,70 @@ $ sentinel --run --env --json 2>/dev/null
2323
2294
  "line": 8
2324
2295
  }
2325
2296
  ],
2297
+ "comparison": {
2298
+ "base": {
2299
+ "ref": "origin/main",
2300
+ "commit": "90d0ae1"
2301
+ },
2302
+ "added": [
2303
+ {
2304
+ "rule": "committed-env-file",
2305
+ "number": 2,
2306
+ "severity": "blocking",
2307
+ "name": "variables/dev.variables.env",
2308
+ "file": "variables/dev.variables.env"
2309
+ },
2310
+ {
2311
+ "rule": "committed-env-file",
2312
+ "number": 2,
2313
+ "severity": "blocking",
2314
+ "name": "variables/production.variables.env",
2315
+ "file": "variables/production.variables.env"
2316
+ },
2317
+ {
2318
+ "rule": "public-secret-to-review",
2319
+ "number": 5,
2320
+ "severity": "advisory",
2321
+ "name": "REACT_APP_SEGMENT_API_KEY_ADMINS",
2322
+ "file": "variables/dev.variables.env",
2323
+ "line": 2
2324
+ },
2325
+ {
2326
+ "rule": "public-secret-to-review",
2327
+ "number": 5,
2328
+ "severity": "advisory",
2329
+ "name": "REACT_APP_SEGMENT_API_KEY_ADMINS",
2330
+ "file": "variables/production.variables.env",
2331
+ "line": 2
2332
+ },
2333
+ {
2334
+ "rule": "secret-not-blanked",
2335
+ "number": 6,
2336
+ "severity": "blocking",
2337
+ "name": "DPAE_PASSWORD",
2338
+ "file": "variables/dev.variables.env",
2339
+ "line": 1
2340
+ },
2341
+ {
2342
+ "rule": "secret-not-blanked",
2343
+ "number": 6,
2344
+ "severity": "blocking",
2345
+ "name": "DPAE_PASSWORD",
2346
+ "file": "variables/production.variables.env",
2347
+ "line": 1
2348
+ },
2349
+ {
2350
+ "rule": "copy-not-owned",
2351
+ "number": 10,
2352
+ "severity": "blocking",
2353
+ "name": "COPY --from=build /home/node/app .",
2354
+ "file": "Dockerfile",
2355
+ "line": 8
2356
+ }
2357
+ ],
2358
+ "fixed": [],
2359
+ "known": 0
2360
+ },
2326
2361
  "inventory": {
2327
2362
  "required": [],
2328
2363
  "optional": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.34",
3
+ "version": "1.7.0-alpha.35",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -177,7 +177,6 @@
177
177
  "jscpd": "5.4.0",
178
178
  "jsdom": "^24.1.3",
179
179
  "jsonc-parser": "^3.3.1",
180
- "libpg-query": "16.8.3",
181
180
  "msw": "1.3.3",
182
181
  "nitro": "3.0.260415-beta",
183
182
  "oxc-parser": "0.147.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/roles/sql/presets/shared.json","../src/roles/sql/presets/squawk-rules.json","../src/roles/sql/preset-data.ts","../src/roles/sql/configs/define.ts"],"sourcesContent":["{\n \"migrations\": {\n \"include\": [\"**/migrations/*/migration.sql\"],\n \"exclude\": [],\n \"indexesFrom\": []\n },\n \"unsafe\": {\n \"includeTests\": true,\n \"tests\": [\n \"**/{test,tests,__tests__,e2e,fixtures,mocks,__mocks__,test-utils}/**\",\n \"**/*.{spec,test,integration-spec,e2e-spec,steps,test-util,mock}.{ts,mts,cts}\"\n ]\n },\n \"ignore\": [\"**/node_modules/**\", \"**/dist/**\", \"**/coverage/**\"],\n \"pgVersion\": \"16.8\",\n \"rules\": {}\n}\n","{\n \"squawk\": \"2.72.0\",\n \"rules\": [\n \"adding-field-with-default\",\n \"adding-foreign-key-constraint\",\n \"adding-not-nullable-field\",\n \"adding-required-field\",\n \"adding-serial-primary-key-field\",\n \"ban-add-column\",\n \"ban-add-composite-attribute\",\n \"ban-add-enum-value\",\n \"ban-alter-database-options\",\n \"ban-alter-domain-with-add-constraint\",\n \"ban-alter-extension\",\n \"ban-alter-function-options\",\n \"ban-alter-generated-expression\",\n \"ban-alter-identity\",\n \"ban-alter-policy-condition\",\n \"ban-alter-policy-roles\",\n \"ban-alter-role-options\",\n \"ban-alter-row-level-security\",\n \"ban-alter-sequence-values\",\n \"ban-alter-system-options\",\n \"ban-alter-view-options\",\n \"ban-char-field\",\n \"ban-concurrent-index-creation-in-transaction\",\n \"ban-create-domain-with-constraint\",\n \"ban-create-policy\",\n \"ban-detach-inheritance\",\n \"ban-disable-trigger\",\n \"ban-drop-column\",\n \"ban-drop-constraint\",\n \"ban-drop-database\",\n \"ban-drop-default\",\n \"ban-drop-domain\",\n \"ban-drop-extension\",\n \"ban-drop-function\",\n \"ban-drop-generated-expression\",\n \"ban-drop-index\",\n \"ban-drop-not-null\",\n \"ban-drop-policy\",\n \"ban-drop-schema\",\n \"ban-drop-sequence\",\n \"ban-drop-table\",\n \"ban-drop-trigger\",\n \"ban-drop-type\",\n \"ban-drop-view\",\n \"ban-duplicate-column-assignments\",\n \"ban-new-write-restriction\",\n \"ban-replace-view-function\",\n \"ban-replica-identity\",\n \"ban-revoke\",\n \"ban-set-default\",\n \"ban-set-schema\",\n \"ban-truncate-cascade\",\n \"ban-uncommitted-transaction\",\n \"changing-column-type\",\n \"constraint-missing-not-valid\",\n \"disallowed-unique-constraint\",\n \"identifier-too-long\",\n \"prefer-bigint-over-int\",\n \"prefer-bigint-over-smallint\",\n \"prefer-identity\",\n \"prefer-repack\",\n \"prefer-robust-stmts\",\n \"prefer-text-field\",\n \"prefer-timestamp-tz\",\n \"renaming-column\",\n \"renaming-object\",\n \"renaming-table\",\n \"require-concurrent-index-creation\",\n \"require-concurrent-index-deletion\",\n \"require-concurrent-partition-detach\",\n \"require-concurrent-reindex\",\n \"require-enum-value-ordering\",\n \"require-lock-timeout\",\n \"require-statement-timeout\",\n \"require-table-schema\",\n \"transaction-nesting\"\n ],\n \"optIn\": [\n \"ban-add-column\",\n \"ban-add-composite-attribute\",\n \"ban-add-enum-value\",\n \"ban-alter-database-options\",\n \"ban-alter-extension\",\n \"ban-alter-function-options\",\n \"ban-alter-generated-expression\",\n \"ban-alter-policy-condition\",\n \"ban-alter-policy-roles\",\n \"ban-alter-role-options\",\n \"ban-alter-row-level-security\",\n \"ban-alter-sequence-values\",\n \"ban-alter-system-options\",\n \"ban-alter-view-options\",\n \"ban-create-policy\",\n \"ban-detach-inheritance\",\n \"ban-disable-trigger\",\n \"ban-drop-index\",\n \"ban-drop-policy\",\n \"ban-drop-trigger\",\n \"ban-new-write-restriction\",\n \"ban-replace-view-function\",\n \"ban-replica-identity\",\n \"ban-revoke\",\n \"ban-set-default\",\n \"require-table-schema\"\n ],\n \"aliases\": {\n \"prefer-timestamptz\": [\"prefer-timestamp-tz\"],\n \"require-timeout-settings\": [\"require-lock-timeout\", \"require-statement-timeout\"]\n }\n}\n","/**\n * The SQL role's values: what it reads, where it writes, and what a module may move.\n *\n * ## What this role guards, and in which order\n *\n * The study behind it (`docs/sql-verification-study.md`, HUB-45374, issue #150) measured where our\n * SQL lives and set the order, cheapest first:\n *\n * 1. **migrations**, read by squawk. On the monorepo (`main` 0eb8be6550d, 2026-11-14): 871\n * `migration.sql` across 21 modules, 135 of them added by 84 pull requests in five weeks.\n * 2. **the `Unsafe` calls** (`$queryRawUnsafe`, `$executeRawUnsafe`), read by a rule of ours. 226\n * calls the same day: 23 in production code, 203 in tests. And `Prisma.raw`, whose text is SQL\n * inside a tagged query, by the same rule under its own name: 97 calls on `main` f12da701121.\n *\n * 3. **the SQL of tagged templates** (`$queryRaw`, `$executeRaw`, `Prisma.sql`), read with\n * PostgreSQL's own parser (`libpg-query`) by rules of ours, the 19 May incident's first (#178):\n * 1 587 templates on `main` 837abe3f29c, 91 % of the production ones read alone.\n *\n * The ORM chain comes later, in this same role.\n *\n * ## Which modules: the ones that hold SQL, whatever their preset\n *\n * Decided from what the module HOLDS, never from its preset, which is the rule sentinel already\n * follows: the build role reads its own Vite config rather than trusting a preset. A preset says\n * which stack a module is written in, not whether it talks to a database. `libs/nest/signal-bus`\n * is `nest` (its code imports `@nestjs/`) and holds no SQL at all, it carries signals over Redis;\n * `libs/nest/db-main` holds 442 of the 871 migrations. Both are `nest`, and only one concerns this\n * role.\n *\n * So the role applies to every preset, like six of the seven before it, and `--init` skips a module\n * holding neither a migration nor an `Unsafe` call. A front end holds neither, so it is skipped\n * with no line of code about front ends. Measured with dry runs on `apps/front/host-admin`,\n * `libs/front/components`, `libs/nest/signal-bus` (skipped), `libs/nest/db-main` and `network`\n * (adopted).\n */\nimport sharedData from './presets/shared.json'\nimport squawkRulesData from './presets/squawk-rules.json'\n\n/** The target this role serves, and the flag that runs it: `sentinel --run --sql`. */\nexport const TARGET = 'sql'\n\n/** The file a module writes at its root to move a setting. Optional at every moment. */\nexport const SQL_CONFIG_FILE = 'sql.config.mjs'\n\n/**\n * Where the files of `--output json|html|markdown` land, inside the module.\n *\n * Its own directory rather than `static-analysis-report/`: two roles writing into one folder would\n * each clear the other's stale files.\n */\nexport const REPORT_DIR = 'sql-report'\n\n/**\n * One script per shape a DEVELOPER runs. `markdown` gets none: it is the pull request comment a CI\n * workflow produces, the decision static analysis took for the same reason.\n */\nexport const SCRIPTS = {\n console: 'sql',\n json: 'sql:json',\n html: 'sql:html',\n} as const\n\n/** A rule's level. `off` is a module's decision, and the report prints it as one. */\nexport type Severity = 'off' | 'warn' | 'error'\n\nexport interface SqlDefaults {\n /** The migration files squawk reads, as globs relative to the module. */\n migrations: {\n /**\n * ⛔ `migration.sql` BY NAME, and that is what keeps the rollback scripts out. Beside the 871\n * migrations sit 385 `down.sql`, 2 `drop.sql` and one `donw.sql`: scripts a human runs by hand,\n * which Prisma never applies. Reading them would report every `DROP` they are made of, for a\n * file that never reaches production through a deploy. Naming the file Prisma applies, rather\n * than excluding the others, also keeps out the misspelling nobody would think to exclude.\n */\n include: string[]\n /** Migrations a module chooses not to read. Empty by default. */\n exclude: string[]\n /**\n * Other migrations directories, relative to the module, whose INDEXES this module's queries\n * use: never checked, only read for the trigram indexes `leading-wildcard-like` asks about.\n *\n * For a module that queries a database another module migrates. On the monorepo every trigram\n * index is in `libs/nest/db-main` (main 190dc8e3595), and `mission`, `network` or `institution`\n * query its tables: without this, the rule would say of their searches that no index serves\n * them. Empty by default: the module's own migrations only, and the message says so.\n */\n indexesFrom: string[]\n }\n /** What the `Unsafe` rule reads. */\n unsafe: {\n /**\n * Read the tests too. ON by default: 203 of the 226 `Unsafe` calls are in tests, and a call\n * that is safe today is not safe by construction tomorrow. A module that decides otherwise sets\n * it to false, and the report says so; the decision is the team's.\n */\n includeTests: boolean\n /**\n * What counts as a test, by PATH. Measured on the monorepo before it was written: the filter\n * `*.spec.*` alone let 149 test calls through as production, because `*.integration-spec.ts`,\n * `*.steps.ts`, `tests/database/` and `*.test-util.ts` are all test code and none of them\n * matches it.\n */\n tests: string[]\n }\n /** Directories never read, whatever the includes say. */\n ignore: string[]\n /**\n * The PostgreSQL version squawk checks against, since some rules depend on it.\n *\n * 16.8 is the version the monorepo pins (`postgres:16.8`, in its integration tests and its\n * database tooling). The role reads what the repository declares and never asks production.\n */\n pgVersion: string\n /**\n * Each rule's level, by name. Empty means every rule at its default, `warn` in this version: the\n * role refuses nothing while its adoption runs.\n */\n rules: Record<string, Severity>\n}\n\n/**\n * The role's values, read from `presets/shared.json`: preset data is JSON, never TypeScript, in every\n * role (AGENTS.md, and `tests/role-layout.test.ts` holds it). The reasons for each value are the\n * comments on `SqlDefaults` above, since JSON carries none.\n */\nexport const defaults: SqlDefaults = sharedData as SqlDefaults\n\n/**\n * squawk's rule names, for the version sentinel pins: what `rules` in `sql.config.mjs` may name.\n *\n * Data about the tool rather than a preset, kept beside the presets like `build`'s\n * `requirements.json`. Taken from squawk's own source at the pinned tag\n * (`crates/squawk_linter/src/lib.rs`, the names a finding carries and `is_opt_in`), and held to the\n * binary by a test: every name here is accepted by the installed squawk, and the version here is\n * the version installed, so a squawk bump that renames a rule fails the build instead of a module.\n *\n * - `rules`, the names findings carry. `unused-ignore` is left out: squawk reports it about its own\n * ignore comments, and refuses it in a config.\n * - `optIn`, the rules squawk runs only when a config names them.\n * - `aliases`, names squawk accepts that no finding carries. A level set on one would never meet a\n * finding, so the role refuses it and names the rule(s) it stands for.\n */\nexport interface SquawkRules {\n squawk: string\n rules: string[]\n optIn: string[]\n aliases: Record<string, string[]>\n}\n\nexport const squawkRules: SquawkRules = squawkRulesData\n","/**\n * `defineSql`: what a module imports to declare its own SQL settings.\n *\n * ```js\n * // sql.config.mjs\n * import { defineSql } from '@hublo/sentinel/sql'\n *\n * export default defineSql({\n * root: import.meta.dirname,\n * overrides: { unsafe: { includeTests: false } },\n * })\n * ```\n *\n * The shape of `defineStaticAnalysis`, for the two reasons stated there. A function receives the\n * module's INTENT, the keys it actually passed, and merges them here, so setting one key never\n * drops its siblings: a spread in the module's file would replace the whole `unsafe` block to set\n * `includeTests`, and lose `tests` with nobody seeing it. And the defaults are never copied into a\n * module, so a changed default reaches every module at the next release instead of leaving stale\n * copies behind.\n *\n * `overrides` REPLACES what it names, lists included, and every path it sets lands in `moved`, so\n * the report prints `(module)` beside it: two modules measured with different settings no longer\n * compare, and the reader has to be told.\n */\nimport { isPlainObject } from '../../../shared/deep-merge.js'\nimport { defaults, type SqlDefaults } from '../preset-data.js'\n\ntype DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K] }\n\n/** What a module's config file passes. Everything is optional, including the file itself. */\nexport interface SqlInput {\n /** The module's own directory, normally `import.meta.dirname`. */\n root?: string\n /** The seam. Replaces whatever it names, and every path it sets lands in `moved`. */\n overrides?: DeepPartial<SqlDefaults>\n}\n\nexport interface ResolvedSqlConfig extends SqlDefaults {\n /** The module's directory, or null when its config file did not say. */\n root: string | null\n /** Dotted paths the module set through `overrides`, sorted so two runs print the same report. */\n moved: string[]\n}\n\n/**\n * Merge `patch` into `base`, recursively, patch winning.\n *\n * Arrays are REPLACED, never concatenated: a merge that concatenates cannot express \"replace this\n * list\", which is exactly what a team reaching for `overrides` asks for. `rules` is a record, so\n * a module naming one rule keeps the levels of every other.\n */\nfunction mergeInto<T>(base: T, patch: unknown): T {\n if (!isPlainObject(patch)) return base\n if (!isPlainObject(base)) return patch as T\n const out: Record<string, unknown> = { ...base }\n for (const [key, value] of Object.entries(patch)) {\n out[key] = isPlainObject(value) ? mergeInto(out[key], value) : value\n }\n return out as T\n}\n\n/** Every leaf path in `patch`, dotted, so a reader can be told what the module decided. */\nfunction leafPaths(patch: unknown, prefix = ''): string[] {\n if (!isPlainObject(patch)) return prefix ? [prefix] : []\n return Object.entries(patch).flatMap(([key, value]) =>\n leafPaths(value, prefix ? `${prefix}.${key}` : key),\n )\n}\n\n/** The keys `defineSql` reads. */\nconst INPUT_KEYS: readonly string[] = ['root', 'overrides']\n\n/** Resolve a module's declaration against this role's defaults. */\nexport function defineSql(input: SqlInput = {}): ResolvedSqlConfig {\n // ⛔ `override:` for `overrides:` would otherwise resolve to the defaults in silence, the module\n // believing it moved a setting. Thrown, so the loader names the file and the key.\n const unknown = Object.keys(input).filter((key) => !INPUT_KEYS.includes(key))\n if (unknown.length > 0) {\n throw new Error(\n `defineSql takes ${INPUT_KEYS.map((key) => `\\`${key}\\``).join(' and ')}; ` +\n `${unknown.map((key) => `\\`${key}\\``).join(', ')} would be ignored.`,\n )\n }\n return {\n ...mergeInto(defaults, input.overrides),\n root: input.root ?? null,\n moved: leafPaths(input.overrides).sort(),\n }\n}\n"],"mappings":";;;;;AAAA;AAAA,EACE,YAAc;AAAA,IACZ,SAAW,CAAC,+BAA+B;AAAA,IAC3C,SAAW,CAAC;AAAA,IACZ,aAAe,CAAC;AAAA,EAClB;AAAA,EACA,QAAU;AAAA,IACR,cAAgB;AAAA,IAChB,OAAS;AAAA,MACP;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EACA,QAAU,CAAC,sBAAsB,cAAc,gBAAgB;AAAA,EAC/D,WAAa;AAAA,EACb,OAAS,CAAC;AACZ;;;AChBA;AAAA,EACE,QAAU;AAAA,EACV,OAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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