@hublo/sentinel 1.7.0-alpha.23 → 1.7.0-alpha.25

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
@@ -177,6 +177,7 @@ throwaway run wants. Once a module has adopted, nothing is fetched any more: the
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
179
  - [`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
+ - [`docs/runtime-analysis-adoption.md`](docs/runtime-analysis-adoption.md) — measuring a React front's Core Web Vitals on a pull request: the config key by key, the run on a machine, the CI phases, the browser packages installed only where a measure runs, and how the verdict decides what blocks.
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
 
182
183
  ## Architecture: `target → runner → preset`
@@ -12,7 +12,7 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-426EFSK7.js";
15
+ } from "../chunk-CQQENHUZ.js";
16
16
  import "../chunk-NE3IEJBN.js";
17
17
  import "../chunk-VWASE6NN.js";
18
18
  import {
@@ -5674,7 +5674,11 @@ var OPTIONS = {
5674
5674
  detect: { type: "string" },
5675
5675
  "run-url": { type: "string" },
5676
5676
  jobs: { type: "string" },
5677
- run: { type: "string" }
5677
+ run: { type: "string" },
5678
+ pending: { type: "boolean" },
5679
+ affected: { type: "string" },
5680
+ state: { type: "string" },
5681
+ "report-url": { type: "string" }
5678
5682
  };
5679
5683
  var REQUIRED = {
5680
5684
  detect: [],
@@ -5710,7 +5714,8 @@ function parsePhase(toolArgs = []) {
5710
5714
  values: { runs: String(values.runs), throttling: String(values.throttling) }
5711
5715
  };
5712
5716
  const phase = first;
5713
- const missing = REQUIRED[phase].filter((key) => values[key] === void 0);
5717
+ const required = phase === "verdict" && values.pending ? [] : REQUIRED[phase];
5718
+ const missing = required.filter((key) => values[key] === void 0);
5714
5719
  if (missing.length)
5715
5720
  return {
5716
5721
  phase: "invalid",
@@ -6105,30 +6110,102 @@ function everyFlow(runs) {
6105
6110
  "```"
6106
6111
  ];
6107
6112
  }
