@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.
package/README.md CHANGED
@@ -176,6 +176,7 @@ throwaway run wants. Once a module has adopted, nothing is fetched any more: the
176
176
  - [`docs/typescript-adoption.md`](docs/typescript-adoption.md) — the adoption cheat sheet: the two adoption steps, the command model (verb x type x location), options, reading a report, and troubleshooting.
177
177
  - [`docs/test-adoption.md`](docs/test-adoption.md) — migrating a module from jest to Vitest: the two steps, what the migration rewrites and what it refuses BY NAME, how the baseline gate proves nothing was lost, and the failures worth recognising.
178
178
  - [`docs/static-analysis-adoption.md`](docs/static-analysis-adoption.md) — running the static analysis role on a module: the two steps, the four output shapes, how to read each row and where its threshold comes from, declaring an entry point, and the two limits worth knowing before trusting a number.
179
+ - [`docs/sql-adoption.md`](docs/sql-adoption.md) — checking the migrations, the `Unsafe` calls and the `Prisma.raw` calls a branch adds or changes: the two steps, the 52 rules on by default and the 26 opt-in ones, the three levels in `sql.config.mjs` with an example, sentinel's two notes, and what the role does not read yet.
179
180
  - [`docs/env-adoption.md`](docs/env-adoption.md) — checking a whole repository's env files, contracts and Dockerfiles from its root: the ten rules and which block, the three levels of `SENTINEL_ENV_LEVEL`, the optional `env.config.mjs`, and what changed from the monorepo's `tools/repo-env`.
180
181
  - [`docs/typescript-traces.md`](docs/typescript-traces.md) — a **generated, versioned** reference of live command + output traces (every verb, option, config result and edge case) against the mock monorepo. Regenerate after CLI changes with `pnpm docs:traces`.
181
182
 
@@ -12,18 +12,18 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-NSILXJWF.js";
15
+ } from "../chunk-VZZ3DOC3.js";
16
16
  import {
17
17
  resolveContext,
18
18
  separateToolArgs
19
- } from "../chunk-2LLRSWG2.js";
19
+ } from "../chunk-ZASD5YPF.js";
20
20
  import {
21
21
  ensureWorkspacePrep,
22
22
  findWorkspaceRoot,
23
23
  inspectWorkspacePrep,
24
24
  readOwnVersion,
25
25
  readProjectPackageJson
26
- } from "../chunk-ZNANJEMK.js";
26
+ } from "../chunk-JT7ZMH44.js";
27
27
  import {
28
28
  DEFAULT_ENV_LEVEL,
29
29
  ENV_LEVELS,
@@ -34,7 +34,9 @@ import {
34
34
  SWEEPABLE_TARGETS,
35
35
  TARGETS,
36
36
  VERBS
37
- } from "../chunk-7E6YTTAK.js";
37
+ } from "../chunk-LX7EG6PJ.js";
38
+ import "../chunk-LU4E4TVD.js";
39
+ import "../chunk-PXTU5MPW.js";
38
40
  import "../chunk-4EIY7TTR.js";
39
41
  import "../chunk-O7REVMOC.js";
40
42
  import "../chunk-QXFCZON7.js";
@@ -547,8 +549,8 @@ sentinel (${type}): ${asMessage(error)}
547
549
  // Only when the FORMAT role actually adopted: a module still formatted by the root
548
550
  // must not be excluded from it.
549
551
  formattedModule: toRun.includes("format") ? module.root : void 0,
550
- // Same rule for the report directory: only when the STATIC ANALYSIS role adopted.
551
- analysedModule: toRun.includes("static-analysis")
552
+ // Same rule for the report directories: only for a role that writes reports and adopted.
553
+ adoptedRoles: toRun
552
554
  });
553
555
  workspace = changes;
554
556
  const prefix = ctx.dryRun ? " dry run: " : " ";
@@ -585,7 +587,7 @@ async function runValidate(ctx) {
585
587
  );
586
588
  }
587
589
  if (!ctx.targets.includes("test")) return 1;
588
- const { validateModuleTests } = await import("../validate-S5I4Z7IO.js");
590
+ const { validateModuleTests } = await import("../validate-QYP7HFSY.js");
589
591
  const outcomes = modules.flatMap(
590
592
  (module) => validateModuleTests(module.name, module.root)
591
593
  );
