@hublo/sentinel 1.7.0-alpha.31 → 1.7.0-alpha.32

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.
Files changed (45) hide show
  1. package/README.md +1 -2
  2. package/dist/bin/sentinel.js +7 -13
  3. package/dist/{chunk-FZLUCPST.js → chunk-2PRJJRJI.js} +1 -1
  4. package/dist/{chunk-XMAXE2Q2.js → chunk-APBEGLRI.js} +2 -5
  5. package/dist/chunk-APBEGLRI.js.map +1 -0
  6. package/dist/{chunk-QMIJ4ZGJ.js → chunk-LVY5NPOC.js} +2 -2
  7. package/dist/{chunk-NGLEGAEN.js → chunk-SHF46ALB.js} +1 -1
  8. package/dist/chunk-SHF46ALB.js.map +1 -0
  9. package/dist/{chunk-2DUG6GVU.js → chunk-UJ5VLEZF.js} +2338 -3917
  10. package/dist/{chunk-KKHKRY7P.js → chunk-YUZB4LRJ.js} +1 -6
  11. package/dist/chunk-YUZB4LRJ.js.map +1 -0
  12. package/dist/index.js +5 -9
  13. package/dist/roles/sql/config.js +1 -1
  14. package/dist/roles/static-analysis/config.js +1 -1
  15. package/dist/roles/test/setup/jest-parity.js +2 -2
  16. package/dist/roles/test/setup/workspace-entry.js +2 -2
  17. package/dist/{validate-GTBRD2M4.js → validate-4GMB32V7.js} +2 -2
  18. package/docs/sql-adoption.md +92 -18
  19. package/docs/typescript-traces.md +38 -2
  20. package/package.json +3 -10
  21. package/dist/chunk-F5WISUN3.js +0 -17
  22. package/dist/chunk-F5WISUN3.js.map +0 -1
  23. package/dist/chunk-KKHKRY7P.js.map +0 -1
  24. package/dist/chunk-NE3IEJBN.js +0 -59
  25. package/dist/chunk-NE3IEJBN.js.map +0 -1
  26. package/dist/chunk-NGLEGAEN.js.map +0 -1
  27. package/dist/chunk-U7G2Y6YC.js +0 -15
  28. package/dist/chunk-U7G2Y6YC.js.map +0 -1
  29. package/dist/chunk-VWASE6NN.js +0 -34
  30. package/dist/chunk-VWASE6NN.js.map +0 -1
  31. package/dist/chunk-XMAXE2Q2.js.map +0 -1
  32. package/dist/roles/runtime-analysis/config.d.ts +0 -97
  33. package/dist/roles/runtime-analysis/config.js +0 -10
  34. package/dist/roles/runtime-analysis/config.js.map +0 -1
  35. package/dist/roles/runtime-analysis/gateway.d.ts +0 -2
  36. package/dist/roles/runtime-analysis/gateway.js +0 -89
  37. package/dist/roles/runtime-analysis/gateway.js.map +0 -1
  38. package/dist/roles/runtime-analysis/mock-api.d.ts +0 -2
  39. package/dist/roles/runtime-analysis/mock-api.js +0 -43
  40. package/dist/roles/runtime-analysis/mock-api.js.map +0 -1
  41. package/docs/runtime-analysis-adoption.md +0 -198
  42. package/runtime-analysis-deps/load.mjs +0 -6
  43. package/runtime-analysis-deps/package-lock.json +0 -1766
  44. package/runtime-analysis-deps/package.json +0 -11
  45. /package/dist/{chunk-QMIJ4ZGJ.js.map → chunk-LVY5NPOC.js.map} +0 -0
@@ -186,11 +186,6 @@ var REPORT_DIRS = {
186
186
  header: "# @hublo/sentinel: static analysis reports, written inside each module",
187
187
  label: "the static analysis role"
188
188
  },