6108
- function reportMarkdown(input) {
6113
+ var COMMENT_LIMIT = 65536;
6114
+ var FULL_REPORT = "runtime-analysis.full.md";
6115
+ function reportMarkdown(input, limit = COMMENT_LIMIT) {
6109
6116
  const found = evidenceOf(input.evidence);
6110
6117
  const invalidConfig = input.detect.includes("### Invalid runtime-analysis config") ? "; \u274C invalid runtime-analysis config, below" : "";
6111
6118
  const artifacts = input.runUrl === void 0 ? "This run" : `[This run](${input.runUrl})`;
6112
- return [
6119
+ const head = [
6113
6120
  MARKER,
6114
6121
  `## ${TITLE}: ${headline2(input)}${invalidConfig}`,
6115
6122
  "",
6116
6123
  input.detect,
6117
- ...verdictTable(input.rows),
6118
- ...folded(`The proof of every flow (${input.runs.length})`, proofTable(input.runs)),
6119
- ...folded("Medians, noise and how the verdict is decided", [
6120
- `Interleaved base, head, base again; Lighthouse throttling \`${input.throttling}\`.`,
6121
- "",
6122
- // As the harness read it from a file the gate printed: ending with a line break.
6123
- `${input.budget}
6124
+ ...verdictTable(input.rows)
6125
+ ];
6126
+ const sections = [
6127
+ {
6128
+ name: "the proof of every flow",
6129
+ lines: folded(`The proof of every flow (${input.runs.length})`, proofTable(input.runs))
6130
+ },
6131
+ {
6132
+ name: "medians and noise",
6133
+ lines: folded("Medians, noise and how the verdict is decided", [
6134
+ `Interleaved base, head, base again; Lighthouse throttling \`${input.throttling}\`.`,
6135
+ "",
6136
+ // As the harness read it from a file the gate printed: ending with a line break.
6137
+ `${input.budget}
6124
6138
  `
6125
- ]),
6126
- ...folded("Builds and settings", buildsAndSettings(input, found)),
6127
- ...folded("Time of each phase", phaseTimes(input, found)),
6128
- ...folded(`Every flow's values, read from Lighthouse's JSON`, everyFlow(input.runs)),
6139
+ ])
6140
+ },
6141
+ {
6142
+ name: "builds and settings",
6143
+ lines: folded("Builds and settings", buildsAndSettings(input, found))
6144
+ },
6145
+ { name: "time of each phase", lines: folded("Time of each phase", phaseTimes(input, found)) },
6146
+ {
6147
+ name: "every flow's values",
6148
+ lines: folded(`Every flow's values, read from Lighthouse's JSON`, everyFlow(input.runs))
6149
+ }
6150
+ ];
6151
+ const tail = [
6129
6152
  `${artifacts}: the artifacts \`cwv-lighthouse-*\` hold the Lighthouse HTML reports, screenshots and filmstrips, one HAR per build and screen, the request list of every flow and the server logs; \`cwv-lighthouse-report\` holds this comment and verdict.json.`
6153
+ ];
6154
+ const leftOut = (dropped) => [
6155
+ `\u26A0\uFE0F **${dropped.length} of ${sections.length} sections are not shown**: a GitHub comment holds at most ${COMMENT_LIMIT.toLocaleString("en-US")} characters. They are in \`${FULL_REPORT}\`, in \`cwv-lighthouse-report\`: ${dropped.map((section) => section.name).join(", ")}.`,
6156
+ ""
6157
+ ];
6158
+ const assemble = (shown3) => [
6159
+ ...head,
6160
+ ...sections.slice(0, shown3).flatMap((section) => section.lines),
6161
+ ...shown3 < sections.length ? leftOut(sections.slice(shown3)) : [],
6162
+ ...tail
6163
+ ];
6164
+ let shown2 = sections.length;
6165
+ while (shown2 > 0 && assemble(shown2).join("\n").length > limit) shown2 -= 1;
6166
+ return assemble(shown2).join("\n");
6167
+ }
6168
+ function pendingMarkdown(input) {
6169
+ const status = input.invalid && !input.measure ? "\u274C invalid runtime-analysis config, nothing measured" : input.invalid ? "\u23F3 building base and head; \u274C invalid runtime-analysis config" : input.measure ? "\u23F3 building base and head" : "\u23ED\uFE0F nothing to measure";
6170
+ return [
6171
+ MARKER,
6172
+ `## ${TITLE}: ${status}`,
6173
+ "",
6174
+ input.detect,
6175
+ "",
6176
+ input.runUrl === void 0 ? "This run" : `[This run](${input.runUrl})`
6130
6177
  ].join("\n");
6131
6178
  }
6179
+ function noticeMarkdown(input) {
6180
+ const value = (metric, figure2) => metric === "cls" ? figure2.toFixed(4) : `${Math.round(figure2)} ms`;
6181
+ const good = (metric) => metric === "cls" ? String(GOOD.cls) : `${GOOD[metric]} ms`;
6182
+ const lines = [
6183
+ `## ${TITLE}: \u274C verdict after the PR was ${input.state}`,
6184
+ "",
6185
+ `The measure of \`${input.head.slice(0, 8)}\` ended after this PR was ${input.state}.`,
6186
+ ""
6187
+ ];
6188
+ const blocked = input.rows.filter((row) => row.blocking.length);
6189
+ if (blocked.length) {
6190
+ lines.push("| Screen | What blocks |", "| --- | --- |");
6191
+ for (const row of blocked) {
6192
+ const what = [
6193
+ // Only the judged metrics (LCP, CLS, INP) can be created by the pull request.
6194
+ ...row.created.map(
6195
+ (metric) => `${metric.toUpperCase()} ${value(metric, row[metric].base)} \u2192 **${value(metric, row[metric].head)}** (good: ${good(metric)}), created by this PR`
6196
+ ),
6197
+ ...row.invalid ? [`${row.invalid} flow(s) not proven`] : []
6198
+ ];
6199
+ lines.push(`| \`${row.screen}\` | ${what.join("<br>")} |`);
6200
+ }
6201
+ } else lines.push("The measure did not complete: nothing could be judged.");
6202
+ const links = [
6203
+ ...input.reportUrl ? [`[The full report](${input.reportUrl})`] : [],
6204
+ ...input.runUrl ? [`[this run](${input.runUrl})`] : []
6205
+ ];
6206
+ lines.push("", `To fix in a follow-up PR.${links.length ? ` ${links.join(" \xB7 ")}` : ""}`);
6207
+ return lines.join("\n");
6208
+ }
6132
6209
 