@@ -918,6 +920,7 @@ var TARGET_HELP = {
918
920
  dev: "dev server (long-running: never swept by an unqualified --run)",
919
921
  test: "tests",
920
922
  "static-analysis": "duplication, dead code, complexity, import graph, file size, bundle weight",
923
+ sql: "migrations and Unsafe raw SQL calls, in the modules that hold them",
921
924
  env: "env files, contracts and Dockerfiles, for the whole repository (run from its root)",
922
925
  "runtime-analysis": "Lighthouse, web vitals",
923
926
  arch: "architecture boundaries"
@@ -1100,10 +1103,12 @@ function parseEnvLevel(value) {
1100
1103
  var envLevel = targets.some((target) => REPOSITORY_TARGETS.includes(target)) ? parseEnvLevel(process.env.SENTINEL_ENV_LEVEL) : DEFAULT_ENV_LEVEL;
1101
1104
  var githubActions = process.env.GITHUB_ACTIONS === "true";
1102
1105
  var targetsExplicit = !(opts.all || namedTargets.length === 0);
1103
- if (namedTargets.includes("static-analysis") && (verb === "report" || verb === "run" && opts.json)) {
1104
- program.error(
1105
- `sentinel: --static-analysis writes its own report, so ${verb === "report" ? "--report" : "--json"} has nothing to add to it. Run it bare for the console report, or with --output json|html|markdown for the files.`
1106
- );
1106
+ for (const reporting of ["static-analysis", "sql"]) {
1107
+ if (namedTargets.includes(reporting) && (verb === "report" || verb === "run" && opts.json)) {
1108
+ program.error(
1109
+ `sentinel: --${reporting} writes its own report, so ${verb === "report" ? "--report" : "--json"} has nothing to add to it. Run it bare for the console report, or with --output json|html|markdown for the files.`
1110
+ );
1111
+ }
1107
1112
  }
1108
1113
  var maxDiagnostics = Number(opts.maxDiagnostics);
1109
1114
  if (!Number.isInteger(maxDiagnostics) || maxDiagnostics < 0) {
@@ -180,9 +180,19 @@ function ensureReleaseAgeAllowList(root, dryRun) {
180
180
  return `allow-listed ${own} under ${RELEASE_AGE_KEY} in ${WORKSPACE_YAML}`;
181
181
  }
182
182
  var GIT_IGNORE = ".gitignore";
183
- var REPORT_DIR_NAME = "static-analysis-report";
184
- var REPORT_PATTERN = `${REPORT_DIR_NAME}/`;
185
- var REPORT_HEADER = "# @hublo/sentinel: static analysis reports, written inside each module";
183
+ var REPORT_DIRS = {
184
+ "static-analysis": {
185
+ dir: "static-analysis-report",
186
+ header: "# @hublo/sentinel: static analysis reports, written inside each module",
187
+ label: "the static analysis role"
188
+ },
189
+ sql: {
190
+ dir: "sql-report",
191
+ header: "# @hublo/sentinel: sql reports, written inside each module",
192
+ label: "the sql role"
193
+ }
194
+ };
195
+ var ignores = (text, dir) => text.split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === dir);
186
196
  var PRETTIER_IGNORE = ".prettierignore";
187
197
  var EXCLUSION_HEADER = "# @hublo/sentinel: modules formatted by oxfmt, not by the root Prettier";
188
198
  var ROOT_PRETTIER_CONFIGS = [
@@ -230,19 +240,21 @@ ${pattern}
230
240
  }
231
241
  return `excluded ${rel} from the root Prettier (${PRETTIER_IGNORE}): it formats itself now`;
232
242
  }
233
- function ensureReportIgnored(root, dryRun) {
243
+ function ensureReportIgnored(root, role, dryRun) {
244
+ const entry = REPORT_DIRS[role];
245
+ if (entry === void 0) return void 0;
246
+ const pattern = `${entry.dir}/`;
234
247
  const path = join2(root, GIT_IGNORE);
235
248
  const existing = existsSync2(path) ? readFileSync2(path, "utf8") : "";
236
- const already = existing.split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === REPORT_DIR_NAME);
237
- if (already) return void 0;
238
- if (dryRun) return `would ignore ${REPORT_PATTERN} in the root ${GIT_IGNORE}`;
249
+ if (ignores(existing, entry.dir)) return void 0;
250
+ if (dryRun) return `would ignore ${pattern} in the root ${GIT_IGNORE}`;
239
251
  const prefix = existing.trim() === "" ? "" : `${existing.replace(/\n*$/, "")}
240
252
 
241
253
  `;
242
- writeFileSync(path, `${prefix}${REPORT_HEADER}
243
- ${REPORT_PATTERN}
254
+ writeFileSync(path, `${prefix}${entry.header}
255
+ ${pattern}
244
256
  `);
245
- return `ignored ${REPORT_PATTERN} in the root ${GIT_IGNORE}`;
257
+ return `ignored ${pattern} in the root ${GIT_IGNORE}`;
246
258
  }
247
259
  function ensureWorkspacePrep(opts) {
248
260
  const dryRun = Boolean(opts.dryRun);
@@ -250,7 +262,7 @@ function ensureWorkspacePrep(opts) {
250
262
  ensureI18nextSingleton(opts.root, dryRun),
251
263
  ensureReleaseAgeAllowList(opts.root, dryRun),
252
264
  opts.formattedModule === void 0 ? void 0 : ensureFormatterExclusion(opts.root, opts.formattedModule, dryRun),
253
- opts.analysedModule === true ? ensureReportIgnored(opts.root, dryRun) : void 0
265
+ ...Object.keys(REPORT_DIRS).filter((role) => opts.adoptedRoles?.includes(role) === true).map((role) => ensureReportIgnored(opts.root, role, dryRun))
254
266
  ].filter((message) => message !== void 0);
255
267
  }
256
268
  function inspectWorkspacePrep(root) {
@@ -283,11 +295,13 @@ function inspectWorkspacePrep(root) {
283
295
  }
284
296
  const ignorePath = join2(root, GIT_IGNORE);
285
297
  if (existsSync2(ignorePath)) {
286
- const ignored = readFileSync2(ignorePath, "utf8").split("\n").some((line) => line.trim().replace(/^\//, "").replace(/\/$/, "") === REPORT_DIR_NAME);
287
- if (ignored) {
298
+ const ignoreText = readFileSync2(ignorePath, "utf8");
299
+ for (const [role, entry] of Object.entries(REPORT_DIRS)) {
300
+ if (!ignores(ignoreText, entry.dir)) continue;
301
+ const pattern = `${entry.dir}/`;
288
302
  entries.push({
289
- rule: `${GIT_IGNORE} \u2192 ${REPORT_PATTERN}`,
290
- reason: `the static analysis role writes its json and html into \`<module>/${REPORT_PATTERN}\`, and one unanchored line at the root covers every module instead of creating a \`${GIT_IGNORE}\` in each one. Unlike the override above it changes no resolution and no build, so a stale one costs a single unused line. It retires when no module declares a \`static-analysis\` script any more, which the adoption report counts and this read deliberately does not: it would have to sweep every module.`
303
+ rule: `${GIT_IGNORE} \u2192 ${pattern}`,
304
+ reason: `${entry.label} writes its report files into \`<module>/${pattern}\`, and one unanchored line at the root covers every module instead of creating a \`${GIT_IGNORE}\` in each one. Unlike the override above it changes no resolution and no build, so a stale one costs a single unused line. It retires when no module declares a \`${role}\` script any more, which the adoption report counts and this read deliberately does not: it would have to sweep every module.`
291
305
  });
292
306
  }
293
307
  }
@@ -318,4 +332,4 @@ export {
318
332
  ensureWorkspacePrep,
319
333
  inspectWorkspacePrep
320
334
  };