189
- "runtime-analysis": {
190
- dir: "runtime-analysis-report",
191
- header: "# @hublo/sentinel: runtime analysis reports, written inside each front",
192
- label: "the runtime analysis role"
193
- },
194
189
  sql: {
195
190
  dir: "sql-report",
196
191
  header: "# @hublo/sentinel: sql reports, written inside each module",
@@ -342,4 +337,4 @@ export {
342
337
  ensureWorkspacePrep,
343
338
  inspectWorkspacePrep
344
339
  };
345
- //# sourceMappingURL=chunk-KKHKRY7P.js.map
340
+ //# sourceMappingURL=chunk-YUZB4LRJ.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 'code-churn': {\n dir: 'code-churn-report',\n header: '# @hublo/sentinel: code churn reports, written inside each module',\n label: 'the code churn 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;AACP,UAAM,UAAU,KAAK,KAAK,cAAc;AACxC,QAAI,WAAW,OAAO,GAAG;AACvB,UAAI;AACF,cAAM,MAAM,KAAK,MAAM,aAAa,SAAS,MAAM,CAAC;AAKpD,YAAI,OAAO,IAAI,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AAG,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"]}
package/dist/index.js CHANGED
@@ -6,25 +6,21 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-2DUG6GVU.js";
9
+ } from "./chunk-UJ5VLEZF.js";
10
10
  import "./chunk-ZZMYV576.js";
11
11
  import {
12
12
  BaseAdapter
13
- } from "./chunk-FZLUCPST.js";
13
+ } from "./chunk-2PRJJRJI.js";
14
14
  import "./chunk-ZFG6P27V.js";
15
- import "./chunk-NE3IEJBN.js";
16
- import "./chunk-VWASE6NN.js";
17
15
  import "./chunk-O7REVMOC.js";
18
16
  import "./chunk-H4HAFJFZ.js";
19
17
  import "./chunk-QXFCZON7.js";
20
- import "./chunk-KKHKRY7P.js";
21
- import "./chunk-XMAXE2Q2.js";
18
+ import "./chunk-YUZB4LRJ.js";
19
+ import "./chunk-APBEGLRI.js";
22
20
  import "./chunk-TMVKYXZ3.js";
23
- import "./chunk-NGLEGAEN.js";
21
+ import "./chunk-SHF46ALB.js";
24
22
  import "./chunk-XYOIXC6A.js";
25
23
  import "./chunk-PXTU5MPW.js";
26
- import "./chunk-U7G2Y6YC.js";
27
- import "./chunk-F5WISUN3.js";
28
24
  import "./chunk-4EIY7TTR.js";
29
25
  export {
30
26
  BaseAdapter,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineSql
3
- } from "../../chunk-NGLEGAEN.js";
3
+ } from "../../chunk-SHF46ALB.js";
4
4
  import "../../chunk-PXTU5MPW.js";
5
5
  export {
6
6
  defineSql
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineStaticAnalysis
3
- } from "../../chunk-XMAXE2Q2.js";
3
+ } from "../../chunk-APBEGLRI.js";
4
4
  import "../../chunk-PXTU5MPW.js";
5
5
  export {
6
6
  defineStaticAnalysis
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  installWorkspaceSetup
3
- } from "../../../chunk-QMIJ4ZGJ.js";
3
+ } from "../../../chunk-LVY5NPOC.js";
4
4
  import {
5
5
  clearDeepMocks,
6
6
  resetDeepMocks
@@ -9,7 +9,7 @@ import {
9
9
  alreadyInstalled
10
10
  } from "../../../chunk-NUOQXAYR.js";
11
11
  import "../../../chunk-ELZHIN6E.js";
12
- import "../../../chunk-KKHKRY7P.js";
12
+ import "../../../chunk-YUZB4LRJ.js";
13
13
 
14
14
  // src/roles/test/setup/jest-parity.ts
15
15
  import { expect, vi } from "vitest";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  pinWorkspaceTimezone
3
- } from "../../../chunk-QMIJ4ZGJ.js";
3
+ } from "../../../chunk-LVY5NPOC.js";
4
4
  import "../../../chunk-ELZHIN6E.js";
5
- import "../../../chunk-KKHKRY7P.js";
5
+ import "../../../chunk-YUZB4LRJ.js";
6
6
 