6133
6210
  // src/roles/runtime-analysis/verdict/runs.ts
6134
6211
  import { existsSync as existsSync23, readdirSync as readdirSync7, readFileSync as readFileSync24, statSync as statSync6 } from "node:fs";
@@ -6223,8 +6300,12 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6223
6300
  async run(ctx) {
6224
6301
  const parsed = parsePhase(ctx.toolArgs);
6225
6302
  if (parsed.phase === "invalid") return this.fail(parsed.reason);
6226
- if (parsed.phase === "verdict") return this.verdict(ctx, parsed.values);
6227
6303
  if (parsed.phase === "detect") return this.detect(ctx, parsed.values);
6304
+ if (!existsSync24(join33(ctx.cwd, RUNTIME_CONFIG_FILE))) {
6305
+ this.say(`not adopted here; \`sentinel --init --runtime-analysis\` sets it up.`);
6306
+ return { ok: true, code: 0, metrics: { adopted: false } };
6307
+ }
6308
+ if (parsed.phase === "verdict") return this.verdict(ctx, parsed.values);
6228
6309
  const checked = await this.configOf(ctx.cwd);
6229
6310
  if ("reason" in checked) return this.fail(checked.reason);
6230
6311
  const { config } = checked;
@@ -6329,6 +6410,34 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6329
6410
  }
6330
6411
  /** Judge every measure job's evidence and write the comment, the verdict and the budget. */
