@mark1russell7/conventions 0.52.1 → 0.52.3

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.
@@ -4,7 +4,7 @@ import { createRequire } from "node:module";
4
4
  import { spawnSync } from "node:child_process";
5
5
  import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
6
6
  import { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
7
- import { parseAllDocuments } from "yaml";
7
+ import { LineCounter, isMap, isScalar, parseAllDocuments } from "yaml";
8
8
  import { errorMessage } from "@mark1russell7/text";
9
9
  import { SECRET_SHAPES, findSecretShapes, findSecretShapesInValue, redactSecretShapes } from "@mark1russell7/text/redact";
10
10
  import { createHash } from "node:crypto";
@@ -1776,7 +1776,7 @@ function matrixJobsOf(strategy) {
1776
1776
  return combinations.length + added;
1777
1777
  }
1778
1778
  /** This function reads a job. */
1779
- function parsedJob(id, value) {
1779
+ function parsedJob(id, value, line, lines) {
1780
1780
  const job = isObject$1(value) ? value : {};
1781
1781
  const secrets = secretsOf(job);
1782
1782
  if (job["secrets"] === "inherit") secrets.add("inherit");
@@ -1784,6 +1784,8 @@ function parsedJob(id, value) {
1784
1784
  const limit = strategy["max-parallel"];
1785
1785
  return {
1786
1786
  id,
1787
+ line,
1788
+ lines,
1787
1789
  name: optionalText(job["name"]) || id,
1788
1790
  maxParallel: typeof limit === "number" && Number.isInteger(limit) && limit > 0 ? limit : null,
1789
1791
  matrixJobs: isExpression(job["strategy"]) || isExpression(strategy["matrix"]) ? null : matrixJobsOf(strategy),
@@ -1796,6 +1798,17 @@ function parsedJob(id, value) {
1796
1798
  steps: Array.isArray(job["steps"]) ? job["steps"].map(parsedStep) : []
1797
1799
  };
1798
1800
  }
1801
+ /** This function gives the line of each key of a map node of the parser, two keys deep. A key that is not a scalar has no line. */
1802
+ function keyLinesOf(node, lineOf, prefix = "", depth = 2, into = {}) {
1803
+ if (!isMap(node)) return into;
1804
+ for (const pair of node.items) {
1805
+ if (!isScalar(pair.key) || pair.key.range === void 0 || pair.key.range === null) continue;
1806
+ const path = prefix + String(pair.key.value);
1807
+ into[path] ??= lineOf(pair.key.range[0]);
1808
+ if (depth > 1) keyLinesOf(pair.value, lineOf, `${path}.`, depth - 1, into);
1809
+ }
1810
+ return into;
1811
+ }
1799
1812
  /** This function gives the line (from 1) of the offset `at` of a text. */
1800
1813
  const lineAt$1 = (text, at) => text.slice(0, at).split("\n").length;
1801
1814
  /**
@@ -1803,7 +1816,11 @@ const lineAt$1 = (text, at) => text.slice(0, at).split("\n").length;
1803
1816
  * problem is a fault of the result. A file with a fault gives no trigger and no job.
1804
1817
  */
1805
1818
  function parseWorkflow(file, text) {
1806
- const documents = parseAllDocuments(text, PARSE);
1819
+ const lineCounter = new LineCounter();
1820
+ const documents = parseAllDocuments(text, {
1821
+ ...PARSE,
1822
+ lineCounter
1823
+ });
1807
1824
  const faults = faultsOf(documents);
1808
1825
  const [first, second] = documents;
1809
1826
  if (second !== void 0) faults.push({
@@ -1825,15 +1842,27 @@ function parseWorkflow(file, text) {
1825
1842
  concurrency: null,
1826
1843
  secrets: [],
1827
1844
  jobs: [],
1845
+ lines: {},
1828
1846
  faults
1829
1847
  };
1830
1848
  if (first === void 0 || faults.length > 0) return none;
1831
1849
  try {
1832
1850
  const top = first.toJS();
1833
1851
  if (!isObject$1(top)) return none;
1834
- const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job)) : [];
1852
+ const lineOf = (offset) => lineCounter.linePos(offset).line;
1853
+ const jobNodes = /* @__PURE__ */ new Map();
1854
+ const jobsNode = first.get("jobs");
1855
+ if (isMap(jobsNode)) for (const pair of jobsNode.items) {
1856
+ const at = isScalar(pair.key) ? pair.key.range?.[0] : void 0;
1857
+ if (at !== void 0) jobNodes.set(String(pair.key.value), {
1858
+ line: lineOf(at),
1859
+ lines: keyLinesOf(pair.value, lineOf)
1860
+ });
1861
+ }
1862
+ const jobs = isObject$1(top["jobs"]) ? Object.entries(top["jobs"]).map(([id, job]) => parsedJob(id, job, jobNodes.get(id)?.line ?? 1, jobNodes.get(id)?.lines ?? {})) : [];
1835
1863
  const secrets = secretsOf(top);
1836
1864
  if (jobs.some((job) => job.secrets.includes("inherit"))) secrets.add("inherit");
1865
+ const lines = keyLinesOf(first.contents, lineOf);
1837
1866
  return {
1838
1867
  file,
1839
1868
  name: optionalText(top["name"]) || file,
@@ -1842,6 +1871,7 @@ function parseWorkflow(file, text) {
1842
1871
  concurrency: concurrencyOf(top),
1843
1872
  secrets: [...secrets],
1844
1873
  jobs,
1874
+ lines,
1845
1875
  faults
1846
1876
  };
1847
1877
  } catch (error) {
@@ -2556,57 +2586,33 @@ function scheduleMinute(repository, file) {
2556
2586
  return hash % 59 + 1;
2557
2587
  }
2558
2588
  /** This function tells if a workflow is a shared workflow (`on: workflow_call`). Its caller gives the concurrency group. */
2559
- function isShared(lines) {
2560
- return lines.some((line) => {
2561
- const text = line.trimStart();
2562
- return text.startsWith("workflow_call:") || text === "workflow_call" || text === "- workflow_call" || text.startsWith("on:") && text.includes("workflow_call");
2563
- });
2564
- }
2565
- /** This function gives the jobs of a workflow. */
2566
- function jobsOf(lines) {
2567
- const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && line.startsWith("jobs:"));
2568
- if (jobs < 0) return [];
2569
- const jobIndent = childIndent(lines, jobs);
2570
- const end = blockEnd(lines, jobs);
2571
- const found = [];
2572
- for (let i = jobs + 1; i < end; i++) {
2573
- const line = lines[i] ?? "";
2574
- if (line.trim() === "" || indentOf$1(line) !== jobIndent) continue;
2575
- const keyIndent = childIndent(lines, i);
2576
- const keys = lines.slice(i + 1, blockEnd(lines, i)).filter((text) => indentOf$1(text) === keyIndent);
2577
- const uses = keys.map((text) => keyValue(text, "uses")).find((value) => value !== void 0);
2578
- const at = uses === void 0 ? -1 : uses.indexOf(".github/workflows/");
2579
- const calls = uses === void 0 || at < 0 ? void 0 : uses.slice(at + 18).split("@")[0] ?? "";
2580
- found.push({
2581
- name: line.trim().replace(/:$/, ""),
2582
- line: i + 1,
2583
- grouped: keys.some((text) => keyValue(text, "concurrency") !== void 0),
2584
- ...calls === void 0 ? {} : { calls }
2585
- });
2586
- }
2587
- return found;
2589
+ const isShared = (workflow) => workflow.triggers.includes("workflow_call");
2590
+ /** This function gives the file name of the shared workflow that a job calls (`uses: .../.github/workflows/<name>`), if any. */
2591
+ function callOf$1(job) {
2592
+ const at = job.uses.indexOf(".github/workflows/");
2593
+ return at < 0 ? void 0 : job.uses.slice(at + 18);
2588
2594
  }
2589
- const hasTopGroup = (lines) => lines.some((line) => indentOf$1(line) === 0 && line.startsWith("concurrency:"));
2590
2595
  /**
2591
2596
  * This function gives the edit that adds a concurrency group at the top of a workflow, before `jobs:`. A new run of a pull
2592
2597
  * request stops the old run. A run of another event has the group of its commit, so that no release or scheduled run stops.
2593
2598
  */
2594
- function groupEdits(file, text, lines) {
2595
- const jobs = lines.findIndex((line) => indentOf$1(line) === 0 && line.startsWith("jobs:"));
2596
- if (jobs < 0) return [];
2597
- const pad = " ".repeat(childIndent(lines, jobs) ?? 2);
2598
- const original = text.split(/\r?\n/)[jobs] ?? "jobs:";
2599
- const group = [
2600
- "concurrency:",
2601
- pad + "group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}",
2602
- pad + "cancel-in-progress: ${{ github.event_name == 'pull_request' }}",
2603
- "",
2604
- original
2605
- ];
2599
+ function groupEdits(file, text, workflow) {
2600
+ const jobs = workflow.lines["jobs"];
2601
+ if (jobs === void 0) return [];
2602
+ const originals = text.split(/\r?\n/);
2603
+ const first = workflow.jobs[0];
2604
+ const pad = " ".repeat(first === void 0 ? 2 : indentOf$1(originals[first.line - 1] ?? " ") || 2);
2605
+ const original = originals[jobs - 1] ?? "jobs:";
2606
2606
  return [{
2607
2607
  file,
2608
2608
  before: text,
2609
- after: replaceLine(text, jobs + 1, group)
2609
+ after: replaceLine(text, jobs, [
2610
+ "concurrency:",
2611
+ pad + "group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.sha }}",
2612
+ pad + "cancel-in-progress: ${{ github.event_name == 'pull_request' }}",
2613
+ "",
2614
+ original
2615
+ ])
2610
2616
  }];
2611
2617
  }
2612
2618
  /**
@@ -2614,68 +2620,67 @@ function groupEdits(file, text, lines) {
2614
2620
  * A job that calls a shared workflow of `grouped` gets its group from the jobs of that workflow. A shared workflow gets
2615
2621
  * its group from its caller, but a shared workflow of `grouped` has a group in each job.
2616
2622
  */
2617
- function concurrencyBreaks(file, text, lines, grouped) {
2623
+ function concurrencyBreaks(file, text, workflow, grouped) {
2618
2624
  const name = file.slice(file.lastIndexOf("/") + 1);
2619
- const jobs = jobsOf(lines);
2620
- if (isShared(lines)) {
2625
+ if (isShared(workflow)) {
2621
2626
  if (!grouped.includes(name)) return [];
2622
- return jobs.filter((job) => !job.grouped).map((job) => ({
2627
+ return workflow.jobs.filter((job) => job.concurrency === null).map((job) => ({
2623
2628
  file,
2624
2629
  line: job.line,
2625
- message: `${file}: the job ${job.name} has no concurrency group, and its callers rely on it (the option grouped).`
2630
+ message: `${file}: the job ${job.id} has no concurrency group, and its callers rely on it (the option grouped).`
2626
2631
  }));
2627
2632
  }
2628
- if (hasTopGroup(lines)) return [];
2629
- const missing = jobs.filter((job) => !job.grouped && !(job.calls !== void 0 && grouped.includes(job.calls)));
2630
- const edits = missing.length === 0 ? [] : groupEdits(file, text, lines);
2633
+ if (workflow.concurrency !== null) return [];
2634
+ const missing = workflow.jobs.filter((job) => {
2635
+ const calls = callOf$1(job);
2636
+ return job.concurrency === null && !(calls !== void 0 && grouped.includes(calls));
2637
+ });
2638
+ const edits = missing.length === 0 ? [] : groupEdits(file, text, workflow);
2631
2639
  return missing.map((job) => ({
2632
2640
  file,
2633
2641
  line: job.line,
2634
- message: `${file}: the job ${job.name} has no concurrency group, and the workflow has none.`,
2642
+ message: `${file}: the job ${job.id} has no concurrency group, and the workflow has none.`,
2635
2643
  edits
2636
2644
  }));
2637
2645
  }
2638
2646
  /** This function gives the breaks of the matrices: each `strategy` with a `matrix` has a `max-parallel` of `limit` or less. */
2639
- function matrixBreaks(file, text, lines, limit) {
2647
+ function matrixBreaks(file, text, workflow, limit) {
2640
2648
  const breaks = [];
2641
2649
  const originals = text.split(/\r?\n/);
2642
- lines.forEach((line, index) => {
2643
- if (keyValue(line, "strategy") === void 0) return;
2644
- const keyIndent = childIndent(lines, index);
2645
- if (keyIndent === void 0) return;
2646
- const keys = [];
2647
- for (let i = index + 1; i < blockEnd(lines, index); i++) if ((lines[i] ?? "").trim() !== "" && indentOf$1(lines[i] ?? "") === keyIndent) keys.push(i);
2648
- if (!keys.some((i) => keyValue(lines[i] ?? "", "matrix") !== void 0)) return;
2649
- const at = keys.find((i) => keyValue(lines[i] ?? "", "max-parallel") !== void 0);
2650
- const raw = at === void 0 ? void 0 : keyValue(lines[at] ?? "", "max-parallel");
2651
- const value = raw === void 0 ? NaN : Number(raw);
2652
- const wanted = `${" ".repeat(keyIndent)}max-parallel: ${String(limit)}`;
2653
- if (at === void 0 || raw === void 0) {
2654
- const after = replaceLine(text, index + 1, [originals[index] ?? line, wanted]);
2650
+ for (const job of workflow.jobs) {
2651
+ const strategy = job.lines["strategy"];
2652
+ const matrix = job.lines["strategy.matrix"];
2653
+ if (strategy === void 0 || matrix === void 0) continue;
2654
+ const at = job.lines["strategy.max-parallel"];
2655
+ const block = (line, key) => (originals[line - 1] ?? "").trimStart().startsWith(`${key}:`);
2656
+ const wanted = (line) => `${" ".repeat(indentOf$1(originals[line - 1] ?? ""))}max-parallel: ${String(limit)}`;
2657
+ if (at === void 0) {
2658
+ const edits = block(matrix, "matrix") ? [{
2659
+ file,
2660
+ before: text,
2661
+ after: replaceLine(text, strategy, [originals[strategy - 1] ?? "", wanted(matrix)])
2662
+ }] : [];
2655
2663
  breaks.push({
2656
2664
  file,
2657
- line: index + 1,
2665
+ line: strategy,
2658
2666
  message: `${file}: a matrix has no max-parallel.`,
2659
- edits: [{
2660
- file,
2661
- before: text,
2662
- after
2663
- }]
2667
+ edits
2664
2668
  });
2665
- } else if (!Number.isInteger(value) || value < 1 || value > limit) {
2666
- const after = replaceLine(text, at + 1, [wanted]);
2669
+ } else if (job.maxParallel === null || job.maxParallel > limit) {
2670
+ const edits = block(at, "max-parallel") ? [{
2671
+ file,
2672
+ before: text,
2673
+ after: replaceLine(text, at, [wanted(at)])
2674
+ }] : [];
2675
+ const value = job.maxParallel === null ? "a max-parallel that is not a whole number of 1 or more" : `max-parallel ${String(job.maxParallel)}`;
2667
2676
  breaks.push({
2668
2677
  file,
2669
- line: index + 1,
2670
- message: `${file}: a matrix has max-parallel ${raw}, and the most is ${String(limit)}.`,
2671
- edits: [{
2672
- file,
2673
- before: text,
2674
- after
2675
- }]
2678
+ line: strategy,
2679
+ message: `${file}: a matrix has ${value}, and the most is ${String(limit)}.`,
2680
+ edits
2676
2681
  });
2677
2682
  }
2678
- });
2683
+ }
2679
2684
  return breaks;
2680
2685
  }
2681
2686
  /**
@@ -2768,8 +2773,8 @@ const runnerBudget = {
2768
2773
  } catch {
2769
2774
  continue;
2770
2775
  }
2771
- const lines = workflowLines(text);
2772
- breaks.push(...matrixBreaks(file, text, lines, limit), ...concurrencyBreaks(file, text, lines, grouped));
2776
+ const workflow = parseWorkflow(file.slice(file.lastIndexOf("/") + 1), text);
2777
+ breaks.push(...matrixBreaks(file, text, workflow, limit), ...concurrencyBreaks(file, text, workflow, grouped));
2773
2778
  if (options["minute"] !== false) {
2774
2779
  if (cronLines(text).length > 0 && repository === void 0) breaks.push({
2775
2780
  file,
@@ -3260,7 +3265,7 @@ const securityGate = {
3260
3265
  * GitHub fails at times with a 504, and a bare `curl` then fails the job.
3261
3266
  */
3262
3267
  /** The files of a composite action. */
3263
- const ACTION$3 = /^\.github\/actions\/.+\/action\.ya?ml$/;
3268
+ const ACTION$4 = /^\.github\/actions\/.+\/action\.ya?ml$/;
3264
3269
  /** The action of the template itself. It is the one place with the download. */
3265
3270
  const SHARED_ACTION$1 = ".github/actions/setup-cue/action.yml";
3266
3271
  /** A hand-written install of the cue CLI: a download of a release asset, or a build with `go install`. */
@@ -3307,7 +3312,7 @@ const setupCue = {
3307
3312
  const files = context.gitFiles();
3308
3313
  if (files === void 0) return { skipped: "the root is not in a git repository" };
3309
3314
  const breaks = [];
3310
- for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$3.test(path)) && path !== SHARED_ACTION$1).sort(byCode)) {
3315
+ for (const file of files.filter((path) => (WORKFLOW$1.test(path) || ACTION$4.test(path)) && path !== SHARED_ACTION$1).sort(byCode)) {
3311
3316
  let text;
3312
3317
  try {
3313
3318
  text = readFileSync(join(context.root, file), "utf8");
@@ -3375,7 +3380,7 @@ const SHARED_ACTIONS = [
3375
3380
  /** The `uses` value of a job that calls the shared CI, with no pin. */
3376
3381
  const SHARED_CI = "mark1russell7/template/.github/workflows/reusable-ci.yml";
3377
3382
  /** The action folder of a path: `.github/actions/<name>/action.yml` gives `<name>`. */
3378
- const ACTION$2 = /^\.github\/actions\/([^/]+)\//;
3383
+ const ACTION$3 = /^\.github\/actions\/([^/]+)\//;
3379
3384
  /** The file name of a path. */
3380
3385
  const baseName = (path) => path.slice(path.lastIndexOf("/") + 1);
3381
3386
  /** This function tells if a job of a workflow text uses the shared CI of the template. */
@@ -3439,7 +3444,7 @@ const sharedCi = {
3439
3444
  });
3440
3445
  const actions = /* @__PURE__ */ new Set();
3441
3446
  for (const file of files) {
3442
- const folder = ACTION$2.exec(file)?.[1];
3447
+ const folder = ACTION$3.exec(file)?.[1];
3443
3448
  if (folder !== void 0 && SHARED_ACTIONS.includes(folder) && !actions.has(folder)) {
3444
3449
  actions.add(folder);
3445
3450
  breaks.push({
@@ -17711,7 +17716,7 @@ function movedTo(repo, moves) {
17711
17716
  * Each run of the workflow then fails before it starts ("workflow file issue"), and no job shows why.
17712
17717
  */
17713
17718
  /** The files of a composite action. */
17714
- const ACTION$1 = /^\.github\/actions\/.+\/action\.ya?ml$/;
17719
+ const ACTION$2 = /^\.github\/actions\/.+\/action\.ya?ml$/;
17715
17720
  /** The value of `uses:` that names another repository: `owner/name`, then a path or nothing, then `@` and the ref. */
17716
17721
  const REMOTE = /^([\w.-]+)\/([\w.-]+)(\/[^@\s]*)?@\S+$/;
17717
17722
  /** This function gives each `uses:` of a workflow or an action that names another repository. A local path (`./`) and a Docker image (`docker://`) are not calls of a repository. */
@@ -17767,7 +17772,7 @@ const movedRepoCalls = {
17767
17772
  if (bad !== void 0) return { skipped: `the option moves has "${bad.text}", which is not in the form owner/name=owner/name` };
17768
17773
  const moves = [...MOVES, ...extra.map((each) => each.move)];
17769
17774
  const breaks = [];
17770
- for (const file of files.filter((path) => WORKFLOW$1.test(path) || ACTION$1.test(path)).sort(byCode)) {
17775
+ for (const file of files.filter((path) => WORKFLOW$1.test(path) || ACTION$2.test(path)).sort(byCode)) {
17771
17776
  let text;
17772
17777
  try {
17773
17778
  text = readFileSync(join(context.root, file), "utf8");
@@ -17795,6 +17800,222 @@ const movedRepoCalls = {
17795
17800
  return breaks;
17796
17801
  }
17797
17802
  };
17803
+ // src/places.ts
17804
+ /**
17805
+ * The places of a repository that name another repository: links, package fields, workflow keys and config values.
17806
+ * When a repository moves to another owner, each such place that names the old owner is stale. Some places break at
17807
+ * once. npm provenance compares the field `repository` with the repository of the run. A GitHub Pages address of the
17808
+ * old owner gives 404. A `uses:` line does not follow the move (the rule `moved-repo-calls` holds that kind). The other
17809
+ * places go through a redirect only until a new repository takes the old name.
17810
+ *
17811
+ * A kind of place is data: its id, the files it reads and a pure function. The function finds each place in a file.
17812
+ * The rule `moved-repo-names` and the move plan read the same kinds. This file reads no file and starts no program.
17813
+ */
17814
+ /** An owner or a name of a repository on GitHub. */
17815
+ const PART = "[A-Za-z0-9_.-]+";
17816
+ /**
17817
+ * A repository in a URL or a specifier: `github.com/owner/name`, `github.com:owner/name` (SSH) and `github:owner/name`.
17818
+ * The name stops before `/`, `#`, `?`, a quote, a bracket, a space or the end.
17819
+ */
17820
+ const HOSTED = new RegExp(`(?<![\\w.-])(?:github\\.com[/:]|github:)(${PART})/(${PART})`, "gd");
17821
+ /** A GitHub Pages address of a project: `owner.github.io/name`. */
17822
+ const PAGES = new RegExp(`(?<![\\w.-])(${PART})\\.github\\.io/(${PART})`, "gd");
17823
+ /** The paths of GitHub that are not owners. */
17824
+ const NOT_OWNERS = /* @__PURE__ */ new Set([
17825
+ "orgs",
17826
+ "users",
17827
+ "settings",
17828
+ "marketplace",
17829
+ "features",
17830
+ "sponsors",
17831
+ "apps",
17832
+ "topics",
17833
+ "collections",
17834
+ "login",
17835
+ "about",
17836
+ "pricing"
17837
+ ]);
17838
+ /** This function gives the name of a repository without the end `.git` and without dots at the end (the end of a sentence). */
17839
+ function bareName(name) {
17840
+ return name.replace(/\.git$/i, "").replace(/\.+$/, "");
17841
+ }
17842
+ /** This function gives each match of `pattern` in the lines of `text`, as a name of a repository. The pattern has the flag d, and the place starts at its group 1 (the owner). */
17843
+ function matches(text, pattern, form, skip = () => false) {
17844
+ const found = [];
17845
+ text.split(/\r?\n/).forEach((line, index) => {
17846
+ if (skip(line)) return;
17847
+ for (const match of line.matchAll(pattern)) {
17848
+ const owner = match[1] ?? "";
17849
+ const name = bareName(match[2] ?? "");
17850
+ if (name === "" || NOT_OWNERS.has(owner.toLowerCase())) continue;
17851
+ const written = form === "pages" ? `${owner}.github.io/${name}` : `${owner}/${name}`;
17852
+ const column = match.indices?.[1]?.[0] ?? 0;
17853
+ found.push({
17854
+ line: index + 1,
17855
+ column,
17856
+ text: written,
17857
+ repo: `${owner}/${name}`.toLowerCase(),
17858
+ form
17859
+ });
17860
+ }
17861
+ });
17862
+ return found;
17863
+ }
17864
+ /** This function gives each GitHub address and each Pages address in a text. */
17865
+ function links(text, skip) {
17866
+ return [...matches(text, HOSTED, "repo", skip), ...matches(text, PAGES, "pages", skip)].sort((a, b) => a.line - b.line || a.column - b.column);
17867
+ }
17868
+ /** This function gives each value `"owner/name"` of a key in a JSON text, for a key that names a repository with no host. */
17869
+ function bareValues(text, keys) {
17870
+ return matches(text, new RegExp(`"(?:${keys.join("|")})"\\s*:\\s*"(${PART})/(${PART})"`, "gd"), "repo");
17871
+ }
17872
+ /** The file of a package. */
17873
+ const MANIFEST = /(^|\/)package\.json$/;
17874
+ /** A Markdown file. A change log is a record of the past: its links go through the redirect, so the kinds do not read it. */
17875
+ const MARKDOWN = /\.mdx?$/i;
17876
+ const CHANGELOG = /(^|\/)CHANGELOG\.md$/i;
17877
+ /** A file of a composite action. */
17878
+ const ACTION$1 = /^\.github\/actions\/.+\/action\.ya?ml$/;
17879
+ /** The kinds of place of the core, in the order of a report. */
17880
+ const PLACE_KINDS = [
17881
+ {
17882
+ id: "package-fields",
17883
+ title: "The fields repository, homepage and bugs and the git dependencies of each package.json. npm provenance compares the field repository with the repository of the run.",
17884
+ reads: (file) => MANIFEST.test(file),
17885
+ find: (text) => [...links(text), ...bareValues(text, ["repository"])]
17886
+ },
17887
+ {
17888
+ id: "doc-links",
17889
+ title: "The links, the badges and the Pages addresses of each Markdown file, except a change log.",
17890
+ reads: (file) => MARKDOWN.test(file) && !CHANGELOG.test(file),
17891
+ find: (text) => links(text)
17892
+ },
17893
+ {
17894
+ id: "workflow-names",
17895
+ title: "The addresses and each key repository of a workflow or a composite action, except uses: (the rule moved-repo-calls).",
17896
+ reads: (file) => WORKFLOW$1.test(file) || ACTION$1.test(file),
17897
+ find: (text) => {
17898
+ const skip = (line) => line.trimStart().startsWith("#") || keyValue(line, "uses") !== void 0;
17899
+ const keys = [];
17900
+ text.split(/\r?\n/).forEach((line, index) => {
17901
+ if (skip(line)) return;
17902
+ const value = keyValue(line, "repository");
17903
+ const match = value === void 0 ? null : new RegExp(`^(${PART})/(${PART})$`).exec(value);
17904
+ if (match === null) return;
17905
+ const written = `${match[1] ?? ""}/${match[2] ?? ""}`;
17906
+ keys.push({
17907
+ line: index + 1,
17908
+ column: line.indexOf(written),
17909
+ text: written,
17910
+ repo: written.toLowerCase(),
17911
+ form: "repo"
17912
+ });
17913
+ });
17914
+ return [...links(text, skip), ...keys].sort((a, b) => a.line - b.line || a.column - b.column);
17915
+ }
17916
+ },
17917
+ {
17918
+ id: "config-repos",
17919
+ title: "The key repo of the change log of Changesets, and the addresses in the config of Renovate.",
17920
+ reads: (file) => file === ".changeset/config.json" || /^(\.github\/)?renovate\.json5?$/.test(file),
17921
+ find: (text) => [...links(text), ...bareValues(text, ["repo"])]
17922
+ }
17923
+ ];
17924
+ /**
17925
+ * This function gives each place of a file that names a moved repository by an old name. A name that the moves do not
17926
+ * know is not stale. The replacement keeps the form of the place: `owner/name` or `owner.github.io/name`.
17927
+ */
17928
+ function stalePlaces(file, text, moves, kinds = PLACE_KINDS) {
17929
+ const found = [];
17930
+ for (const kind of kinds) {
17931
+ if (!kind.reads(file)) continue;
17932
+ for (const named of kind.find(text, file)) {
17933
+ const to = movedTo(named.repo, moves);
17934
+ if (to === void 0) continue;
17935
+ const [owner = "", name = ""] = to.split("/");
17936
+ const replacement = named.form === "pages" ? `${owner}.github.io/${name}` : to;
17937
+ found.push({
17938
+ ...named,
17939
+ kind: kind.id,
17940
+ file,
17941
+ to,
17942
+ replacement
17943
+ });
17944
+ }
17945
+ }
17946
+ return found;
17947
+ }
17948
+ /**
17949
+ * This function gives the text with each stale place replaced. A place whose text is not at its line and column (an
17950
+ * earlier replacement moved it) stays as it is, and the next check finds it again.
17951
+ */
17952
+ function replacePlaces(text, places) {
17953
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
17954
+ const lines = text.split(/\r?\n/);
17955
+ const order = [...places].sort((a, b) => a.line - b.line || b.column - a.column);
17956
+ for (const place of order) {
17957
+ const line = lines[place.line - 1];
17958
+ if (line === void 0 || line.slice(place.column, place.column + place.text.length) !== place.text) continue;
17959
+ lines[place.line - 1] = line.slice(0, place.column) + place.replacement + line.slice(place.column + place.text.length);
17960
+ }
17961
+ return lines.join(eol);
17962
+ }
17963
+ // src/rules/moved-repo-names.ts
17964
+ /**
17965
+ * The rule `moved-repo-names`: no package field, Markdown link, workflow key or config value names a repository by the
17966
+ * old name of a move. The kinds of place are in `places.ts`. The rule `moved-repo-calls` holds `uses:`.
17967
+ */
17968
+ const movedRepoNames = {
17969
+ id: "moved-repo-names",
17970
+ title: "No package field, Markdown link, workflow key or config value names a repository by an old owner after the repository moved.",
17971
+ reason: "Some old names break at once: npm provenance compares the field repository of package.json with the repository of the run, and a GitHub Pages address of the old owner gives 404. The other old names go through a redirect only until a new repository takes the old name. On 2026-11-24, 11 repositories moved to metrograph-labs, and each place was found and changed by hand.",
17972
+ fix: "Write the new owner in each place. `conventions fix` writes each one. A change log is not read: it is a record of the past.",
17973
+ sources: [{
17974
+ repo: "private",
17975
+ rule: "repo-move-tool",
17976
+ doc: "a decision of 2026-11-25: one gate holds each place that names a moved repository"
17977
+ }],
17978
+ options: { moves: {
17979
+ type: "strings",
17980
+ default: [],
17981
+ description: "More moves for this repository, each in the form `owner/name=owner/name`, after the moves that the package knows."
17982
+ } },
17983
+ failsFrom: "2026-12-10",
17984
+ check(context, options) {
17985
+ const files = context.gitFiles();
17986
+ if (files === void 0) return { skipped: "the root is not in a git repository" };
17987
+ const extra = options["moves"].map((text) => ({
17988
+ text,
17989
+ move: parseMove(text)
17990
+ }));
17991
+ const bad = extra.find((each) => each.move === void 0);
17992
+ if (bad !== void 0) return { skipped: `the option moves has "${bad.text}", which is not in the form owner/name=owner/name` };
17993
+ const moves = [...MOVES, ...extra.map((each) => each.move)];
17994
+ const breaks = [];
17995
+ for (const file of files.filter((path) => PLACE_KINDS.some((kind) => kind.reads(path))).sort(byCode)) {
17996
+ let text;
17997
+ try {
17998
+ text = readFileSync(join(context.root, file), "utf8");
17999
+ } catch {
18000
+ continue;
18001
+ }
18002
+ const places = stalePlaces(file, text, moves);
18003
+ if (places.length === 0) continue;
18004
+ const after = replacePlaces(text, places);
18005
+ for (const place of places) breaks.push({
18006
+ file,
18007
+ line: place.line,
18008
+ message: `${file} names ${place.text} (${place.kind}), which moved to ${place.to}. Write ${place.replacement} in its place.`,
18009
+ ...after === text ? {} : { edits: [{
18010
+ file,
18011
+ before: text,
18012
+ after
18013
+ }] }
18014
+ });
18015
+ }
18016
+ return breaks;
18017
+ }
18018
+ };
17798
18019
  // src/rules/no-build-output.ts
17799
18020
  /**
17800
18021
  * The rule `no-build-output`: git does not keep build output.
@@ -21673,6 +21894,423 @@ const roadmapParses = {
21673
21894
  return breaks;
21674
21895
  }
21675
21896
  };
21897
+ // src/workflow-expression.ts
21898
+ /** The events of a pull request: `github.head_ref` is not empty only on these. */
21899
+ const PULL_REQUEST_EVENTS = /* @__PURE__ */ new Set([
21900
+ "pull_request",
21901
+ "pull_request_target",
21902
+ "pull_request_review",
21903
+ "pull_request_review_comment"
21904
+ ]);
21905
+ const literal = (text, truthy) => ({
21906
+ parts: /* @__PURE__ */ new Set(),
21907
+ truthy,
21908
+ text
21909
+ });
21910
+ const unknownBool = {
21911
+ parts: /* @__PURE__ */ new Set(),
21912
+ truthy: void 0
21913
+ };
21914
+ const union = (a, b) => ({
21915
+ parts: /* @__PURE__ */ new Set([...a.parts, ...b.parts]),
21916
+ truthy: a.truthy === b.truthy ? a.truthy : void 0
21917
+ });
21918
+ /** This function gives the part of a context path (lower case, with dots), or undefined for `github.event_name`. */
21919
+ function partOf(path) {
21920
+ if (/^github\.(ref|ref_name|head_ref|base_ref)$/.test(path) || /^github\.event\.(number|pull_request\.(number|head\.ref))$/.test(path)) return "ref";
21921
+ if (/^github\.(sha|event\.after|event\.pull_request\.head\.sha)$/.test(path)) return "commit";
21922
+ if (/^github\.run_(id|number|attempt)$/.test(path)) return "run";
21923
+ if (/^(inputs|github\.event\.inputs)(\.|$)/.test(path)) return "input";
21924
+ return "other";
21925
+ }
21926
+ /** This function gives the value of a context path on the event. */
21927
+ function contextValue(path, event) {
21928
+ const name = path.toLowerCase();
21929
+ if (name === "github.event_name") return literal(event, event !== "");
21930
+ if (/^github\.(workflow|repository|repository_owner|event\.repository\.\w+)$/.test(name)) return {
21931
+ parts: /* @__PURE__ */ new Set(),
21932
+ truthy: true
21933
+ };
21934
+ if (name === "github.head_ref") return {
21935
+ parts: /* @__PURE__ */ new Set(["ref"]),
21936
+ truthy: PULL_REQUEST_EVENTS.has(event)
21937
+ };
21938
+ const part = partOf(name);
21939
+ return {
21940
+ parts: /* @__PURE__ */ new Set([part]),
21941
+ truthy: part === "ref" || part === "commit" || part === "run" ? true : void 0
21942
+ };
21943
+ }
21944
+ /** This function gives the tokens of an expression, or undefined when it has a character that GitHub does not take. */
21945
+ function tokensOf(body) {
21946
+ const tokens = [];
21947
+ let at = 0;
21948
+ while (at < body.length) {
21949
+ const rest = body.slice(at);
21950
+ const space = /^\s+/.exec(rest);
21951
+ if (space) {
21952
+ at += space[0].length;
21953
+ continue;
21954
+ }
21955
+ const match = /^'((?:[^']|'')*)'/.exec(rest) ?? /^(-?\d+(?:\.\d+)?)/.exec(rest) ?? /^([A-Za-z_][\w-]*(?:\s*(?:\.\s*[A-Za-z_*][\w-]*|\[\s*'(?:[^']|'')*'\s*\]|\[\s*\*\s*\]))*)/.exec(rest) ?? /^(&&|\|\||==|!=|<=|>=|[!<>(),])/.exec(rest);
21956
+ if (!match) return void 0;
21957
+ const text = match[0];
21958
+ const kind = text.startsWith("'") ? "string" : /^-?\d/.test(text) ? "number" : /^[A-Za-z_]/.test(text) ? "name" : "op";
21959
+ tokens.push({
21960
+ kind,
21961
+ text: kind === "string" ? (match[1] ?? "").replaceAll("''", "'") : text
21962
+ });
21963
+ at += text.length;
21964
+ }
21965
+ return tokens;
21966
+ }
21967
+ /** This function gives the path of a context name: lower case, with dots, and `['x']` as `.x`. */
21968
+ const pathOf = (name) => name.replace(/\s+/g, "").replace(/\['((?:[^']|'')*)'\]/g, (_, key) => `.${key.replaceAll("''", "'")}`).toLowerCase();
21969
+ /** This function reads an expression on the event. It gives undefined when the expression does not parse. */
21970
+ function evaluateExpression(body, event) {
21971
+ const tokens = tokensOf(body);
21972
+ if (tokens === void 0 || tokens.length === 0) return void 0;
21973
+ let at = 0;
21974
+ const peek = () => tokens[at];
21975
+ const take = (text) => {
21976
+ if (peek()?.kind === "op" && peek()?.text === text) {
21977
+ at++;
21978
+ return true;
21979
+ }
21980
+ return false;
21981
+ };
21982
+ const primary = () => {
21983
+ const token = tokens[at++];
21984
+ if (token === void 0) return void 0;
21985
+ if (token.kind === "string") return literal(token.text, token.text !== "");
21986
+ if (token.kind === "number") return literal(String(Number(token.text)), Number(token.text) !== 0);
21987
+ if (token.kind === "op") {
21988
+ if (token.text !== "(") return void 0;
21989
+ const inner = or();
21990
+ return inner !== void 0 && take(")") ? inner : void 0;
21991
+ }
21992
+ const name = token.text.toLowerCase();
21993
+ if (name === "true" || name === "false") return literal(name, name === "true");
21994
+ if (name === "null") return literal("", false);
21995
+ if (!take("(")) return contextValue(pathOf(token.text), event);
21996
+ const args = [];
21997
+ if (!take(")")) {
21998
+ do {
21999
+ const arg = or();
22000
+ if (arg === void 0) return void 0;
22001
+ args.push(arg);
22002
+ } while (take(","));
22003
+ if (!take(")")) return void 0;
22004
+ }
22005
+ const parts = new Set(args.flatMap((arg) => [...arg.parts]));
22006
+ if (name === "format" || name === "join" || name === "tojson") return {
22007
+ parts,
22008
+ truthy: name === "format" ? void 0 : true
22009
+ };
22010
+ if (name === "contains" || name === "startswith" || name === "endswith" || name === "always" || name === "success" || name === "failure" || name === "cancelled") return unknownBool;
22011
+ return {
22012
+ parts,
22013
+ truthy: void 0
22014
+ };
22015
+ };
22016
+ const not = () => {
22017
+ if (!take("!")) return primary();
22018
+ const value = not();
22019
+ return value === void 0 ? void 0 : {
22020
+ parts: /* @__PURE__ */ new Set(),
22021
+ truthy: value.truthy === void 0 ? void 0 : !value.truthy
22022
+ };
22023
+ };
22024
+ const compare = () => {
22025
+ const left = not();
22026
+ if (left === void 0) return void 0;
22027
+ const op = peek();
22028
+ if (op?.kind !== "op" || ![
22029
+ "==",
22030
+ "!=",
22031
+ "<",
22032
+ "<=",
22033
+ ">",
22034
+ ">="
22035
+ ].includes(op.text)) return left;
22036
+ at++;
22037
+ const right = not();
22038
+ if (right === void 0) return void 0;
22039
+ if ((op.text === "==" || op.text === "!=") && left.text !== void 0 && right.text !== void 0) {
22040
+ const same = left.text.toLowerCase() === right.text.toLowerCase();
22041
+ return literal(String(same === (op.text === "==")), same === (op.text === "=="));
22042
+ }
22043
+ return unknownBool;
22044
+ };
22045
+ const and = () => {
22046
+ let left = compare();
22047
+ while (left !== void 0 && take("&&")) {
22048
+ const right = compare();
22049
+ if (right === void 0) return void 0;
22050
+ left = left.truthy === false ? left : left.truthy === true ? right : union(left, right);
22051
+ }
22052
+ return left;
22053
+ };
22054
+ const or = () => {
22055
+ let left = and();
22056
+ while (left !== void 0 && take("||")) {
22057
+ const right = and();
22058
+ if (right === void 0) return void 0;
22059
+ left = left.truthy === true ? left : left.truthy === false ? right : union(left, right);
22060
+ }
22061
+ return left;
22062
+ };
22063
+ const value = or();
22064
+ return value !== void 0 && at === tokens.length ? value : void 0;
22065
+ }
22066
+ /** This function gives the bodies of the expressions of a text (the parts between `${{` and `}}`). */
22067
+ function bodiesOf(text) {
22068
+ const bodies = [];
22069
+ let at = text.indexOf("${{");
22070
+ while (at >= 0) {
22071
+ const end = text.indexOf("}}", at + 3);
22072
+ if (end < 0) break;
22073
+ bodies.push(text.slice(at + 3, end));
22074
+ at = text.indexOf("${{", end + 2);
22075
+ }
22076
+ return bodies;
22077
+ }
22078
+ /**
22079
+ * This function gives the parts of a run that a concurrency group depends on, on the event. A group with no expression
22080
+ * depends on no part: all runs share it. An expression that does not parse depends on the run, so each run has its own group.
22081
+ */
22082
+ function groupParts(group, event) {
22083
+ const parts = /* @__PURE__ */ new Set();
22084
+ for (const body of bodiesOf(group)) {
22085
+ const value = evaluateExpression(body, event);
22086
+ if (value === void 0) parts.add("run");
22087
+ else for (const part of value.parts) parts.add(part);
22088
+ }
22089
+ return parts;
22090
+ }
22091
+ /**
22092
+ * This function tells if a job with the condition `condition` (an `if`, with or with no `${{ }}`) can run on the event.
22093
+ * It is false only when the condition is false on each run of the event.
22094
+ */
22095
+ function mayRun(condition, event) {
22096
+ const text = condition.trim();
22097
+ if (text === "") return true;
22098
+ const whole = /^\$\{\{([\s\S]*)\}\}$/.exec(text);
22099
+ return evaluateExpression(whole ? whole[1] ?? "" : text, event)?.truthy !== false;
22100
+ }
22101
+ // src/rules/runner-peak.ts
22102
+ /**
22103
+ * The rule `runner-peak`: the workflows of a repository hold at most its share of the runners in a busy minute. The peak
22104
+ * of a job is the jobs of one run (a matrix, capped by its `max-parallel`) times the runs that its concurrency group lets
22105
+ * run at one time. A burst of merges on `push` and a burst of pull requests give these runs. The peak of a workflow is
22106
+ * the sum over its jobs.
22107
+ */
22108
+ /** The jobs of a matrix that the reader cannot count and that has no `max-parallel`: the most that the rule runner-budget lets run. */
22109
+ const UNKNOWN_MATRIX_JOBS = 3;
22110
+ const PUSH_EVENTS = /* @__PURE__ */ new Set([
22111
+ "push",
22112
+ "merge_group",
22113
+ "workflow_run"
22114
+ ]);
22115
+ const PULL_EVENTS = /* @__PURE__ */ new Set(["pull_request", "pull_request_target"]);
22116
+ /** This function gives the class of an event, or undefined for `workflow_call`: the caller counts the jobs of a called workflow. */
22117
+ function eventClass(event) {
22118
+ if (event === "workflow_call") return void 0;
22119
+ return PUSH_EVENTS.has(event) ? "push" : PULL_EVENTS.has(event) ? "pull" : "other";
22120
+ }
22121
+ /**
22122
+ * This function gives the runs of a concurrency group that run at one time on the event. A group that depends on the commit
22123
+ * or the run, or no group, gives a burst on `push` and on pull requests. A group of the branch gives one run on `push` (the
22124
+ * default branch) and a burst of pull requests. Each other event gives one run.
22125
+ */
22126
+ function runsAtOnce(concurrency, event, burst) {
22127
+ const kind = eventClass(event);
22128
+ if (kind === void 0 || kind === "other") return 1;
22129
+ if (concurrency === null) return burst;
22130
+ const parts = groupParts(concurrency.group, event);
22131
+ if (parts.has("commit") || parts.has("run")) return burst;
22132
+ return parts.has("ref") && kind === "pull" ? burst : 1;
22133
+ }
22134
+ /** The file name of the workflow that a job calls, and if it is a file of the same repository (`./.github/workflows/`). */
22135
+ function callOf(job) {
22136
+ const at = job.uses.indexOf(".github/workflows/");
22137
+ if (at < 0) return void 0;
22138
+ return {
22139
+ name: job.uses.slice(at + 18),
22140
+ local: job.uses.startsWith("./")
22141
+ };
22142
+ }
22143
+ /** This function gives the jobs of one run of a job that calls no workflow: 1, or the jobs of its matrix that run together. */
22144
+ function matrixPeak(job) {
22145
+ if (job.lines["strategy.matrix"] === void 0) return 1;
22146
+ const limit = job.maxParallel;
22147
+ if (job.matrixJobs === null) return limit ?? 3;
22148
+ return Math.max(1, Math.min(job.matrixJobs, limit ?? job.matrixJobs));
22149
+ }
22150
+ /** This function gives the jobs of one run of a workflow on the event: the sum over the jobs that can run on it. */
22151
+ function jobsOfRun(workflow, event, local, options, seen) {
22152
+ let jobs = 0;
22153
+ let known = true;
22154
+ for (const job of workflow.jobs) {
22155
+ if (!mayRun(job.if, event)) continue;
22156
+ const one = jobOfRun(job, event, local, options, seen);
22157
+ jobs += one.jobs;
22158
+ known &&= one.known;
22159
+ }
22160
+ return {
22161
+ jobs,
22162
+ known
22163
+ };
22164
+ }
22165
+ /** This function gives the jobs of one run of a job: its matrix, or the jobs of the workflow that it calls. */
22166
+ function jobOfRun(job, event, local, options, seen) {
22167
+ const call = callOf(job);
22168
+ if (call === void 0) return {
22169
+ jobs: matrixPeak(job),
22170
+ known: true
22171
+ };
22172
+ const file = call.local ? local.get(call.name) : void 0;
22173
+ if (file !== void 0) return seen.has(call.name) ? {
22174
+ jobs: 0,
22175
+ known: true
22176
+ } : jobsOfRun(file, event, local, options, /* @__PURE__ */ new Set([...seen, call.name]));
22177
+ const count = options.called[call.name];
22178
+ return count === void 0 ? {
22179
+ jobs: 1,
22180
+ known: false
22181
+ } : {
22182
+ jobs: count,
22183
+ known: true
22184
+ };
22185
+ }
22186
+ /**
22187
+ * This function gives the peak of each workflow of a repository in a busy minute. In each class of events, it takes the
22188
+ * event with the most jobs. The peak of a job is its jobs of one run times the runs of its group (the group at the top of
22189
+ * the file, else the group of the job). The sum over the jobs is an upper bound: a job that `needs` another job does not
22190
+ * run at the same time as it.
22191
+ */
22192
+ function workflowPeaks(workflows, options) {
22193
+ const local = new Map(workflows.map((workflow) => [workflow.file, workflow]));
22194
+ return workflows.flatMap((workflow) => {
22195
+ const classes = {};
22196
+ for (const event of workflow.triggers) {
22197
+ const kind = eventClass(event);
22198
+ if (kind === void 0) continue;
22199
+ const jobs = workflow.jobs.filter((job) => mayRun(job.if, event)).map((job) => {
22200
+ const one = jobOfRun(job, event, local, options, /* @__PURE__ */ new Set([workflow.file]));
22201
+ return {
22202
+ id: job.id,
22203
+ line: job.line,
22204
+ jobs: one.jobs,
22205
+ runs: runsAtOnce(workflow.concurrency ?? job.concurrency, event, options.burst),
22206
+ known: one.known
22207
+ };
22208
+ });
22209
+ const peak = jobs.reduce((sum, job) => sum + job.jobs * job.runs, 0);
22210
+ if (peak > (classes[kind]?.peak ?? -1)) classes[kind] = {
22211
+ event,
22212
+ peak,
22213
+ jobs
22214
+ };
22215
+ }
22216
+ const peak = Object.values(classes).reduce((sum, item) => sum + item.peak, 0);
22217
+ return Object.keys(classes).length === 0 ? [] : [{
22218
+ file: workflow.file,
22219
+ peak,
22220
+ classes
22221
+ }];
22222
+ });
22223
+ }
22224
+ /** This function reads the option `called`: a list of `<file>=<jobs>`. A pair that does not parse is left out. */
22225
+ function calledJobs(values) {
22226
+ const out = {};
22227
+ for (const value of values) {
22228
+ const match = /^\s*([^=\s]+)\s*=\s*(\d+)\s*$/.exec(value);
22229
+ if (match) out[match[1] ?? ""] = Number(match[2]);
22230
+ }
22231
+ return out;
22232
+ }
22233
+ /** This function gives the text of the peak of a workflow: `ci.yml 15 (push: 5 runs of 3 jobs)`. */
22234
+ function peakText(item) {
22235
+ const parts = Object.entries(item.classes).map(([kind, value]) => {
22236
+ const runs = Math.max(...value.jobs.map((job) => job.runs), 0);
22237
+ const unknown = value.jobs.some((job) => !job.known) ? ", a call of an unknown workflow counts 1" : "";
22238
+ return `${kind} ${String(value.peak)} on ${value.event} (up to ${String(runs)} runs at one time${unknown})`;
22239
+ });
22240
+ return `${item.file.slice(item.file.lastIndexOf("/") + 1)} ${String(item.peak)}: ${parts.join("; ")}`;
22241
+ }
22242
+ /**
22243
+ * The jobs of each run of the shared workflows of the template, on the event with the most jobs. A test of the template
22244
+ * computes them from its files, so a change of a shared workflow changes this list.
22245
+ */
22246
+ const TEMPLATE_CALLED = [
22247
+ "reusable-ai-review.yml=1",
22248
+ "reusable-ci.yml=7",
22249
+ "reusable-codex-review.yml=2",
22250
+ "reusable-lockfile.yml=1",
22251
+ "reusable-mutation.yml=5",
22252
+ "reusable-pages-check.yml=1",
22253
+ "reusable-pages.yml=4",
22254
+ "reusable-queue.yml=1",
22255
+ "reusable-release-build.yml=1",
22256
+ "reusable-release-tag.yml=1",
22257
+ "reusable-release-tree.yml=1",
22258
+ "reusable-security.yml=3"
22259
+ ];
22260
+ const runnerPeak = {
22261
+ id: "runner-peak",
22262
+ title: "The workflows of a repository hold at most its share of the runners in a busy minute.",
22263
+ reason: "The repositories of an account or an organization share its runners. The rule runner-budget caps each matrix and each workflow, but not the sum: a run of main has the group of its commit (the rule main-runs-finish), so a burst of merges starts a full run for each merge. On 2026-11-24, five push runs of one repository waited with 58 of the 60 jobs of its organization, and a bench of that repository waited 15.9 minutes for a runner.",
22264
+ fix: "Lower the `max-parallel` of the largest matrices, run heavy jobs only on `workflow_dispatch` or a schedule, or give a job that a run of `push` does not need an `if` that is false on `push`. Else the organization gives the repository a larger share (the option share).",
22265
+ sources: [{
22266
+ repo: "private",
22267
+ rule: "runner-slots",
22268
+ doc: "a decision of 2026-10-30: the runner slots: a cap of 40, heavy work at most 28"
22269
+ }],
22270
+ failsFrom: "2026-12-09",
22271
+ options: {
22272
+ share: {
22273
+ type: "number",
22274
+ default: 0,
22275
+ description: "The most jobs that the workflows of the repository hold at one time in a busy minute. The organization gives each repository its share of the pool. 0 turns the rule off: the CI of the template alone can hold 145 jobs in a busy minute, so no one share fits each repository."
22276
+ },
22277
+ burst: {
22278
+ type: "number",
22279
+ default: 5,
22280
+ description: "The runs of push, or of pull requests, that start in a busy minute when each run has its own group."
22281
+ },
22282
+ called: {
22283
+ type: "strings",
22284
+ default: TEMPLATE_CALLED,
22285
+ description: "The jobs of each run of a called workflow of another repository, as `<file>=<jobs>`. A call of a workflow that is not in the list counts 1."
22286
+ }
22287
+ },
22288
+ check(context, options) {
22289
+ const share = Number(options["share"]);
22290
+ if (!(share > 0)) return { skipped: "the option share is 0" };
22291
+ const files = context.gitFiles();
22292
+ if (files === void 0) return { skipped: "the root is not in a git repository" };
22293
+ const paths = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
22294
+ if (paths.length === 0) return { skipped: "the repository has no workflow" };
22295
+ const workflows = [];
22296
+ for (const path of paths) try {
22297
+ workflows.push(parseWorkflow(path.slice(path.lastIndexOf("/") + 1), readFileSync(join(context.root, path), "utf8")));
22298
+ } catch {
22299
+ continue;
22300
+ }
22301
+ const called = calledJobs(Array.isArray(options["called"]) ? options["called"] : []);
22302
+ const peaks = workflowPeaks(workflows, {
22303
+ burst: Math.max(1, Number(options["burst"])),
22304
+ called
22305
+ }).sort((a, b) => b.peak - a.peak);
22306
+ const total = peaks.reduce((sum, item) => sum + item.peak, 0);
22307
+ if (total <= share) return [];
22308
+ return [{
22309
+ file: `.github/workflows/${peaks[0]?.file ?? ""}`,
22310
+ message: `The workflows can hold ${String(total)} jobs at one time in a busy minute, and the share of the repository is ${String(share)}. ${peaks.map(peakText).join(". ")}.`
22311
+ }];
22312
+ }
22313
+ };
21676
22314
  // src/rules/schedule-literals.ts
21677
22315
  /**
21678
22316
  * The rule `schedule-literals`: a workflow can compare `github.event.schedule` with a cron in quotes. Each such cron
@@ -23396,6 +24034,7 @@ const RULES = [
23396
24034
  roadmapParses,
23397
24035
  workflowParses,
23398
24036
  runnerBudget,
24037
+ runnerPeak,
23399
24038
  mainRunsFinish,
23400
24039
  pushMainOnly,
23401
24040
  pipeFails,
@@ -23409,6 +24048,7 @@ const RULES = [
23409
24048
  setupCue,
23410
24049
  playwrightInstall,
23411
24050
  movedRepoCalls,
24051
+ movedRepoNames,
23412
24052
  scheduleLiterals,
23413
24053
  homePackage,
23414
24054
  homeModule,
@@ -24429,6 +25069,6 @@ function runHook(args, io) {
24429
25069
  git: (gitArgs) => runGit(io.cwd, gitArgs)
24430
25070
  }, io);
24431
25071
  }
24432
- export { unreleasedChange as $, summaryJob as $n, homePackage as $t, scriptsOf as A, addSummaryJob as An, privateTextBreaks as At, roadmapOfLine as B, runnerBudget as Bn, parsePrivateNames as Bt, setVersions as C, sharedCi as Cn, runGit as Cr, PRIVATE_NAMES_FILE_VARIABLE as Ct, trustPolicy as D, securityGate as Dn, defaultOptions as Dr, privateNamesFile as Dt, TRAIN_SCOPES as E, isSecurityGate as En, specifiersOf as Er, noLocalPaths as Et, sourceMain as F, SECURITY_SCAN_INPUTS as Fn, isCommonUse as Ft, minorOf as G, licenseFileOf as Gn, mainCheck as Gt, requiredScripts as H, LICENSE_TEXTS as Hn, noBuildOutput as Ht, HOME_TIMEOUT_MS as I, SECURITY_TIMEOUT_MINUTES as In, lineNameHit as It, reachOf as J, ACTIONS_COMMIT as Jn, homeModule as Jt, publishedMinor as K, mitText as Kn, coverageProvider as Kt, blockHash as L, securityCallers as Ln, lineNameHits as Lt, testsRequired as M, startsOnPullRequest as Mn, PrivateNameListError as Mt, isSourcePath as N, summaryJobRule as Nn, firstNameMatch as Nt, typedScripts as O, securityWorkflow as On, parseConfig as Or, privateNamesFiles as Ot, pathsOf as P, SECURITY_SCAN_COMMIT as Pn, isAllowedHit as Pt, npmLookup as Q, skippableJobs as Qn, declaredName as Qt, githubFetch as R, securityOneJob as Rn, mergePrivateNames as Rt, namedVersions as S, callsSharedCi as Sn, repositoryOfRemote as Sr, PRIVATE_NAMES_FILE_CONFIG as St, IGNORE_AFTER as T, SECURITY_FILE as Tn, showFiles as Tr, invalidPatternBreaks as Tt, releaseFiles as U, authorOf as Un, REAL_COMPARE as Ut, roadmapParses as V, scheduleMinute as Vn, pathNameHit as Vt, lockedVersions as W, licenseFile as Wn, hasImportMetaMain as Wt, SHIPPED_FIELDS as X, gateTrigger as Xn, moduleUses as Xt, NPM_REGISTRY as Y, convertGate as Yn, moduleMessage as Yt, UNSHIPPED_FILES as Z, prPathFilters as Zn, modulesOf as Zt, runPrePushArgs as _, hasTests as _n, matchesAny as _r, exportsRequire as _t, listRules as a, HOMES as an, readWorkflow as ar, startsTests as at, GITHUB_YAML as b, SHARED_CI as bn, readJsonc as br, DEFAULT_ALLOWED as bt, runCli as c, mapMarkdown as cn, cuePreset as cr, isGitSpecifier as ct, HOOK_MARKER as d, npmDrift as dn, cleanPath as dr, siteCheckInCi as dt, messageOf as en, summaryName as er, unreleasedChangeRule as et, NO_READ_LINE as f, npmNames as fn, codePackages as fr, pagesAfterRelease as ft, prePush as g, serviceRunMain as gn, lineOf as gr, pagesSite as gt, parsePrePushArgs as h, runCalls as hn, keyLine as hr, pagesCalls as ht, formatResult as i, HOME_EXPORTS as in, readAction as ir, parseAdvisory as it, typedFiles as j, hasSummaryJob as jn, PRIVATE_NAME_LIST as jt, configsOfScript as k, SUMMARY_GATES as kn, parseRuleConfig as kr, privatePatterns as kt, runFix as l, mapText as ln, DEPENDENCY_FIELDS as lr, isPinned as lt, installHook as m, SERVICE_PACKAGE as mn, inFolder as mr, PAGES_WORKFLOWS as mt, annotations as n, reposOf as nn, MATRIX_EXPAND_MAX as nr, hiddenFailures as nt, readConfig as o, MAP_RULE as on, yamlFaults as or, swallowsTests as ot, PRE_PUSH_HOOK as p, readOverlay as pn, hasFile as pr, pushMainOnly as pt, publishedMinorRule as q, repositoryIsPublic as qn, apiReportScript as qt, createContext as r, signaturesOf as rn, parseWorkflow as rr, jobFails as rt, runChecks as s, findHomes as sn, STRICT_OPTIONS as sr, pipeFails as st, USAGE as t, repoOf as tn, gateAfterCancel as tr, playwrightInstall as tt, summaryMarkdown as u, mergeHomes as un, RULE_WARN_DAYS as ur, pinnedGitDeps as ut, RULES as v, tsconfigTest as vn, parseCatFileBatch as vr, publishTextSafe as vt, versionTitle as w, setupCue as wn, runGitShow as wr, PRIVATE_PATTERNS_VARIABLE as wt, workflowParses as x, SHARED_WORKFLOWS as xn, replaceLine as xr, HOME_PATTERNS as xt, workspaceProtocol as y, SHARED_ACTIONS as yn, parseJsonc as yr, packNoBuildinfo as yt, sharedDocsRule as z, withOneJob as zn, nameMatches as zt };
25072
+ export { requiredScripts as $, LICENSE_TEXTS as $n, noBuildOutput as $t, scriptsOf as A, SHARED_ACTIONS as An, parseJsonc as Ar, packNoBuildinfo as At, TEMPLATE_CALLED as B, SUMMARY_GATES as Bn, parseRuleConfig as Br, privatePatterns as Bt, setVersions as C, npmNames as Cn, codePackages as Cr, pagesAfterRelease as Ct, trustPolicy as D, serviceRunMain as Dn, lineOf as Dr, pagesSite as Dt, TRAIN_SCOPES as E, runCalls as En, keyLine as Er, pagesCalls as Et, sourceMain as F, setupCue as Fn, runGitShow as Fr, PRIVATE_PATTERNS_VARIABLE as Ft, runnerPeak as G, SECURITY_SCAN_COMMIT as Gn, isAllowedHit as Gt, calledJobs as H, hasSummaryJob as Hn, PRIVATE_NAME_LIST as Ht, HOME_TIMEOUT_MS as I, SECURITY_FILE as In, showFiles as Ir, invalidPatternBreaks as It, evaluateExpression as J, securityCallers as Jn, lineNameHits as Jt, runsAtOnce as K, SECURITY_SCAN_INPUTS as Kn, isCommonUse as Kt, blockHash as L, isSecurityGate as Ln, specifiersOf as Lr, noLocalPaths as Lt, testsRequired as M, SHARED_WORKFLOWS as Mn, replaceLine as Mr, HOME_PATTERNS as Mt, isSourcePath as N, callsSharedCi as Nn, repositoryOfRemote as Nr, PRIVATE_NAMES_FILE_CONFIG as Nt, typedScripts as O, hasTests as On, matchesAny as Or, exportsRequire as Ot, pathsOf as P, sharedCi as Pn, runGit as Pr, PRIVATE_NAMES_FILE_VARIABLE as Pt, roadmapParses as Q, scheduleMinute as Qn, pathNameHit as Qt, githubFetch as R, securityGate as Rn, defaultOptions as Rr, privateNamesFile as Rt, namedVersions as S, npmDrift as Sn, cleanPath as Sr, siteCheckInCi as St, IGNORE_AFTER as T, SERVICE_PACKAGE as Tn, inFolder as Tr, PAGES_WORKFLOWS as Tt, eventClass as U, startsOnPullRequest as Un, PrivateNameListError as Ut, UNKNOWN_MATRIX_JOBS as V, addSummaryJob as Vn, privateTextBreaks as Vt, matrixPeak as W, summaryJobRule as Wn, firstNameMatch as Wt, mayRun as X, withOneJob as Xn, nameMatches as Xt, groupParts as Y, securityOneJob as Yn, mergePrivateNames as Yt, roadmapOfLine as Z, runnerBudget as Zn, parsePrivateNames as Zt, runPrePushArgs as _, MAP_RULE as _n, yamlFaults as _r, swallowsTests as _t, listRules as a, homeModule as an, ACTIONS_COMMIT as ar, reachOf as at, GITHUB_YAML as b, mapText as bn, DEPENDENCY_FIELDS as br, isPinned as bt, runCli as c, modulesOf as cn, prPathFilters as cr, UNSHIPPED_FILES as ct, HOOK_MARKER as d, messageOf as dn, summaryName as dr, unreleasedChangeRule as dt, REAL_COMPARE as en, authorOf as er, releaseFiles as et, NO_READ_LINE as f, repoOf as fn, gateAfterCancel as fr, playwrightInstall as ft, prePush as g, HOMES as gn, readWorkflow as gr, startsTests as gt, parsePrePushArgs as h, HOME_EXPORTS as hn, readAction as hr, parseAdvisory as ht, formatResult as i, apiReportScript as in, repositoryIsPublic as ir, publishedMinorRule as it, typedFiles as j, SHARED_CI as jn, readJsonc as jr, DEFAULT_ALLOWED as jt, configsOfScript as k, tsconfigTest as kn, parseCatFileBatch as kr, publishTextSafe as kt, runFix as l, declaredName as ln, skippableJobs as lr, npmLookup as lt, installHook as m, signaturesOf as mn, parseWorkflow as mr, jobFails as mt, annotations as n, mainCheck as nn, licenseFileOf as nr, minorOf as nt, readConfig as o, moduleMessage as on, convertGate as or, NPM_REGISTRY as ot, PRE_PUSH_HOOK as p, reposOf as pn, MATRIX_EXPAND_MAX as pr, hiddenFailures as pt, workflowPeaks as q, SECURITY_TIMEOUT_MINUTES as qn, lineNameHit as qt, createContext as r, coverageProvider as rn, mitText as rr, publishedMinor as rt, runChecks as s, moduleUses as sn, gateTrigger as sr, SHIPPED_FIELDS as st, USAGE as t, hasImportMetaMain as tn, licenseFile as tr, lockedVersions as tt, summaryMarkdown as u, homePackage as un, summaryJob as ur, unreleasedChange as ut, RULES as v, findHomes as vn, STRICT_OPTIONS as vr, pipeFails as vt, versionTitle as w, readOverlay as wn, hasFile as wr, pushMainOnly as wt, workflowParses as x, mergeHomes as xn, RULE_WARN_DAYS as xr, pinnedGitDeps as xt, workspaceProtocol as y, mapMarkdown as yn, cuePreset as yr, isGitSpecifier as yt, sharedDocsRule as z, securityWorkflow as zn, parseConfig as zr, privateNamesFiles as zt };
24433
25073
 
24434
- //# sourceMappingURL=run-BkkhkBof.js.map
25074
+ //# sourceMappingURL=run-Ck7ahUNV.js.map