7
7
  // src/roles/test/setup/workspace-entry.ts
8
8
  await pinWorkspaceTimezone();
@@ -7,12 +7,12 @@ import {
7
7
  readTestAdoption,
8
8
  resolveVitest,
9
9
  suiteOf
10
- } from "./chunk-FZLUCPST.js";
10
+ } from "./chunk-2PRJJRJI.js";
11
11
  import "./chunk-ZFG6P27V.js";
12
12
  import "./chunk-O7REVMOC.js";
13
13
  import "./chunk-H4HAFJFZ.js";
14
14
  import "./chunk-QXFCZON7.js";
15
- import "./chunk-KKHKRY7P.js";
15
+ import "./chunk-YUZB4LRJ.js";
16
16
 
17
17
  // src/roles/test/validate.ts
18
18
  import { execFileSync } from "node:child_process";
@@ -145,11 +145,14 @@ which a module may turn off) and the 2 timeouts the key calls for.
145
145
  | sentinel, `applied-migration-changed` | 1 | **yes**, at `warn` |
146
146
  | sentinel, `enum-value-used-before-commit` | 1 | **yes**, at `warn` |
147
147
  | sentinel, `migration-folder-without-sql` | 1 | **yes**, at `warn` |
148
+ | sentinel, its rules on the SQL of templates | 5 | **yes**, at `warn` |
149
+ | sentinel, its opt-in rules on the SQL of templates | 3 | no: one runs once the module gives it a level |
148
150
 
149
- **55 rules run on every module**, the set squawk itself runs, plus sentinel's five. sentinel turns
151
+ **60 rules run on every module**, the set squawk itself runs, plus sentinel's ten. sentinel turns
150
152
  no squawk rule off and turns no opt-in rule on: the choice of what runs by default is squawk's, and