6331
6412
  async verdict(ctx, values) {
6413
+ const detections = values.detect === void 0 ? [] : readDetections(resolve7(ctx.cwd, String(values.detect)));
6414
+ const readJson = (file) => typeof file === "string" && existsSync24(resolve7(ctx.cwd, file)) ? JSON.parse(readFileSync25(resolve7(ctx.cwd, file), "utf8")) : void 0;
6415
+ const detect = detectionMarkdown({
6416
+ fronts: detections.map((detection) => detection.front),
6417
+ screensOf: Object.fromEntries(
6418
+ detections.filter((detection) => detection.front.measured).map((detection) => [detection.front.name, detection.screens])
6419
+ ),
6420
+ affected: readAffected(
6421
+ typeof values.affected === "string" ? resolve7(ctx.cwd, values.affected) : void 0
6422
+ ),
6423
+ invalid: detections.flatMap((detection) => detection.invalid ? [detection.invalid] : [])
6424
+ });
6425
+ const runUrl = typeof values["run-url"] === "string" ? values["run-url"] : void 0;
6426
+ const out = resolve7(ctx.cwd, String(values.out ?? REPORT_DIR3));
6427
+ mkdirSync7(out, { recursive: true });
6428
+ if (values.pending) {
6429
+ const pending = pendingMarkdown({
6430
+ detect,
6431
+ measure: detections.some(
6432
+ (detection) => detection.screens.some((screen) => screen.measured)
6433
+ ),
6434
+ invalid: detections.some((detection) => detection.invalid),
6435
+ ...runUrl === void 0 ? {} : { runUrl }
6436
+ });
6437
+ writeFileSync8(join33(out, "runtime-analysis.md"), `${pending}
6438
+ `);
6439
+ return { ok: true, code: 0, metrics: { pending: true } };
6440
+ }
6332
6441
  const evidence = resolve7(ctx.cwd, String(values.evidence));
6333
6442
  let runs;
6334
6443
  try {
@@ -6339,19 +6448,10 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6339
6448
  const verdict = judge(runs);
6340
6449
  const throttling = runs[0]?.settings?.navigation?.throttlingMethod ?? "?";
6341
6450
  const budget = verdictMarkdown(verdict, String(values.evidence), throttling);
6342
- const detections = values.detect === void 0 ? [] : readDetections(resolve7(ctx.cwd, String(values.detect)));
6343
- const readJson = (file) => typeof file === "string" && existsSync24(resolve7(ctx.cwd, file)) ? JSON.parse(readFileSync25(resolve7(ctx.cwd, file), "utf8")) : void 0;
6344
6451
  const jobs = readJson(values.jobs)?.jobs;
6345
6452
  const run = readJson(values.run);
6346
- const comment = reportMarkdown({
6347
- detect: detectionMarkdown({
6348
- fronts: detections.map((detection) => detection.front),
6349
- screensOf: Object.fromEntries(
6350
- detections.filter((detection) => detection.front.measured).map((detection) => [detection.front.name, detection.screens])
6351
- ),
6352
- affected: [],
6353
- invalid: detections.flatMap((detection) => detection.invalid ? [detection.invalid] : [])
6354
- }),
6453
+ const input = {
6454
+ detect,
6355
6455
  budget,
6356
6456
  rows: verdict.rows,
6357
6457
  runs,
@@ -6360,13 +6460,35 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6360
6460
  head: String(values.head ?? ""),
6361
6461
  failed: verdict.failed,
6362
6462
  throttling: String(values.throttling),
6363
- ...typeof values["run-url"] === "string" ? { runUrl: values["run-url"] } : {},
6364
- ...jobs ? { ci: { jobs, ...run?.created_at ? { createdAt: run.created_at } : {} } } : {}
6365
- });
6366
- const out = resolve7(ctx.cwd, String(values.out ?? REPORT_DIR3));
6367
- mkdirSync7(out, { recursive: true });
6463
+ ...runUrl === void 0 ? {} : { runUrl },
6464
+ // One clock for both shapes below, so they differ only by what the sizing left out.
6465
+ ...jobs ? {
6466
+ ci: {
6467
+ jobs,
6468
+ now: /* @__PURE__ */ new Date(),
6469
+ ...run?.created_at ? { createdAt: run.created_at } : {}
6470
+ }
6471
+ } : {}
6472
+ };
6473
+ const comment = reportMarkdown(input);
6368
6474
  writeFileSync8(join33(out, "runtime-analysis.md"), `${comment}
6369
6475
  `);
6476
+ const full = reportMarkdown(input, Number.POSITIVE_INFINITY);
6477
+ if (full !== comment) writeFileSync8(join33(out, FULL_REPORT), `${full}
6478
+ `);
6479
+ const state = typeof values.state === "string" ? values.state : "open";
6480
+ if (verdict.failed && state !== "open")
6481
+ writeFileSync8(
6482
+ join33(out, "notice.md"),
6483
+ `${noticeMarkdown({
6484
+ rows: verdict.rows,
6485
+ state,
6486
+ head: String(values.head ?? ""),
6487
+ ...typeof values["report-url"] === "string" ? { reportUrl: values["report-url"] } : {},
6488
+ ...runUrl === void 0 ? {} : { runUrl }
6489
+ })}
6490
+ `
6491
+ );
6370
6492
  writeFileSync8(join33(out, "verdict.json"), JSON.stringify(verdict, null, 2));
6371
6493
  writeFileSync8(join33(out, "budget.md"), `${budget}
6372
6494
  `);
@@ -6453,6 +6575,12 @@ ${problems.map(({ field, message }) => ` - ${field}: ${message}`).join("\n")}`,
6453
6575
  return { adopted, preset: adopted ? ctx.preset : null, conformant: adopted, drift: [] };
6454
6576
  }
6455
6577
  };
6578
+ function readAffected(file) {
6579
+ if (file === void 0 || !existsSync24(file)) return [];
6580
+ const text = readFileSync25(file, "utf8").trim();
6581
+ if (text.startsWith("[")) return JSON.parse(text);
6582
+ return text.split(/\s+/).filter(Boolean);
6583
+ }
6456
6584
  function readDetections(dir) {
6457
6585
  if (!existsSync24(dir)) return [];
6458
6586
  const files = [
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  registerAdapters,
7
7
  resolve,
8
8
  setDefaultRunner
9
- } from "./chunk-426EFSK7.js";
9
+ } from "./chunk-CQQENHUZ.js";
10
10
  import "./chunk-NE3IEJBN.js";
11
11
  import "./chunk-VWASE6NN.js";
12
12
  import {
@@ -0,0 +1,162 @@
1
+ # Runtime analysis adoption cheat sheet
2
+
3
+ `--runtime-analysis` measures the Core Web Vitals (LCP, CLS, INP) of a pull request on a React front's real builds. It builds the front twice, at the merge base and at the head, and serves both on the machine behind a gateway, with every API call answered from JSON files. It then measures the screens the diff can change in a real Chrome and fails the pull request only for a breach the pull request **creates**.
4
+
5
+ It is on demand: a measure costs minutes and a build, so `sentinel --run` never sweeps it, and a bare `--init` never adopts it. It runs only when you name it.
6
+
7
+ Scope: React fronts on TanStack Router file routes. A Next.js or Svelte front is reported as out of scope, not measured.
8
+
9
+ ## Adopt a front in two steps
10
+
11
+ ```bash
12
+ cd apps/front/<front>
13
+ # 1. write the front's config and the `runtime-analysis` script
14
+ npx --yes @hublo/sentinel@<exact version> --init --runtime-analysis
15
+ # 2. fill runtime-analysis.config.mjs with the front's screens, mocks and build, then check it
16
+ pnpm exec sentinel --inspect --runtime-analysis
17
+ ```
18
+
19
+ `--init` writes `runtime-analysis.config.mjs` with every key and what it means. A re-init never rewrites it, because its screens and mocks are the front's own. `--inspect` checks it before anything is built, and names each problem by its field.
20
+
21
+ ## The config, key by key
22
+
23
+ ```js
24
+ // runtime-analysis.config.mjs, at the front's root
25
+ import { defineRuntimeAnalysis } from '@hublo/sentinel/runtime-analysis'
26
+
27
+ export default defineRuntimeAnalysis({
28
+ root: import.meta.dirname,
29
+ basePath: '/admin',
30
+ health: '/admin/api/health',
31
+ ready: '/bff-admin/session',
32
+ build: {
33
+ output: '.output',
34
+ server: 'server/index.mjs',
35
+ env: { VITE_API_URL: '{origin}/bff-admin' },
36
+ },
37
+ api: [{ path: '/bff-admin/session', file: 'runtime-analysis/api/session.json' }],
38
+ router: { tsconfig: 'tsconfig.app.json', shell: ['src/router.tsx'], routes: 'src/routes' },
39
+ translations: 'src/assets/locales',
40
+ locale: 'fr-FR',
41
+ screens: [
42
+ {
43
+ id: 'contract-types',
44
+ route: 'contract-types/index.tsx',
45
+ path: '/admin/contract-types',
46
+ expectText: ['Types de contrat'],
47
+ interact: { click: 'main button' },
48
+ },
49
+ ],
50
+ })
51
+ ```
52
+
53
+ Every path is relative to the front.
54
+
55
+ | Key | What it is |
56
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
+ | `basePath` or `mockPrefixes` | Where the app is served. Under `basePath`, the app gets that path and the mocks get the rest. At the root, `mockPrefixes` lists the paths sent to the mocks. Give one, not both. |
58
+ | `health` | The app's health path, polled until the server is up. |
59
+ | `ready` | The call that tells the app is ready, usually the session. A mock in `api` must answer it with 200. |
60
+ | `build.output`, `build.server` | The build output, and the server it starts with (`node <server>`, with `HOST` and `PORT` set). |
61
+ | `build.env` | The build variables. `{origin}` is replaced by the gateway the build is served behind: point every API there, never at a real one. Use placeholders, never a secret. |
62
+ | `api` | One entry per call the screens make: `path`, `file`, optional `method` (GET by default) and `status` (200). |
63
+ | `router` | `tsconfig` resolves the route imports, `shell` lists the files every screen loads, and `routes` is the file routes folder holding `__root.tsx`. |
64
+ | `translations` | Optional. The folder holding `<lang>/<namespace>.json`. A change to one namespace measures only the screens whose code names it. |
65
+ | `locale` | Optional, `en-US` by default. The browser's language, matching how `expectText` is written. |
66
+ | `screens` | What is measured. `route` is relative to `router.routes`, `path` is what is opened, `expectText` lists what must be visible before a figure counts, and `interact` is the one interaction timed for INP (`click`, `clickText` or `type`). Optional: `rows` (a count or a minimum of rows) and `expectSelector`. |
67
+
68
+ A mocked list is written once, not copied out by hand:
69
+
70
+ ```json
71
+ {
72
+ "$repeat": 25,
73
+ "item": { "id": "cwv-{n}", "name": "Type {nn}", "kind": { "$cycle": ["CDI", "CDD"] } }
74
+ }
75
+ ```
76
+
77
+ That is 25 items. `{n}` is the item's number from 1, `{nn}` the same on two digits, and `$cycle` takes its values in turn.
78
+
79
+ ## Run it on your machine
80
+
81
+ ```bash
82
+ pnpm run runtime-analysis # sentinel --run --runtime-analysis
83
+ ```
84
+
85
+ With no phase, it builds the front once and measures it against itself, base against head on the same build. It judges the result and writes the comment to `runtime-analysis-report/runtime-analysis.md`. Every ❌ in that run is the machine's own noise, which makes it the way to check a new screen before a pull request relies on it.
86
+
87
+ It needs a real Google Chrome: the macOS or Linux install, or `CHROME_PATH`.
88
+
89
+ ## In CI: one command, in phases
90
+
91
+ A CI splits the measure over parallel jobs: one build job per front, then one measure job per front and screen. Each phase is the same command with its name after `--`:
92
+
93
+ | Phase | Where it runs | What it does |
94
+ | --------------------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
+ | `detect --base SHA --head SHA` (or `--all`) | in each affected front | Finds which of the front's screens the diff can change. Writes `runtime-analysis-report/detect.json` and prints `screens=a,b`. Fails on an invalid config. |
96
+ | `verdict --pending --detect DIR [--affected FILE]` | once | Writes the first comment, before any build: building, nothing to measure, or an invalid config. |
97
+ | `env --origin URL` | in the build job | Prints the front's build variables as shell exports, `{origin}` replaced. |
98
+ | `measure --screens a,b --base-build DIR --head-build DIR` | per front and screen | Serves both builds behind their gateways and measures. Writes the evidence to `--out`. |
99
+ | `verdict --evidence DIR --detect DIR` | once, at the end | Judges every measure job's evidence. Writes the comment, `verdict.json` and the budget, and exits 1 on a breach. |
100
+
101
+ Options of the final `verdict`:
102
+
103
+ - `--base` and `--head` print the commits.
104
+ - `--run-url` links the run's artifacts.
105
+ - `--jobs` and `--run` take the run's jobs and its creation time, read from the GitHub API, for the time of each phase.
106
+ - `--affected FILE` takes the projects the pull request affects (a JSON array or one per line), for the line saying none of them is a frontend.
107
+ - `--state closed|merged --report-url URL` adds a `notice.md` when the measure fails on a pull request closed meanwhile: GitHub notifies nobody of an edited comment, so the notice is posted as a new one.
108
+
109
+ sentinel never calls nx or the GitHub API. Which fronts a pull request affects, their builds and the posting of the comment stay the workflow's.
110
+
111
+ ## The browser packages: installed only where a measure runs
112
+
113
+ Lighthouse, Puppeteer and Playwright are not dependencies of sentinel, so a module that installs sentinel does not carry them. sentinel ships their manifest and lockfile in `runtime-analysis-deps/`. The `measure` phase installs them with `npm ci` into sentinel's cache, outside the repository: the workspace, its lockfile and its node_modules never change.
114
+
115
+ | Where | |
116
+ | -------------------------- | ------------------------------------------------------------------------------------------------- |
117
+ | The cache | `~/.cache/sentinel/runtime-analysis/<lockfile hash>`, or the folder named by `SENTINEL_CACHE_DIR` |
118
+ | First measure of a version | about 11 s and 213 MB, from the npm registry |
119
+ | Next measures | nothing to install |
120
+
121
+ In CI, set `SENTINEL_CACHE_DIR` to a folder and cache it with `actions/cache`, with the sentinel version as the key, so each version downloads once.
122
+
123
+ ## Reading the comment
124
+
125
+ The title says what happened: ✅ nothing degraded, ❌ a degradation with its metric and screen, ❌ flows not proven, or ❌ a measure that did not complete. Under it come the detection (what was measured and why), then one row per screen with each metric from base to head.
126
+
127
+ **What blocks, and only that:** a metric within Google's "good" threshold at the base (LCP 2500 ms, CLS 0.1, INP 200 ms) and over it at the head, by more than this run's noise. The noise is the base measured against itself in the same run, per round (the p90 of the gaps). These are reported without blocking:
128
+
129
+ - a breach already at the base;
130
+ - a breach within the noise;
131
+ - a move above the noise that stays within the threshold;
132
+ - TBT, which has no threshold of its own.
133
+
134
+ **Every figure is proven first.** Each flow must show:
135
+
136
+ - the screen opened, with its texts;
137
+ - every call answered by a mock;
138
+ - an LCP element that is neither a placeholder nor the login form;
139
+ - a second reading of the browser's own entries that agrees with Lighthouse.
140
+
141
+ A flow that fails a proof fails its screen. Its figure is not judged.
142
+
143
+ The folded sections hold the proof of every flow, the medians and the noise, the builds and settings, the time of each phase, and every flow's values.
144
+
145
+ The comment is sized to the 65,536 characters GitHub keeps of a comment: past that, GitHub cuts it mid-sentence. The headline, the detection and the verdict table always stay. Only the last folded sections drop out, and the comment names them. The full comment is then written beside it, to `runtime-analysis-report/runtime-analysis.full.md`.
146
+
147
+ ## Troubleshooting
148
+
149
+ | What you see | What it means |
150
+ | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
151
+ | `runtime-analysis.config.mjs is not valid`, with fields | Fix each named field; `--inspect --runtime-analysis` checks it in seconds. |
152
+ | `no Google Chrome found` | Install Chrome or set `CHROME_PATH`. |
153
+ | `could not install the measure's browser packages … ENOTFOUND on …` | The npm registry was unreachable. In CI, cache `SENTINEL_CACHE_DIR`. |
154
+ | A screen ❌ with `ready 200 (mocked)` failed | The `ready` call has no mock answering 200. |
155
+ | A screen ❌ with `no unhandled request` failed | The screen calls a path no `api` entry answers: add the entry. |
156
+ | `this PR changes none of its screens` | The diff reaches none of the screen's route chain, its shell, its translations or the workspace's build inputs. A change the bundler erases (a type, a comment) does not count. |
157
+
158
+ ## What the role will not do
159
+
160
+ - Measure a real environment: both builds are served on the runner, with mocks, so only the code changes between base and head.
161
+ - Measure a screen that is not in the config: a screen is measured only once it is declared with its proofs.
162
+ - Block on a breach the base already had: that is reported, not blamed on the pull request.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.7.0-alpha.23",
3
+ "version": "1.7.0-alpha.25",
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",