321
- //# sourceMappingURL=chunk-ZNANJEMK.js.map
335
+ //# sourceMappingURL=chunk-JT7ZMH44.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/shared/package-json.ts","../src/core/settings.ts","../src/core/workspace-prep.ts"],"sourcesContent":["/**\n * package.json helpers, shared by the CLI and the engine.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { basename, dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * sentinel's OWN version, for `--version`. We must NOT use\n * `process.env.npm_package_version`, that is the version of whatever script\n * invoked us (an app's package.json, or nothing). Instead walk up from this\n * module to the nearest package.json, which is always sentinel's own, whether\n * running from source or the bundled dist.\n */\n/**\n * sentinel's OWN name + version, read by walking up from this module to the nearest\n * package.json. Used both for `--version` and to pin the exact dependency `--init`\n * writes into an adopted module, so a module always references the version that adopted it.\n */\nexport function readOwnPackage(): { name: string; version: string; bin?: string } {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n const pkgPath = join(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as {\n name?: string\n version?: string\n bin?: string | Record<string, string>\n }\n if (typeof pkg.version === 'string') {\n // The bin PATH, not the command name: a package that adopts itself has to invoke\n // its own build output, because the `.bin` shim does not exist yet (see below).\n const bin = typeof pkg.bin === 'string' ? pkg.bin : Object.values(pkg.bin ?? {})[0]\n return { name: pkg.name ?? '@hublo/sentinel', version: pkg.version, bin }\n }\n } catch {\n // Malformed package.json; keep walking up.\n }\n }\n const parent = dirname(dir)\n if (parent === dir) return { name: '@hublo/sentinel', version: '0.0.0' } // filesystem root\n dir = parent\n }\n}\n\nexport function readOwnVersion(): string {\n return readOwnPackage().version\n}\n\n/**\n * The directory sentinel's own `package.json` sits in, for the files it SHIPS beside its code.\n *\n * ⛔ Walked up to, never computed from a count of `..`. The emitted layout is not ours to predict:\n * `tsup` bundles the source into chunks whose depth has nothing to do with the source tree's, and\n * it moves code between them from one build to the next. A relative path from `import.meta.url` is\n * therefore right in `src/` and wrong in `dist/`, which is exactly the failure\n * `roles/test/shared-test-config.ts` records at length after it cost a module 83 passing tests.\n *\n * Measured here: `plugins/sonar-cognitive.js` resolved through a four-segment relative path existed\n * when run from source and did not after the build, and the only symptom was the whole size pass\n * reporting \"oxlint could not be run\".\n */\nexport function ownPackageDir(): string {\n let dir = dirname(fileURLToPath(import.meta.url))\n for (;;) {\n if (existsSync(join(dir, 'package.json'))) return dir\n const parent = dirname(dir)\n if (parent === dir) return dir\n dir = parent\n }\n}\n\n/**\n * Read a module's package.json for framework detection; tolerant of a missing or\n * malformed file (returns `{}`, so detection falls through to the `node` default).\n */\nexport function readProjectPackageJson(dir: string): {\n /** The package name, which is also what nx calls the project when there is no `project.json`. */\n name?: string\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n /**\n * How the module's `.js`/`.ts` files are loaded. It decides whether a Vite config can import\n * an ESM-only package at all, which is why the build role reads it before rewriting one.\n */\n type?: string\n /**\n * What nx alone needs per target, which every role writes here and none could read back.\n *\n * Typed loosely on purpose: this reader is shared by every role and each one knows the shape of\n * its own target. Declared at all because a role that WRITES a block and then has to cast to\n * read it is one refactor away from reading a key it never wrote.\n */\n nx?: { targets?: Record<string, Record<string, unknown>> }\n /**\n * The npm scripts, which several roles read to know what a module can DO rather than what it is.\n *\n * ⚠️ Added when the bundle pass had to tell two silences apart: a module that declares a build\n * and produced no manifest is a defect to act on, a module that declares none has nothing to\n * measure. Without this the two shared one sentence, and it told a front team their application\n * ships no bundle.\n */\n scripts?: Record<string, string>\n} {\n const path = join(dir, 'package.json')\n if (!existsSync(path)) return {}\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as Record<string, never>\n } catch {\n process.stderr.write(`sentinel: could not parse ${path}; ignoring for detection.\\n`)\n return {}\n }\n}\n\n/**\n * The nx project name for a module, read from its `project.json`, or undefined if\n * there is none/unreadable. Used when `--init` has to scaffold a `package.json`\n * for a module that only has a `project.json` (common for nx apps/services): the\n * scaffolded file borrows this name so it is a valid, uniquely-named workspace\n * package. Reusable by any tool that scaffolds, not just TypeScript.\n */\nexport function readNxProjectName(dir: string): string | undefined {\n const path = join(dir, 'project.json')\n if (!existsSync(path)) return undefined\n try {\n const parsed = JSON.parse(readFileSync(path, 'utf8')) as { name?: unknown }\n return typeof parsed.name === 'string' ? parsed.name : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * What nx calls this module, resolved the way nx itself resolves it.\n *\n * The precedence is `project.json`, then `package.json`, then the directory, and only the\n * first and last of those were being consulted. A module with no `project.json` therefore\n * answered with its DIRECTORY while nx answered with its package name, and the two disagree\n * in the real repo: `apps/front/hr-management` is `front-hr-management` to nx, as is\n * `apps/front/storybook-app`.\n *\n * That gap is not cosmetic, because this name is what `--module` is matched against. The\n * `serve` script `--init` writes carries `--module <name>`, so a module in that shape was\n * adopted with a script naming a project the workspace does not contain, and `pnpm run serve`\n * failed the day it was adopted with nothing having reported it.\n *\n * One function so the two ends cannot drift again: whoever WRITES the name and whoever\n * RESOLVES it now read the same source.\n */\nexport function moduleName(dir: string): string {\n const declared = readProjectPackageJson(dir).name\n return readNxProjectName(dir) ?? (declared === undefined ? basename(dir) : declared)\n}\n","/**\n * Tunable settings: the knobs you would actually change. The fixed vocabulary and\n * its types live in `domain.ts`.\n *\n * Note: the preset is DETECTED from a module's dependencies (see\n * `detect-framework.ts`), deterministically, `node` when no framework dep is present.\n * `--preset` overrides the detection (recommended for `--init`, since hoisted deps\n * can make detection return `node`). The detection table lives in `detect-framework.ts`.\n */\n\n/** A file that marks a workspace root; sentinel refuses to operate there. */\nexport const WORKSPACE_ROOT_MARKER = 'nx.json'\n\n/**\n * How many structured diagnostics a report embeds per module, when the caller does not say.\n *\n * A cap, not a limit on what is counted: the totals stay exact and `diagnosticsTruncated`\n * says when rows were dropped, so a bounded envelope never reads as a clean module. Shared\n * by every role, because a consumer reading `--json` across roles should not have to learn\n * a different cap for each one. `--max-diagnostics 0` means no cap.\n */\nexport const DEFAULT_MAX_DIAGNOSTICS = 100\n","/**\n * Workspace-level preparation that `--init` applies once, at the workspace root, so an\n * adopted module actually installs and resolves cleanly. `--init` writes a module's own\n * files; this is the small, deliberate exception where it also touches the root, because\n * \"set this module up\" is not honest if the workspace it lives in cannot then install or\n * resolve it.\n *\n * Kept intentionally narrow (YAGNI): it applies the specific fixes a workspace's OWN\n * config shows it needs, and is a no-op everywhere else. It is NOT a speculative dedupe\n * engine, when a second, different case appears we generalize from real cases instead of\n * predicting them. The two fixes today:\n *\n * - i18next singleton override. If the root declares a second TypeScript via the\n * `@typescript/native` alias (a repo mid-migration running two TypeScripts), adopting a\n * module re-resolves pnpm and i18next, which carries an optional type-only `typescript`\n * peer, forks into two peer-keyed variants. That forks react-i18next into two React\n * contexts and breaks translation-singleton tests. Pinning i18next's `typescript` peer\n * to the declared TS collapses it to one. Read from the root's own declaration, so it\n * tracks the version and disappears (no-op) once the migration removes the second TS.\n * Written to `pnpm-workspace.yaml`, the only place current pnpm reads overrides from.\n *\n * - release-age allow-list. If the root uses pnpm's `minimumReleaseAgeExclude` gate, a\n * freshly published sentinel is younger than the gate and will not install; allow-list\n * it. Only touched when the gate is actually configured.\n *\n * - root formatter exclusion. A module that has adopted the FORMAT role is formatted by\n * oxfmt, from its own config. The root Prettier does not know that and still owns every\n * file in the repo, so `nx format:write` or `prettier --write .` from the root reformats\n * the module back to the ROOT's style, and the next `pnpm run format` in the module\n * reverses it. Two formatters fighting over the same files, with whichever ran last\n * winning, is the exact state adoption removes INSIDE a module, and it has to be removed\n * at the root too. So the module is excluded in the root `.prettierignore` as it adopts,\n * and the root's own config is otherwise untouched: it still serves every module that has\n * not migrated.\n *\n * All three edits are idempotent and defensive: absent the trigger (no second TypeScript, no\n * release-age gate, no root Prettier) each is skipped, so the step is safe on any workspace.\n */\nimport { existsSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join, relative } from 'node:path'\n\nimport { readOwnPackage } from '../shared/package-json.js'\n\nimport { WORKSPACE_ROOT_MARKER } from './settings.js'\n\nconst OVERRIDE_KEY = 'i18next>typescript'\nconst NATIVE_TS_ALIAS = '@typescript/native' // `npm:typescript@^7.x`: a workspace's second, real TS\nconst WORKSPACE_YAML = 'pnpm-workspace.yaml'\nconst RELEASE_AGE_KEY = 'minimumReleaseAgeExclude'\nconst LIST_ITEM = /^(\\s*)-\\s+(.*?)\\s*$/\nconst MAP_ENTRY = /^(\\s+)(.*?):\\s+(.*?)\\s*$/\n/** A line yaml ignores inside a block: blank, or a comment at any indentation. */\nconst BLANK_OR_COMMENT = /^\\s*(#.*)?$/\n/** A value's trailing ` # comment`, kept apart so an update rewrites the value and nothing else. */\nconst INLINE_COMMENT = /^(.*?)(\\s+#.*)?$/\n\ninterface RootPackageJson {\n dependencies?: Record<string, string>\n devDependencies?: Record<string, string>\n pnpm?: { overrides?: Record<string, string> }\n}\n\n/** Walk up from a module directory to the workspace root (the dir holding the marker). */\nexport function findWorkspaceRoot(startDir: string): string | undefined {\n let dir = startDir\n for (;;) {\n if (existsSync(join(dir, WORKSPACE_ROOT_MARKER))) return dir\n const parent = dirname(dir)\n if (parent === dir) return undefined\n dir = parent\n }\n}\n\n/**\n * The TypeScript version to pin i18next's peer to, read from the root's own\n * `@typescript/native` alias (`npm:typescript@^7.0.2` -> `7.0.2`). Returns undefined when\n * the alias is absent (no second TypeScript, so no fork to fix).\n */\nfunction declaredNativeTs(pkg: RootPackageJson): string | undefined {\n const spec = pkg.dependencies?.[NATIVE_TS_ALIAS] ?? pkg.devDependencies?.[NATIVE_TS_ALIAS]\n if (!spec) return undefined\n const version = spec.slice(spec.lastIndexOf('@') + 1).replace(/^[\\^~>=<\\s]+/, '')\n return version || undefined\n}\n\n/**\n * Ensure the i18next singleton override matches the declared second TypeScript. No-op when\n * the workspace runs a single TypeScript (no `@typescript/native`). Returns a message when\n * it changed (or would change, under dryRun), else undefined.\n *\n * The override is written to `pnpm-workspace.yaml`, never to `package.json#pnpm`: pnpm 11\n * stopped reading the `pnpm` field and does so SILENTLY, with no warning and no deprecation\n * (pnpm/pnpm#11536), so an override left in `package.json` is simply not applied. The yaml is\n * read by pnpm 10 and 11 alike (https://pnpm.io/settings), which is why there is one target\n * here rather than a version-dependent fallback.\n */\nfunction ensureI18nextSingleton(root: string, dryRun: boolean): string | undefined {\n const pkgPath = join(root, 'package.json')\n if (!existsSync(pkgPath)) return undefined\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as RootPackageJson\n const want = declaredNativeTs(pkg)\n if (!want) return undefined // single TypeScript: nothing forks\n\n const yamlPath = join(root, WORKSPACE_YAML)\n if (!existsSync(yamlPath)) return undefined // no workspace file: nowhere pnpm would read it\n const lines = readFileSync(yamlPath, 'utf8').split('\\n')\n const entry = findOverrideEntry(lines)\n if (entry.inline) {\n // Said, not skipped silently: the fork this override prevents is still there.\n return `did not pin ${OVERRIDE_KEY} to ${want}: \\`overrides:\\` in ${WORKSPACE_YAML} is written inline, add \\`${OVERRIDE_KEY}: ${want}\\` to it by hand (i18next singleton)`\n }\n if (entry.valueIdx !== undefined && entry.value === want) return undefined // already pinned\n if (dryRun) return `would pin ${OVERRIDE_KEY} to ${want} in ${WORKSPACE_YAML} (i18next singleton)`\n\n applyOverride(lines, entry, want)\n writeFileSync(yamlPath, lines.join('\\n'))\n return `pinned ${OVERRIDE_KEY} to ${want} in ${WORKSPACE_YAML} (i18next singleton)`\n}\n\n/** Where the override sits in the yaml, if at all, plus where a new one would be inserted. */\ninterface OverrideEntry {\n /** Index of the `OVERRIDE_KEY` line, when the key is already declared. */\n valueIdx?: number\n /** Its current value, unquoted, without an inline comment. */\n value?: string\n /** The key exactly as the file spells it (quoted or not), so an update keeps that spelling. */\n rawKey?: string\n /** The value's inline comment, with its leading whitespace, so an update keeps it. */\n comment?: string\n /** Index of the `overrides:` key line, when the block exists. */\n blockIdx?: number\n /** Index of the block's last entry, so an insertion keeps the block contiguous. */\n lastEntryIdx?: number\n /** Indentation the block's entries use. */\n indent: string\n /** `overrides:` is written inline (`overrides: {}`): a line edit cannot add to it safely. */\n inline?: boolean\n}\n\nconst unquote = (text: string): string => text.replace(/^['\"]|['\"]$/g, '')\nconst indentOf = (line: string): number => line.length - line.trimStart().length\n\n/**\n * The indexes of the lines that belong to the top-level block opened at `keyIdx`, blank lines and\n * comments left out.\n *\n * ⚠️ A comment or a blank line never ends a block, at any indentation: yaml ignores both, and the\n * monorepo's `overrides:` OPENS with a two-line comment. An earlier scan stopped at the first line\n * that was not an entry, so on that file it never saw `i18next>typescript`, 85 entries down, and\n * wrote it a second time: a duplicate mapping key, which yaml rejects and `pnpm run format` failed\n * on. The block ends at the first other line indented no deeper than the key. A list may sit at\n * the key's own indentation (`key:` then `- item`), so `sameIndentItems` keeps those lines in.\n */\nfunction blockLines(lines: string[], keyIdx: number, sameIndentItems = false): number[] {\n const keyIndent = indentOf(lines[keyIdx] ?? '')\n const inside: number[] = []\n for (let i = keyIdx + 1; i < lines.length; i++) {\n const line = lines[i] ?? ''\n if (BLANK_OR_COMMENT.test(line)) continue\n const indent = indentOf(line)\n const ownItem = sameIndentItems && indent === keyIndent && /^\\s*-(\\s|$)/.test(line)\n if (indent <= keyIndent && !ownItem) break // the next key: the block ended\n inside.push(i)\n }\n return inside\n}\n\n/**\n * Locate the `overrides:` block and the i18next key inside it. A targeted text read rather\n * than a yaml parse, for the same reason `ensureReleaseAgeAllowList` does it: this file is\n * hand-maintained and round-tripping it through a parser would drop its comments and ordering.\n */\nfunction findOverrideEntry(lines: string[]): OverrideEntry {\n const blockIdx = lines.findIndex((line) => /^overrides:\\s*(#.*)?$/.test(line))\n if (blockIdx === -1) {\n // Declared, but inline (`overrides: {}`). Opening a second block would be a duplicate key.\n const inline = lines.some((line) => /^overrides:\\s*[^\\s#]/.test(line))\n return inline ? { indent: ' ', inline } : { indent: ' ' }\n }\n\n const inside = blockLines(lines, blockIdx)\n // The entries are the lines at the block's own indentation; anything deeper continues one.\n const entryIndent = inside.length > 0 ? indentOf(lines[inside[0] ?? blockIdx] ?? '') : 2\n let lastEntryIdx = blockIdx\n let entry: Omit<OverrideEntry, 'blockIdx' | 'lastEntryIdx' | 'indent'> = {}\n for (const i of inside) {\n lastEntryIdx = i // past a continuation line too, so an insertion never splits an entry\n const match = lines[i]?.match(MAP_ENTRY)\n if (!match || indentOf(lines[i] ?? '') !== entryIndent) continue\n const rawKey = match[2] ?? ''\n if (entry.valueIdx !== undefined || unquote(rawKey) !== OVERRIDE_KEY) continue\n const [, value = '', comment] = (match[3] ?? '').match(INLINE_COMMENT) ?? []\n entry = { valueIdx: i, value: unquote(value), rawKey, comment }\n }\n return { ...entry, blockIdx, lastEntryIdx, indent: ' '.repeat(entryIndent) }\n}\n\n/** Update the key in place, append it to an existing block, or open a block at the end. */\nfunction applyOverride(lines: string[], entry: OverrideEntry, want: string): void {\n if (entry.valueIdx !== undefined) {\n // Only the value changes: the key keeps its spelling, the value its inline comment.\n lines[entry.valueIdx] =\n `${entry.indent}${entry.rawKey ?? `'${OVERRIDE_KEY}'`}: ${want}${entry.comment ?? ''}`\n return\n }\n const line = `${entry.indent}'${OVERRIDE_KEY}': ${want}`\n if (entry.lastEntryIdx !== undefined) {\n lines.splice(entry.lastEntryIdx + 1, 0, line)\n return\n }\n // No `overrides:` block at all: open one, keeping a single trailing newline.\n while (lines.length > 0 && lines[lines.length - 1] === '') lines.pop()\n lines.push('overrides:', line, '')\n}\n\n/**\n * Ensure sentinel is allow-listed under `minimumReleaseAgeExclude` so a fresh publish\n * installs. No-op when the workspace has no such gate. Targeted text edit so comments and\n * formatting are preserved. Returns a message when it changed (or would), else undefined.\n */\nfunction ensureReleaseAgeAllowList(root: string, dryRun: boolean): string | undefined {\n const yamlPath = join(root, WORKSPACE_YAML)\n if (!existsSync(yamlPath)) return undefined\n const own = readOwnPackage().name\n const lines = readFileSync(yamlPath, 'utf8').split('\\n')\n const keyIdx = lines.findIndex((line) => line.replace(/\\s+$/, '') === `${RELEASE_AGE_KEY}:`)\n if (keyIdx === -1) return undefined // no release-age gate in use\n\n // The whole list, comments included: the same early stop as the overrides scan listed\n // sentinel a second time below a comment (see `blockLines`).\n let lastItemIdx = keyIdx\n let indent = ' '\n for (const i of blockLines(lines, keyIdx, true)) {\n lastItemIdx = i\n const match = lines[i]?.match(LIST_ITEM)\n if (!match) continue\n indent = match[1] ?? indent\n const [, item = ''] = (match[2] ?? '').match(INLINE_COMMENT) ?? []\n if (unquote(item) === own) return undefined // already listed\n }\n if (dryRun) return `would allow-list ${own} under ${RELEASE_AGE_KEY}`\n\n lines.splice(lastItemIdx + 1, 0, `${indent}- '${own}'`)\n writeFileSync(yamlPath, lines.join('\\n'))\n return `allow-listed ${own} under ${RELEASE_AGE_KEY} in ${WORKSPACE_YAML}`\n}\n\n/** The root ignore file Prettier reads, and the section sentinel owns inside it. */\nconst GIT_IGNORE = '.gitignore'\n/**\n * The roles that write report files inside a module, the directory each writes, and the header\n * its root ignore line carries. One entry per role, so a new role that writes reports adds a row\n * here and nothing else: the write, the read and the inspection below all walk this table.\n *\n * ⚠️ The static analysis header is kept byte for byte: workspaces adopted before this table hold\n * that exact line, and a reworded header would read as a missing one.\n */\nconst REPORT_DIRS: Readonly<Record<string, { dir: string; header: string; label: string }>> = {\n 'static-analysis': {\n dir: 'static-analysis-report',\n header: '# @hublo/sentinel: static analysis reports, written inside each module',\n label: 'the static analysis role',\n },\n sql: {\n dir: 'sql-report',\n header: '# @hublo/sentinel: sql reports, written inside each module',\n label: 'the sql role',\n },\n}\n\n/** Is `dir` ignored by a line of `text`, in whichever spelling a human may have used? */\nconst ignores = (text: string, dir: string): boolean =>\n text.split('\\n').some((line) => line.trim().replace(/^\\//, '').replace(/\\/$/, '') === dir)\nconst PRETTIER_IGNORE = '.prettierignore'\nconst EXCLUSION_HEADER = '# @hublo/sentinel: modules formatted by oxfmt, not by the root Prettier'\n\n/** Root Prettier configs. Their presence is what makes an exclusion meaningful. */\nconst ROOT_PRETTIER_CONFIGS = [\n '.prettierrc',\n '.prettierrc.json',\n '.prettierrc.json5',\n '.prettierrc.yml',\n '.prettierrc.yaml',\n '.prettierrc.js',\n '.prettierrc.cjs',\n '.prettierrc.mjs',\n 'prettier.config.js',\n 'prettier.config.cjs',\n 'prettier.config.mjs',\n]\n\n/**\n * Exclude a module that now formats itself from the ROOT Prettier.\n *\n * Written as a directory pattern anchored at the root (`/apps/front/x/`), which is what\n * gitignore syntax means by \"this exact directory\", so a module cannot accidentally exclude a\n * same-named directory somewhere else.\n *\n * Skipped entirely when the root has no Prettier at all: there is then nothing to conflict\n * with, and creating an ignore file for a tool the workspace does not use would be noise.\n */\nfunction ensureFormatterExclusion(\n root: string,\n moduleDir: string,\n dryRun: boolean,\n): string | undefined {\n const rel = relative(root, moduleDir).replaceAll('\\\\', '/')\n if (rel === '' || rel.startsWith('..')) return undefined // the root itself, or outside it\n\n const ignorePath = join(root, PRETTIER_IGNORE)\n const hasPrettier =\n existsSync(ignorePath) || ROOT_PRETTIER_CONFIGS.some((name) => existsSync(join(root, name)))\n if (!hasPrettier) return undefined\n\n const pattern = `/${rel}/`\n const existing = existsSync(ignorePath) ? readFileSync(ignorePath, 'utf8') : ''\n const lines = existing.split('\\n')\n // Already excluded, in whichever spelling a human may have used.\n if (lines.some((line) => line.trim().replace(/\\/$/, '') === pattern.replace(/\\/$/, ''))) {\n return undefined\n }\n if (dryRun) return `would exclude ${rel} from the root Prettier (${PRETTIER_IGNORE})`\n\n const headerIdx = lines.findIndex((line) => line.trim() === EXCLUSION_HEADER)\n if (headerIdx === -1) {\n const prefix = existing.trim() === '' ? '' : `${existing.replace(/\\n*$/, '')}\\n\\n`\n writeFileSync(ignorePath, `${prefix}${EXCLUSION_HEADER}\\n${pattern}\\n`)\n } else {\n // Keep the managed section together and sorted, so the list stays readable as it grows\n // to 150 entries and a diff shows one added line rather than a reshuffle.\n let end = headerIdx + 1\n while (end < lines.length && lines[end]?.trim().startsWith('/')) end += 1\n const managed = [...lines.slice(headerIdx + 1, end), pattern].sort()\n writeFileSync(\n ignorePath,\n [...lines.slice(0, headerIdx + 1), ...managed, ...lines.slice(end)].join('\\n'),\n )\n }\n return `excluded ${rel} from the root Prettier (${PRETTIER_IGNORE}): it formats itself now`\n}\n\n/**\n * Apply every workspace-level fix the given root needs. Returns the human-readable\n * messages for what changed (empty when nothing did). Under dryRun nothing is written and\n * the messages describe what would change.\n *\n * `formattedModule` is the module that just adopted the FORMAT role, when one did. Absent\n * for an `--init` that adopted neither lint nor format (`--init --typescript`, say), because\n * a module that has not adopted the formatter must keep being formatted by the root. There is\n * no lint-only `--init` any more: naming lint adopts format with it (see `run-init`), so the\n * module that gets oxlint also gets oxfmt and this exclusion.\n */\n/**\n * Ignore the static analysis report directory, once, at the ROOT.\n *\n * ## Why the root and not each module\n *\n * The role writes its json and html into `<module>/static-analysis-report/`, so the obvious place\n * for the rule is the module. It was there first, and it was wrong twice over: it CREATES a\n * `.gitignore` in a module that had none, which is a structural change to someone else's module for\n * one line, and it repeats that line once per adopting module. The root already ignores output this\n * way, with `/dist` and `/coverage`.\n *\n * ⚠️ The pattern is deliberately NOT anchored. `/dist` matches only the root's `dist`; the report\n * directory lives inside a module, so `static-analysis-report/` has to match at any depth. Getting\n * that backwards would leave every adopting module with an untracked directory, which is the exact\n * defect this guards against.\n *\n * ## Why this root write is not the dangerous kind\n *\n * The comment on `inspectWorkspacePrep` is right that root writes are what nobody sees afterwards,\n * and the i18next override earned that warning: it re-resolved a module from a pull request that\n * touched none of its files. An ignore line changes no resolution, no build and no install. If it\n * ever goes stale the cost is one unused line, which is why it is reported rather than feared.\n */\nfunction ensureReportIgnored(root: string, role: string, dryRun: boolean): string | undefined {\n const entry = REPORT_DIRS[role]\n if (entry === undefined) return undefined\n const pattern = `${entry.dir}/`\n const path = join(root, GIT_IGNORE)\n const existing = existsSync(path) ? readFileSync(path, 'utf8') : ''\n if (ignores(existing, entry.dir)) return undefined\n if (dryRun) return `would ignore ${pattern} in the root ${GIT_IGNORE}`\n\n const prefix = existing.trim() === '' ? '' : `${existing.replace(/\\n*$/, '')}\\n\\n`\n writeFileSync(path, `${prefix}${entry.header}\\n${pattern}\\n`)\n return `ignored ${pattern} in the root ${GIT_IGNORE}`\n}\n\nexport function ensureWorkspacePrep(opts: {\n root: string\n dryRun?: boolean\n formattedModule?: string\n /** The roles that adopted on this run: a role writing reports earns its ignore line. */\n adoptedRoles?: readonly string[]\n}): string[] {\n const dryRun = Boolean(opts.dryRun)\n return [\n ensureI18nextSingleton(opts.root, dryRun),\n ensureReleaseAgeAllowList(opts.root, dryRun),\n opts.formattedModule === undefined\n ? undefined\n : ensureFormatterExclusion(opts.root, opts.formattedModule, dryRun),\n ...Object.keys(REPORT_DIRS)\n .filter((role) => opts.adoptedRoles?.includes(role) === true)\n .map((role) => ensureReportIgnored(opts.root, role, dryRun)),\n ].filter((message): message is string => message !== undefined)\n}\n\n/**\n * One standing change sentinel has made to the workspace ROOT, and whether it is still earned.\n *\n * This exists because the three root writes are the only thing sentinel does that nobody can\n * see afterwards. `--init` announces each one on the run that makes it, and then it is a line\n * in someone else's file forever. Two consequences already bit us.\n *\n * The `i18next>typescript` override re-resolved `apps/front/console` from a PR that touched no\n * file under it, so CODEOWNERS pulled nobody and its owners learned about it afterwards.\n *\n * And every one of them is TEMPORARY with its removal condition written in prose. That failed\n * three times in one week: `SENTINEL_TAG=alpha` in the migration-page workflow kept building\n * with a pre-release long after 1.1.0 went stable and reported `Format 0/439` for 15 adopted\n * modules; ADR 0042 and its RFC both sat mid-flight past their deadline; and this release-age\n * exclusion is still waiting on \"once sentinel's release cadence settles\". Nothing failed when\n * any of them expired, because a comment cannot fail.\n *\n * So each entry carries the condition that JUSTIFIES it, evaluated now rather than described.\n * A trigger that has gone away makes the entry dead config, and dead config is something a\n * command can say out loud instead of something a reader has to notice.\n *\n * Read-only, and offline: it inspects the same files `--init` writes and nothing else. What it\n * deliberately does NOT claim is anything needing the npm registry — whether a published\n * version is old enough to clear the release-age gate is not knowable from the repo, so it is\n * stated as the standing exemption it is rather than guessed at.\n */\nexport interface WorkspacePrepEntry {\n /** `rule` to match the shape the shared renderer already prints as a labelled block. */\n rule: string\n /** What it does, whether its trigger still holds, and what would retire it. */\n reason: string\n}\n\n/** The root-level changes sentinel maintains here, each with its justification checked now. */\nexport function inspectWorkspacePrep(root: string): WorkspacePrepEntry[] {\n const entries: WorkspacePrepEntry[] = []\n // Tolerant, unlike the write path above, and the difference is deliberate. `--init` should\n // fail loudly on a root it cannot parse, because it is about to edit it. `--inspect` is a\n // read verb that sweeps 441 modules, and one malformed root file must not take the whole\n // sweep down: the modules still have honest answers to give. Caught by its own test.\n let pkg: RootPackageJson = {}\n const pkgPath = join(root, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) as RootPackageJson\n } catch {\n pkg = {}\n }\n }\n\n const yamlPath = join(root, WORKSPACE_YAML)\n const yaml = existsSync(yamlPath) ? readFileSync(yamlPath, 'utf8') : undefined\n\n const pinned = yaml === undefined ? undefined : findOverrideEntry(yaml.split('\\n')).value\n if (pinned !== undefined) {\n const stillForks = declaredNativeTs(pkg)\n entries.push({\n rule: `${WORKSPACE_YAML} → overrides.${OVERRIDE_KEY}`,\n reason:\n stillForks === undefined\n ? `pinned to ${pinned}, but the root no longer declares ${NATIVE_TS_ALIAS}, so nothing ` +\n `forks any more. This override is now dead config and can be removed.`\n : `pinned to ${pinned}, matching the second TypeScript the root declares ` +\n `(${NATIVE_TS_ALIAS}). It re-resolves i18next for EVERY module that depends on it, ` +\n `not only adopted ones. It retires with the second TypeScript.`,\n })\n }\n\n // A copy left in `package.json#pnpm` by an older sentinel, or by hand. Reported because it\n // is INERT rather than redundant: pnpm 11 dropped the `pnpm` field with no warning\n // (pnpm/pnpm#11536), so it reads as protection that is not applied.\n const legacy = pkg.pnpm?.overrides?.[OVERRIDE_KEY]\n if (legacy !== undefined) {\n entries.push({\n rule: `package.json → pnpm.overrides.${OVERRIDE_KEY}`,\n reason:\n `pinned to ${legacy}, but pnpm 11 no longer reads the \\`pnpm\\` field of package.json ` +\n `and says nothing about it, so this override is not applied. Move it to ` +\n `${WORKSPACE_YAML} under \\`overrides:\\`, which pnpm 10 and 11 both read.`,\n })\n }\n\n const ignorePath = join(root, GIT_IGNORE)\n if (existsSync(ignorePath)) {\n const ignoreText = readFileSync(ignorePath, 'utf8')\n for (const [role, entry] of Object.entries(REPORT_DIRS)) {\n if (!ignores(ignoreText, entry.dir)) continue\n const pattern = `${entry.dir}/`\n entries.push({\n rule: `${GIT_IGNORE} → ${pattern}`,\n reason:\n `${entry.label} writes its report files into ` +\n `\\`<module>/${pattern}\\`, and one unanchored line at the root covers every module ` +\n `instead of creating a \\`${GIT_IGNORE}\\` in each one. Unlike the override above it changes ` +\n `no resolution and no build, so a stale one costs a single unused line. It retires when no ` +\n `module declares a \\`${role}\\` script any more, which the adoption report counts ` +\n `and this read deliberately does not: it would have to sweep every module.`,\n })\n }\n }\n\n const own = readOwnPackage().name\n if (yaml !== undefined) {\n const listed = new RegExp(`^\\\\s*-\\\\s*['\"]?${own.replace('/', '\\\\/')}['\"]?\\\\s*$`, 'm').test(yaml)\n if (listed) {\n const gated = new RegExp(`^\\\\s*minimumReleaseAge\\\\s*:`, 'm').test(yaml)\n entries.push({\n rule: `${WORKSPACE_YAML} → ${RELEASE_AGE_KEY}: ${own}`,\n reason: gated\n ? `${own} is exempt from this workspace's release-age gate, so a freshly published ` +\n `version installs instead of being held. That is a standing exemption from a ` +\n `supply-chain control: the exposure is one bump wide, since the version is pinned ` +\n `and the lockfile carries its integrity, so a re-publish of the same version does ` +\n `not pass. Retire it once a bump can simply wait out the window.`\n : `${own} is allow-listed, but this workspace no longer sets minimumReleaseAge, so ` +\n `there is no gate to be exempt from. This entry is now dead config and can be removed.`,\n })\n }\n }\n\n return entries\n}\n"],"mappings":";AAGA,SAAS,YAAY,oBAAoB;AACzC,SAAS,UAAU,SAAS,YAAY;AACxC,SAAS,qBAAqB;AAcvB,SAAS,iBAAkE;AAChF,MAAI,MAAM,QAAQ,cAAc,YAAY,GAAG,CAAC;AAChD,aAAS;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AACrC,YAAM,UAAU,GAAG,MAAM,GAAG;AAC5B,cAAQ,KAAK;AAAA,QACX,MAAM,GAAG,UAAU,WAAM,OAAO;AAAA,QAChC,QACE,GAAG,MAAM,KAAK,4CACA,OAAO,uFACM,UAAU,sKAEd,IAAI;AAAA,MAE/B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,MAAM,eAAe,EAAE;AAC7B,MAAI,SAAS,QAAW;AACtB,UAAM,SAAS,IAAI,OAAO,kBAAkB,IAAI,QAAQ,KAAK,KAAK,CAAC,cAAc,GAAG,EAAE,KAAK,IAAI;AAC/F,QAAI,QAAQ;AACV,YAAM,QAAQ,IAAI,OAAO,+BAA+B,GAAG,EAAE,KAAK,IAAI;AACtE,cAAQ,KAAK;AAAA,QACX,MAAM,GAAG,cAAc,WAAM,eAAe,KAAK,GAAG;AAAA,QACpD,QAAQ,QACJ,GAAG,GAAG,4XAKN,GAAG,GAAG;AAAA,MAEZ,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["existsSync","readFileSync","dirname","join","existsSync","join","dirname","readFileSync"]}
@@ -0,0 +1,183 @@
1
+ import {
2
+ isPlainObject
3
+ } from "./chunk-PXTU5MPW.js";
4
+
5
+ // src/roles/sql/presets/shared.json
6
+ var shared_default = {
7
+ migrations: {
8
+ include: ["**/migrations/*/migration.sql"],
9
+ exclude: []
10
+ },
11
+ unsafe: {
12
+ includeTests: true,
13
+ tests: [
14
+ "**/{test,tests,__tests__,e2e,fixtures,mocks,__mocks__,test-utils}/**",
15
+ "**/*.{spec,test,integration-spec,e2e-spec,steps,test-util,mock}.{ts,mts,cts}"
16
+ ]
17
+ },
18
+ ignore: ["**/node_modules/**", "**/dist/**", "**/coverage/**"],
19
+ pgVersion: "16.8",
20
+ rules: {}
21
+ };
22
+
23
+ // src/roles/sql/presets/squawk-rules.json
24
+ var squawk_rules_default = {
25
+ squawk: "2.72.0",
26
+ rules: [
27
+ "adding-field-with-default",
28
+ "adding-foreign-key-constraint",
29
+ "adding-not-nullable-field",
30
+ "adding-required-field",
31
+ "adding-serial-primary-key-field",
32
+ "ban-add-column",
33
+ "ban-add-composite-attribute",
34
+ "ban-add-enum-value",
35
+ "ban-alter-database-options",
36
+ "ban-alter-domain-with-add-constraint",
37
+ "ban-alter-extension",
38
+ "ban-alter-function-options",
39
+ "ban-alter-generated-expression",
40
+ "ban-alter-identity",
41
+ "ban-alter-policy-condition",
42
+ "ban-alter-policy-roles",
43
+ "ban-alter-role-options",
44
+ "ban-alter-row-level-security",
45
+ "ban-alter-sequence-values",
46
+ "ban-alter-system-options",
47
+ "ban-alter-view-options",
48
+ "ban-char-field",
49
+ "ban-concurrent-index-creation-in-transaction",
50
+ "ban-create-domain-with-constraint",
51
+ "ban-create-policy",
52
+ "ban-detach-inheritance",
53
+ "ban-disable-trigger",
54
+ "ban-drop-column",
55
+ "ban-drop-constraint",
56
+ "ban-drop-database",
57
+ "ban-drop-default",
58
+ "ban-drop-domain",
59
+ "ban-drop-extension",
60
+ "ban-drop-function",
61
+ "ban-drop-generated-expression",
62
+ "ban-drop-index",
63
+ "ban-drop-not-null",
64
+ "ban-drop-policy",
65
+ "ban-drop-schema",
66
+ "ban-drop-sequence",
67
+ "ban-drop-table",
68
+ "ban-drop-trigger",
69
+ "ban-drop-type",
70
+ "ban-drop-view",
71
+ "ban-duplicate-column-assignments",
72
+ "ban-new-write-restriction",
73
+ "ban-replace-view-function",
74
+ "ban-replica-identity",
75
+ "ban-revoke",
76
+ "ban-set-default",
77
+ "ban-set-schema",
78
+ "ban-truncate-cascade",
79
+ "ban-uncommitted-transaction",
80
+ "changing-column-type",
81
+ "constraint-missing-not-valid",
82
+ "disallowed-unique-constraint",
83
+ "identifier-too-long",
84
+ "prefer-bigint-over-int",
85
+ "prefer-bigint-over-smallint",
86
+ "prefer-identity",
87
+ "prefer-repack",
88
+ "prefer-robust-stmts",
89
+ "prefer-text-field",
90
+ "prefer-timestamp-tz",
91
+ "renaming-column",
92
+ "renaming-object",
93
+ "renaming-table",
94
+ "require-concurrent-index-creation",
95
+ "require-concurrent-index-deletion",
96
+ "require-concurrent-partition-detach",
97
+ "require-concurrent-reindex",
98
+ "require-enum-value-ordering",
99
+ "require-lock-timeout",
100
+ "require-statement-timeout",
101
+ "require-table-schema",
102
+ "transaction-nesting"
103
+ ],
104
+ optIn: [
105
+ "ban-add-column",
106
+ "ban-add-composite-attribute",
107
+ "ban-add-enum-value",
108
+ "ban-alter-database-options",
109
+ "ban-alter-extension",
110
+ "ban-alter-function-options",
111
+ "ban-alter-generated-expression",
112
+ "ban-alter-policy-condition",
113
+ "ban-alter-policy-roles",
114
+ "ban-alter-role-options",
115
+ "ban-alter-row-level-security",
116
+ "ban-alter-sequence-values",
117
+ "ban-alter-system-options",
118
+ "ban-alter-view-options",
119
+ "ban-create-policy",
120
+ "ban-detach-inheritance",
121
+ "ban-disable-trigger",
122
+ "ban-drop-index",
123
+ "ban-drop-policy",
124
+ "ban-drop-trigger",
125
+ "ban-new-write-restriction",
126
+ "ban-replace-view-function",
127
+ "ban-replica-identity",
128
+ "ban-revoke",
129
+ "ban-set-default",
130
+ "require-table-schema"
131
+ ],
132
+ aliases: {
133
+ "prefer-timestamptz": ["prefer-timestamp-tz"],
134
+ "require-timeout-settings": ["require-lock-timeout", "require-statement-timeout"]
135
+ }
136
+ };
137
+
138
+ // src/roles/sql/preset-data.ts
139
+ var TARGET = "sql";
140
+ var SQL_CONFIG_FILE = "sql.config.mjs";
141
+ var REPORT_DIR = "sql-report";
142
+ var SCRIPTS = {
143
+ console: "sql",
144
+ json: "sql:json",
145
+ html: "sql:html"
146
+ };
147
+ var defaults = shared_default;
148
+ var squawkRules = squawk_rules_default;
149
+
150
+ // src/roles/sql/configs/define.ts
151
+ function mergeInto(base, patch) {
152
+ if (!isPlainObject(patch)) return base;
153
+ if (!isPlainObject(base)) return patch;
154
+ const out = { ...base };
155
+ for (const [key, value] of Object.entries(patch)) {
156
+ out[key] = isPlainObject(value) ? mergeInto(out[key], value) : value;
157
+ }
158
+ return out;
159
+ }
160
+ function leafPaths(patch, prefix = "") {
161
+ if (!isPlainObject(patch)) return prefix ? [prefix] : [];
162
+ return Object.entries(patch).flatMap(
163
+ ([key, value]) => leafPaths(value, prefix ? `${prefix}.${key}` : key)
164
+ );
165
+ }
166
+ function defineSql(input = {}) {
167
+ return {
168
+ ...mergeInto(defaults, input.overrides),
169
+ root: input.root ?? null,
170
+ moved: leafPaths(input.overrides).sort()
171
+ };
172
+ }
173
+
174
+ export {
175
+ TARGET,
176
+ SQL_CONFIG_FILE,
177
+ REPORT_DIR,
178
+ SCRIPTS,
179
+ defaults,
180
+ squawkRules,
181
+ defineSql
182
+ };
183
+ //# sourceMappingURL=chunk-LU4E4TVD.js.map
@@ -0,0 +1 @@
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 },\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. This first version ships the two parts that need no\n * SQL parsing of our own:\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 * Raw SQL in tagged templates (libpg-query) and the ORM chain come 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 /** 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/** Resolve a module's declaration against this role's defaults. */\nexport function defineSql(input: SqlInput = {}): ResolvedSqlConfig {\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,EACd;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;;;ACfA;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,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;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M,IAAI,GAAG,KAAK,GAAG;AAAA,EACpD;AACF;AAGO,SAAS,UAAU,QAAkB,CAAC,GAAsB;AACjE,SAAO;AAAA,IACL,GAAG,UAAU,UAAU,MAAM,SAAS;AAAA,IACtC,MAAM,MAAM,QAAQ;AAAA,IACpB,OAAO,UAAU,MAAM,SAAS,EAAE,KAAK;AAAA,EACzC;AACF;","names":[]}
@@ -1,7 +1,6 @@
1
- // src/shared/deep-merge.ts
2
- function isPlainObject(value) {
3
- return typeof value === "object" && value !== null && !Array.isArray(value);
4
- }
1
+ import {
2
+ isPlainObject
3
+ } from "./chunk-PXTU5MPW.js";
5
4
 
6
5
  // src/core/domain.ts
7
6
  var VERBS = ["run", "inspect", "init", "migrate", "validate", "report", "status"];
@@ -13,6 +12,7 @@ var TARGETS = [
13
12
  "dev",
14
13
  "test",
15
14
  "static-analysis",
15
+ "sql",
16
16
  "env",
17
17
  "runtime-analysis",
18
18
  "arch"
@@ -208,7 +208,6 @@ export {
208
208
  OUTPUT_SHAPES,
209
209
  ENV_LEVELS,
210
210
  DEFAULT_ENV_LEVEL,
211
- isPlainObject,
212
211
  REPORT_DIR,
213
212
  TARGET,
214
213
  SHAPES,
@@ -218,4 +217,4 @@ export {
218
217
  overridableSettings,
219
218
  defineStaticAnalysis
220
219
  };
221
- //# sourceMappingURL=chunk-7E6YTTAK.js.map
220
+ //# sourceMappingURL=chunk-LX7EG6PJ.js.map