151
- a module moves it in its own config. `pnpm exec sentinel --inspect --sql --json` lists all 82 names
152
- with the level each has in this module: squawk's 76, sentinel's five, and `syntax-error`.
153
+ a module moves it in its own config. `pnpm exec sentinel --inspect --sql --json` lists all 90 names
154
+ with the level each has in this module: squawk's 76, sentinel's thirteen, and `syntax-error`. The
155
+ rules on the SQL of templates are in [The SQL of templates](#the-sql-of-templates-queryraw-executeraw-prismasql).
153
156
 
154
157
  **A migration that does not parse** is reported first, with its first error (the ones squawk gives
155
158
  after it follow from it), and counts as **one finding** under `syntax-error`, at `warn` like every
@@ -546,22 +549,88 @@ the safety of the text rests on code the call does not show.
546
549
  list, but its separator, prefix and suffix are SQL text. Measured on `main`: 88 calls with a
547
550
  separator, every one a literal (`' AND '`, `' OR '`, `'\n'`), so none is reported.
548
551
 
552
+ ## The SQL of templates, `$queryRaw`, `$executeRaw`, `Prisma.sql`
553
+
554
+ Prisma binds every `${}` of these three, so they are safe from injection. Their SQL is still SQL,
555
+ and the 19 May incident was written in one. The role reads each template of the files the branch
556
+ adds or changes with **PostgreSQL's own parser** (`libpg-query` 16.8.3, the 16 line the monorepo
557
+ runs), the same grammar the server applies: a rule matches the tree, never a word in a string or a
558
+ comment.
559
+
560
+ **How a fragment is read.** A `Prisma.sql` is often a fragment, a condition or an `ORDER BY` list,
561
+ joined into a query later. Each `${}` is filled with what it most likely is (a value, then an
562
+ identifier, then nothing, then a list of values), and the text is wrapped in the smallest statement
563
+ it can stand in (itself, `SELECT …`, `SELECT 1 WHERE …`, `… ORDER BY …`, `WITH … SELECT 1`, …). The
564
+ first reading PostgreSQL accepts is kept. A rule never reports what the wrap wrote, and a rule
565
+ about a whole statement (`UPDATE` without `WHERE`) runs only on a template that is one.
566
+
567
+ **What cannot be read alone** is named in every report, the console, the comment, the json and the
568
+ page, with its line, and never fails the run: the role reads all it can rather than stop. On
569
+ `main` 837abe3f29c, 1 237 of the 1 360 production templates holding SQL of their own are read
570
+ (91 %), and 227 of 227 in tests. A template made of `${}` only has nothing to read and is not
571
+ counted.
572
+
573
+ **Tests are read**, as the `Unsafe` rule reads them: `unsafe.includeTests`, which a module may set
574
+ to `false` for both.
575
+
576
+ | Rule | Default | Reports | Leaves alone |
577
+ | --------------------------------- | ------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
578
+ | `exists-union-correlated-outside` | **on** | an `EXISTS` over a derived `UNION` filtered only outside it | a `UNION` whose branches each carry the correlation (mission's `UNION ALL`) |
579
+ | `update-delete-without-where` | **on** | an `UPDATE` or `DELETE` with no `WHERE`, `UPDATE … FROM` included | a `SET` fragment |
580
+ | `insert-without-columns` | **on** | an `INSERT` with values and no column list | `DEFAULT VALUES`, a `VALUES` fragment |
581
+ | `select-star` | **on** | `SELECT *` or `t.*` on a table of the schema | `EXISTS (SELECT * …)`, `count(*)`, a `WITH` table, a subquery, `jsonb_to_recordset(…)` |
582
+ | `leading-wildcard-like` | **on** | a literal `LIKE` / `ILIKE` pattern starting with `%`, in a query | an anchored pattern, a bound one, a `CHECK` constraint |
583
+ | `offset-pagination` | opt-in | `OFFSET` in a query or in the fragment that pages it | `LIMIT` alone |
584
+ | `select-distinct` | opt-in | a plain `SELECT DISTINCT` | `DISTINCT ON (…)` |
585
+ | `not-in-subquery` | opt-in | `NOT IN (SELECT …)`, which one `NULL` in the result empties | `NOT IN (1, 2)`, `NOT EXISTS` |
586
+
587
+ Measured over every template of `main` 837abe3f29c: the five rules on by default report 3
588
+ templates of production code (all `select-star` on a table) and 15 in tests (fixtures that update
589
+ every row or insert by position, and two `ILIKE '%…'` on `pg_indexes`). Turned on, the opt-in
590
+ ones would report 14, 22 and 0 templates of production code.
591
+
592
+ ### The 19 May incident, `exists-union-correlated-outside`
593
+
594
+ ```sql
595
+ EXISTS (
596
+ SELECT 1 FROM (
597
+ SELECT j.profile_id FROM profile_jobs j WHERE j.approval = 'idle'
598
+ UNION
599
+ SELECT s.profile_id FROM profile_specialties s WHERE s.approval = 'idle'
600
+ ) pending
601
+ WHERE pending.profile_id = p.id
602
+ )
603
+ ```
604
+
605
+ The correlation to the outer row sits outside the union, on the derived table, and PostgreSQL does
606
+ not push it into the branches: for every outer row it builds the whole union. That made the
607
+ network list scan both tables once per profile (monorepo 868e2b4). Run on a copy of `network`, the
608
+ rule reports `has-pending-skill-requests.filter-strategy.ts:21` at `868e2b4^1` and nothing at
609
+ `868e2b4`; over every template of `main`, nothing.
610
+
611
+ ```
612
+ this EXISTS reads the UNION `pending` and filters it only outside the union (`pending.profile_id`): PostgreSQL cannot push that filter into the branches, so it builds the whole union for every outer row. This is the shape of the 19 May incident.
613
+ ```
614
+
615
+ The fix: repeat the correlation in each branch (`WHERE j.profile_id = p.id`), or write one
616
+ `EXISTS` per branch joined by `OR`, so each branch is filtered with its own index.
617
+
549
618
  ## Every way to send SQL text, and what reads it
550
619
 
551
620
  Measured on the monorepo (`main` f12da701121), every call that can send text to a database:
552
621
 
553
- | Entry point | Calls | Its text is | Read by |
554
- | ---------------------------------------------------------------------- | ------------: | -------------------------------------------------------- | --------------------------------------- |
555
- | `` $queryRaw`…` ``, `` $executeRaw`…` ``, `` Prisma.sql`…` `` (tagged) | 332 and 1 079 | a template whose every `${}` Prisma binds | nothing to report: safe by construction |
556
- | `$queryRaw(sql)` called as a function | 30 | a `Prisma.Sql` object; TypeScript refuses a plain string | nothing to report |
557
- | `$queryRawUnsafe` / `$executeRawUnsafe` | 219 | SQL | `unsafe-sql-pasted-value` |
558
- | `pg` `query` | 37 | SQL | `unsafe-sql-pasted-value` |
559
- | postgres.js `unsafe` | 1 | SQL | `unsafe-sql-pasted-value` |
560
- | `Prisma.raw` | 97 | SQL, pasted as is | `unsafe-sql-raw-fragment` |
561
- | `Prisma.join` separator, prefix, suffix | 88 | SQL | `unsafe-sql-raw-fragment` |
562
- | postgres.js tagged `` sql`…` `` | | a template whose every `${}` the driver binds | nothing to report |
563
- | knex, TypeORM, Sequelize, mysql | 0 | | not used |
564
- | MongoDB (35 imports) | | not SQL | outside this role |
622
+ | Entry point | Calls | Its text is | Read by |
623
+ | ---------------------------------------------------------------------- | ------------: | -------------------------------------------------------- | -------------------------------------------------------------- |
624
+ | `` $queryRaw`…` ``, `` $executeRaw`…` ``, `` Prisma.sql`…` `` (tagged) | 332 and 1 079 | a template whose every `${}` Prisma binds | safe from injection; its SQL is read by the rules on templates |
625
+ | `$queryRaw(sql)` called as a function | 30 | a `Prisma.Sql` object; TypeScript refuses a plain string | nothing to report |
626
+ | `$queryRawUnsafe` / `$executeRawUnsafe` | 219 | SQL | `unsafe-sql-pasted-value` |
627
+ | `pg` `query` | 37 | SQL | `unsafe-sql-pasted-value` |
628
+ | postgres.js `unsafe` | 1 | SQL | `unsafe-sql-pasted-value` |
629
+ | `Prisma.raw` | 97 | SQL, pasted as is | `unsafe-sql-raw-fragment` |
630
+ | `Prisma.join` separator, prefix, suffix | 88 | SQL | `unsafe-sql-raw-fragment` |
631
+ | postgres.js tagged `` sql`…` `` | | a template whose every `${}` the driver binds | nothing to report |
632
+ | knex, TypeORM, Sequelize, mysql | 0 | | not used |
633
+ | MongoDB (35 imports) | | not SQL | outside this role |
565
634
 
566
635
  ## What the role does not read yet
567
636
 
@@ -570,9 +639,14 @@ Said here so that a clean report is not read as more than it is:
570
639
  - **`VACUUM` in a migration of several statements.** PostgreSQL refuses it inside a transaction,
571
640
  as it refuses `CONCURRENTLY`, and squawk 2.72.0 does not report it there. No migration of the
572
641
  monorepo runs `VACUUM`.
573
- - **The SQL text itself** of a raw query is not parsed: a tagged `$queryRaw` with only parameters is
574
- safe from injection, and its SQL is not checked against any rule. A syntax error inside it is not
575
- seen. That is the next step, with libpg-query.
642
+ - **A problem split across two templates.** Each template is read alone: an `EXISTS` in one
643
+ `Prisma.sql` and the `UNION` a `${}` brings from another are two readings, and the rule sees
644
+ neither whole. Assembling the fragments of a query would be close to reading the ORM chain.
645
+ - **The templates PostgreSQL's parser cannot read alone**, about 9 % of the production ones on
646
+ `main` 837abe3f29c: named in every report, never a failure, and checked by no rule.
647
+ - **The SQL text of `$queryRawUnsafe`** is checked for what is pasted into it, not against the
648
+ rules on templates, and **drizzle-orm's `` sql`…` ``** (6 files) is not read: its fragments are
649
+ built for its query builder.
576
650
  - **JavaScript files** (`.js`, `.mjs`): the role reads TypeScript (`.ts`, `.mts`, `.cts`).
577
651
  - **Files outside a module.** The role runs on a module; a script at the repository's root that
578
652
  belongs to no module is read by no role.
@@ -241,7 +241,9 @@ $ sentinel --report --json 2>/dev/null
241
241
  "code-churn",
242
242
  "arch"
243
243
  ],
244
- "skipped": [],
244
+ "skipped": [
245
+ "runtime-analysis"
246
+ ],
245
247
  "results": [
246
248
  {
247
249
  "project": "svelte-app",
@@ -328,6 +330,7 @@ $ sentinel --report --json 2>/dev/null
328
330
  "migrations": 0,
329
331
  "codeFiles": 1,
330
332
  "unsafeFiles": 0,
333
+ "templateFiles": 0,
331
334
  "base": null,
332
335
  "migrationsRead": 0,
333
336
  "migrationsUnchanged": 0,
@@ -336,6 +339,9 @@ $ sentinel --report --json 2>/dev/null
336
339
  "unsafeCalls": 0,
337
340
  "rawFragmentCalls": 0,
338
341
  "unsafeUnparsed": 0,
342
+ "templateFilesRead": 0,
343
+ "templatesRead": 0,
344
+ "templatesUnread": 0,
339
345
  "findings": 0,
340
346
  "errors": 0,
341
347
  "rulesOff": [],
@@ -452,6 +458,7 @@ $ sentinel --report --json 2>/dev/null
452
458
  "migrations": 0,
453
459
  "codeFiles": 1,
454
460
  "unsafeFiles": 0,
461
+ "templateFiles": 0,
455
462
  "base": null,
456
463
  "migrationsRead": 0,
457
464
  "migrationsUnchanged": 0,
@@ -460,6 +467,9 @@ $ sentinel --report --json 2>/dev/null
460
467
  "unsafeCalls": 0,
461
468
  "rawFragmentCalls": 0,
462
469
  "unsafeUnparsed": 0,
470
+ "templateFilesRead": 0,
471
+ "templatesRead": 0,
472
+ "templatesUnread": 0,
463
473
  "findings": 0,
464
474
  "errors": 0,
465
475
  "rulesOff": [],
@@ -576,6 +586,7 @@ $ sentinel --report --json 2>/dev/null
576
586
  "migrations": 0,
577
587
  "codeFiles": 1,
578
588
  "unsafeFiles": 0,
589
+ "templateFiles": 0,
579
590
  "base": null,
580
591
  "migrationsRead": 0,
581
592
  "migrationsUnchanged": 0,
@@ -584,6 +595,9 @@ $ sentinel --report --json 2>/dev/null
584
595
  "unsafeCalls": 0,
585
596
  "rawFragmentCalls": 0,
586
597
  "unsafeUnparsed": 0,
598
+ "templateFilesRead": 0,
599
+ "templatesRead": 0,
600
+ "templatesUnread": 0,
587
601
  "findings": 0,
588
602
  "errors": 0,
589
603
  "rulesOff": [],
@@ -688,6 +702,7 @@ $ sentinel --report --json 2>/dev/null
688
702
  "migrations": 0,
689
703
  "codeFiles": 1,
690
704
  "unsafeFiles": 0,
705
+ "templateFiles": 0,
691
706
  "base": null,
692
707
  "migrationsRead": 0,
693
708
  "migrationsUnchanged": 0,
@@ -696,6 +711,9 @@ $ sentinel --report --json 2>/dev/null
696
711
  "unsafeCalls": 0,
697
712
  "rawFragmentCalls": 0,
698
713
  "unsafeUnparsed": 0,
714
+ "templateFilesRead": 0,
715
+ "templatesRead": 0,
716
+ "templatesUnread": 0,
699
717
  "findings": 0,
700
718
  "errors": 0,
701
719
  "rulesOff": [],
@@ -763,7 +781,9 @@ $ sentinel --report --all --json 2>/dev/null
763
781
  "code-churn",
764
782
  "arch"
765
783
  ],
766
- "skipped": [],
784
+ "skipped": [
785
+ "runtime-analysis"
786
+ ],
767
787
  "results": [
768
788
  {
769
789
  "project": "svelte-app",
@@ -850,6 +870,7 @@ $ sentinel --report --all --json 2>/dev/null
850
870
  "migrations": 0,
851
871
  "codeFiles": 1,
852
872
  "unsafeFiles": 0,
873
+ "templateFiles": 0,
853
874
  "base": null,
854
875
  "migrationsRead": 0,
855
876
  "migrationsUnchanged": 0,
@@ -858,6 +879,9 @@ $ sentinel --report --all --json 2>/dev/null
858
879
  "unsafeCalls": 0,
859
880
  "rawFragmentCalls": 0,
860
881
  "unsafeUnparsed": 0,
882
+ "templateFilesRead": 0,
883
+ "templatesRead": 0,
884
+ "templatesUnread": 0,
861
885
  "findings": 0,
862
886
  "errors": 0,
863
887
  "rulesOff": [],
@@ -974,6 +998,7 @@ $ sentinel --report --all --json 2>/dev/null
974
998
  "migrations": 0,
975
999
  "codeFiles": 1,
976
1000
  "unsafeFiles": 0,
1001
+ "templateFiles": 0,
977
1002
  "base": null,
978
1003
  "migrationsRead": 0,
979
1004
  "migrationsUnchanged": 0,
@@ -982,6 +1007,9 @@ $ sentinel --report --all --json 2>/dev/null
982
1007
  "unsafeCalls": 0,
983
1008
  "rawFragmentCalls": 0,
984
1009
  "unsafeUnparsed": 0,
1010
+ "templateFilesRead": 0,
1011
+ "templatesRead": 0,
1012
+ "templatesUnread": 0,
985
1013
  "findings": 0,
986
1014
  "errors": 0,
987
1015
  "rulesOff": [],
@@ -1098,6 +1126,7 @@ $ sentinel --report --all --json 2>/dev/null
1098
1126
  "migrations": 0,
1099
1127
  "codeFiles": 1,
1100
1128
  "unsafeFiles": 0,
1129
+ "templateFiles": 0,
1101
1130
  "base": null,
1102
1131
  "migrationsRead": 0,
1103
1132
  "migrationsUnchanged": 0,
@@ -1106,6 +1135,9 @@ $ sentinel --report --all --json 2>/dev/null
1106
1135
  "unsafeCalls": 0,
1107
1136
  "rawFragmentCalls": 0,
1108
1137
  "unsafeUnparsed": 0,
1138
+ "templateFilesRead": 0,
1139
+ "templatesRead": 0,
1140
+ "templatesUnread": 0,
1109
1141
  "findings": 0,
1110
1142
  "errors": 0,
1111
1143
  "rulesOff": [],
@@ -1210,6 +1242,7 @@ $ sentinel --report --all --json 2>/dev/null
1210
1242
  "migrations": 0,
1211
1243
  "codeFiles": 1,
1212
1244
  "unsafeFiles": 0,
1245
+ "templateFiles": 0,
1213
1246
  "base": null,
1214
1247
  "migrationsRead": 0,
1215
1248
  "migrationsUnchanged": 0,
@@ -1218,6 +1251,9 @@ $ sentinel --report --all --json 2>/dev/null
1218
1251
  "unsafeCalls": 0,
1219
1252
  "rawFragmentCalls": 0,
1220
1253
  "unsafeUnparsed": 0,
1254
+ "templateFilesRead": 0,
1255
+ "templatesRead": 0,
1256
+ "templatesUnread": 0,
1221
1257
  "findings": 0,
1222
1258
  "errors": 0,
1223
1259
  "rulesOff": [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.31",
3
+ "version": "1.7.0-alpha.32",
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",
@@ -66,10 +66,6 @@
66
66
  "types": "./dist/roles/code-churn/config.d.ts",
67
67
  "import": "./dist/roles/code-churn/config.js"
68
68
  },
69
- "./runtime-analysis": {
70
- "types": "./dist/roles/runtime-analysis/config.d.ts",
71
- "import": "./dist/roles/runtime-analysis/config.js"
72
- },
73
69
  "./env": {
74
70
  "types": "./dist/roles/env/config.d.ts",
75
71
  "import": "./dist/roles/env/config.js"
@@ -129,8 +125,7 @@
129
125
  "docs",
130
126
  "lint",
131
127
  "oxlint",
132
- "plugins",
133
- "runtime-analysis-deps"
128
+ "plugins"
134
129
  ],
135
130
  "scripts": {
136
131
  "build": "tsup && tsx scripts/build-presets.ts",
@@ -182,6 +177,7 @@
182
177
  "jscpd": "5.4.0",
183
178
  "jsdom": "^24.1.3",
184
179
  "jsonc-parser": "^3.3.1",
180
+ "libpg-query": "16.8.3",
185
181
  "msw": "1.3.3",
186
182
  "nitro": "3.0.260415-beta",
187
183
  "oxc-parser": "0.147.0",
@@ -201,10 +197,7 @@
201
197
  "@hublo/sentinel": "link:.",
202
198
  "@types/node": "^24.19.2",
203
199
  "@types/picomatch": "4.0.3",
204
- "lighthouse": "13.6.0",
205
200
  "nx": "^23.1.0",
206
- "playwright-core": "1.64.1",
207
- "puppeteer-core": "25.16.0",
208
201
  "tsup": "^8.3.0",
209
202
  "tsx": "^4.19.0"
210
203
  },
@@ -1,17 +0,0 @@
1
- // src/roles/runtime-analysis/presets/shared.json
2
- var shared_default = {
3
- configFile: "runtime-analysis.config.mjs",
4
- reportDir: "runtime-analysis-report",
5
- runs: 5,
6
- throttling: "provided",
7
- locale: "en-US",
8
- good: { lcp: 2500, cls: 0.1, inp: 200 }
9
- };
10
-
11
- // src/roles/runtime-analysis/preset-data.ts
12
- var defaults = shared_default;
13
-
14
- export {
15
- defaults
16
- };
17
- //# sourceMappingURL=chunk-F5WISUN3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/roles/runtime-analysis/presets/shared.json","../src/roles/runtime-analysis/preset-data.ts"],"sourcesContent":["{\n \"configFile\": \"runtime-analysis.config.mjs\",\n \"reportDir\": \"runtime-analysis-report\",\n \"runs\": 5,\n \"throttling\": \"provided\",\n \"locale\": \"en-US\",\n \"good\": { \"lcp\": 2500, \"cls\": 0.1, \"inp\": 200 }\n}\n","/**\n * The runtime analysis role's own settings, as data (`presets/shared.json`):\n *\n * configFile the file a front writes at its root, `runtime-analysis.config.mjs`\n * reportDir where every phase writes, in the module\n * runs rounds of base, head, base again per screen\n * throttling `provided` (the load as it happened) or `simulate` (Lighthouse's Lantern)\n * locale the browser language when a front's config names none\n * good Google's \"good\" thresholds (web.dev/articles/vitals): LCP ms, CLS, INP ms\n *\n * The screens, the mocks and the build are not here: they are each front's, in its config.\n */\nimport shared from './presets/shared.json'\n\nexport interface RuntimeDefaults {\n configFile: string\n reportDir: string\n runs: number\n throttling: 'provided' | 'simulate'\n locale: string\n good: { lcp: number; cls: number; inp: number }\n}\n\nexport const defaults = shared as RuntimeDefaults\n"],"mappings":";AAAA;AAAA,EACE,YAAc;AAAA,EACd,WAAa;AAAA,EACb,MAAQ;AAAA,EACR,YAAc;AAAA,EACd,QAAU;AAAA,EACV,MAAQ,EAAE,KAAO,MAAM,KAAO,KAAK,KAAO,IAAI;AAChD;;;ACgBO,IAAM,WAAW;","names":[]}