Skip to content

merge-lane: feasibility replay #218

Closed

Description

@frostyard-machines

Answer

Under the merge-lane batch rules, few merged agent PRs would have been selected by default: 26 PRs in 31 days (0.8 a day), or 1.6 a day over the 16 days in which frostyard-machines merged anything. No PR was selectable with L. At 8 seconds a batch PR against 37.5 seconds today, the saving is about 0.4 minutes a day (0.8 minutes a day at the upper bound of 37.5 seconds a PR saved).

The main causes, by the first rule that fails:

  • C3 (245 of 585): a changed path matches .github/risk-paths.json or the PR has risk:high. Workflows, Makefiles, argo/workflow-templates/** and .github/risk-paths.json itself lead.
  • C1 (115): no ready-for-human label. 90 of them merged on 2026-10-22 and 2026-10-23, when the label came into use.
  • F-policy (87): AGENTS.md, .memory/** (corrections.jsonl lines), docs/adr/**, docs/design/**.
  • C4-none (75): 13 of the 26 repositories have no required_status_checks rule on the default branch today (rules read by GET /repos/{r}/rules/branches/{default}): homebrew-tap, chairlift, snosi, repogen, intuneme, snowkit, pilothouse, testsuite, lab, omarchy-apps, igloo, flatpak-index, problem-intake. If all of them had required checks, the default-selected count is 39 (1.3 a day).
  • F-build (30), F-config, F-package, F-repo-paths (7 together).

Method

  • PRs: GraphQL search repo:frostyard/<name> is:pr is:merged author:frostyard-machines, filtered to mergedAt from 2026-10-07 to 2026-11-06 (UTC, inclusive). Files: GET /pulls/{n}/files, every page, with both names of a rename.
  • frostyard-machines merged its first PR in these repositories on 2026-10-22. The 15 days before have 0 PRs, so the 31-day means are low by about half; the 16-day means are given too.
  • Rules are evaluated in the order F-repo, C1, C3, C4-none, C7, C8, C9, S3, then the floor groups. A PR is listed under its first failing rule only.
  • Size: additions + deletions above 300, or changedFiles above 15, gives L.

Approximations

  • C1: ready-for-human and risk:high as labeled now, not at merge time. The base must be today's default branch; open and draft are not checked.
  • C3: .github/risk-paths.json at the merge commit's first parent, matched by scripts/lib/risk-paths.mjs (core main at 756a96d). Most repositories added the file from 2026-11-04 to 2026-11-06, so 510 of 585 PRs had no valid file at the first parent; for them the replay uses the file at today's default branch tip.
  • C4: assumed met, except C4-none, read from today's rules.
  • C5 and S1 to S5: assumed met. A chore/sync-core-skills PR with every path under .agents/skills/<name>/ is labeled sync and is exempt from the floor (an approximation of S3).
  • C9: the file list must be complete (its count equals changedFiles, at most 3000).
  • The floor is the hard-coded list of the batch design (groups F-build, F-config, F-package, F-trust, F-privilege, F-policy, F-breaking, F-repo-paths). A pattern without / matches the basename at any depth. For nsl, site/** matches except Markdown.
  • Seconds a PR are estimates: 37.5 seconds is the middle of 30 to 45 seconds today; 8 seconds a batch PR is a guess that the batch measures later.

Command

# replay.mjs (below) beside lib/risk-paths.mjs from core main at 756a96d
GH_TOKEN=$(gh auth token) node replay.mjs --since 2026-10-07 --until 2026-11-06 --out out

Read only: GitHub REST and GraphQL reads. Run on 2026-11-07 as frostyard-machines, Node 24. replay.mjs sha256 8734ffa4debeaa57403d7e8cd4c79a2a7915499a55267043193135b7b925a7fc.

Result

Window: 2026-10-07 to 2026-11-06 (UTC, inclusive, 31 days). PRs by frostyard-machines merged in the 26 repositories: 585.

Outcome PRs A day
Default-selected 26 0.8
Selectable (L: more than 300 lines or 15 files) 0 0.0
Left out 559 18.0

Left out, by first failing rule: C3 245, C1 115, F-policy 87, C4-none 75, F-build 30, F-config 3, F-package 3, F-repo-paths 1.

C3 used the current risk-paths.json for 510 PRs (no valid file at the merge commit's first parent).

Sensitivity: if every repository had required checks (no C4-none), default-selected 39 (1.3 a day), L 0, left out 546 (C3 245, F-policy 122, C1 115, F-build 35, F-config 24, F-package 3, F-repo-paths 2).

Saving

Minutes a day over the 31 days. Today's cost is 37.5 s a PR (the middle of 30 to 45 s).

Batch cost a PR Saving a PR Default-selected Default plus L Default-selected, no C4-none
8 s 29.5 s 0.4 0.4 0.6
0 s (37.5 s saved, upper bound) 37.5 s 0.5 0.5 0.8

A day

Day (UTC) Default L Left out All
2026-10-07 0 0 0 0
2026-10-08 0 0 0 0
2026-10-09 0 0 0 0
2026-10-10 0 0 0 0
2026-10-11 0 0 0 0
2026-10-12 0 0 0 0
2026-10-13 0 0 0 0
2026-10-14 0 0 0 0
2026-10-15 0 0 0 0
2026-10-16 0 0 0 0
2026-10-17 0 0 0 0
2026-10-18 0 0 0 0
2026-10-19 0 0 0 0
2026-10-20 0 0 0 0
2026-10-21 0 0 0 0
2026-10-22 0 0 31 31
2026-10-23 1 0 61 62
2026-10-24 1 0 34 35
2026-10-25 3 0 19 22
2026-10-26 2 0 42 44
2026-10-27 1 0 23 24
2026-10-28 2 0 45 47
2026-10-29 5 0 37 42
2026-10-30 1 0 19 20
2026-10-31 0 0 10 10
2026-11-01 2 0 17 19
2026-11-02 0 0 18 18
2026-11-03 0 0 27 27
2026-11-04 1 0 40 41
2026-11-05 0 0 45 45
2026-11-06 7 0 91 98

From the first merge by frostyard-machines (2026-10-22) to 2026-11-06, 16 days: default-selected 1.6 a day, L 0.0 a day, left out 34.9 a day, all 36.6 a day.

Last 7 days (2026-10-31 to 2026-11-06): default-selected 1.4 a day, L 0.0 a day, left out 35.4 a day.

Per repository

frostyard/homebrew-tap (10 PRs; required checks: 0)

frostyard/chairlift (16 PRs; required checks: 0)

frostyard/snosi (59 PRs; required checks: 0)

  • Default-selected (0): none
  • Selectable, L (0): none
  • Left out (59): C1: #1099 #1101 #1108 #1109 #1110 #1112 #1114 #1115 #1119 #1127 #1150 #1169 #1175 #1179 #1224; C4-none: #1121 #1124 #1129 #1140 #1161 #1163 #1166 #1168 #1174 #1176 #1180 #1193 #1194 #1195 #1196 #1197 #1199 #1200 #1209 #1225 #1227 #1243 #1246 #1247 #1248; C3: #1122 #1126 #1157 #1162 #1165 #1173 #1181 #1190 #1201 #1208 #1210 #1212 #1214 #1215 #1220 #1223 #1226 #1237 #1238

frostyard/repogen (13 PRs; required checks: 0)

frostyard/updex (29 PRs; required checks: 10)

  • Default-selected (1): #494 sync
  • Selectable, L (0): none
  • Left out (28): C1: #445 #448 #449 #450 #452 #454 #456 #457 #459 #460 #461 #462 #466 #468; C3: #458 #467 #469 #472 #474 #480 #481 #482 #485 #488 #492; F-build: #473 #493; F-policy: #478

frostyard/bootc-debian (6 PRs; required checks: 1)

frostyard/intuneme (14 PRs; required checks: 0)

frostyard/std (5 PRs; required checks: 5)

frostyard/clix (2 PRs; required checks: 6)

frostyard/snowkit (4 PRs; required checks: 0)

frostyard/pilothouse (11 PRs; required checks: 0)

frostyard/frostyard-org (71 PRs; required checks: 2)

frostyard/testsuite (5 PRs; required checks: 0)

frostyard/lab (50 PRs; required checks: 0)

frostyard/firn (8 PRs; required checks: 4)

frostyard/core (53 PRs; required checks: 3)

frostyard/omarchy-apps (7 PRs; required checks: 0)

frostyard/nsl (21 PRs; required checks: 3)

frostyard/igloo (6 PRs; required checks: 0)

frostyard/flatpak-index (9 PRs; required checks: 0)

frostyard/frostmail (51 PRs; required checks: 9)

frostyard/frostnotes (45 PRs; required checks: 7)

frostyard/lodge (18 PRs; required checks: 7)

  • Default-selected (0): none
  • Selectable, L (0): none
  • Left out (18): C1: #32 #33 #34 #35; C3: #36 #37 #39 #41 #45 #46 #47 #49 #55; F-package: #38 #42; F-repo-paths: #40; F-policy: #44; F-build: #48

frostyard/porter (18 PRs; required checks: 4)

  • Default-selected (1): #24 docs
  • Selectable, L (0): none
  • Left out (17): C1: #11 #12 #13 #14 #15 #16 #17; C3: #18 #19 #21 #22 #25 #27 #28; F-policy: #20 #23 #26

frostyard/frostread (43 PRs; required checks: 7)

  • Default-selected (4): #21 docs, #28 docs, #34 docs, #47 docs
  • Selectable, L (0): none
  • Left out (39): C1: #15 #16 #17 #18; C3: #19 #20 #22 #25 #26 #27 #30 #31 #32 #35 #36 #38 #39 #40 #41 #44 #45 #49 #50 #51 #52 #54 #55 #60 #61; F-policy: #23 #24 #29 #33 #37 #42 #43 #46 #53 #62

frostyard/problem-intake (11 PRs; required checks: 0)

  • Default-selected (0): none
  • Selectable, L (0): none
  • Left out (11): C3: #1 #2 #4 #7 #13; C4-none: #3 #5 #6 #10 #11 #12
  • Of the C4-none PRs, default-selected with required checks (1): #6
replay.mjs
#!/usr/bin/env node
// merge-lane feasibility replay (read only).
// Replays the PRs by frostyard-machines merged in a UTC date window in the
// 26 policy repositories against the batch rules of the merge-lane plan.
//
// Usage: GH_TOKEN=$(gh auth token) node replay.mjs [--since 2026-10-07] [--until 2026-11-06] [--out DIR]
// Writes DIR/replay.json (every PR with its outcome) and DIR/replay.md (the report).
// Needs lib/risk-paths.mjs from frostyard/core main (scripts/lib/risk-paths.mjs).
//
// Approximations (the replay cannot see the state at the time of the batch):
// - C1: label `ready-for-human` and no `risk:high` as labeled now; open/draft not checked (all merged).
// - C3: `.github/risk-paths.json` at the merge commit's first parent; when absent or invalid there,
//   the file at the current default branch tip (counted as `c3_fallback`).
// - C4: assumed met, except `C4-none`, read from the current rules of the default branch.
// - C5, S1 to S5: assumed met. A `chore/sync-core-skills` PR whose paths all lie under
//   `.agents/skills/<name>/` is labeled `sync` and exempt from the floor (approximates S3).
// - C9: the PR's file list must be complete (count equals changedFiles, at most 3000).

import { writeFileSync, mkdirSync } from "node:fs";
import { matchGlob, matchFiles, parseStrictJson, validateRiskPaths } from "./lib/risk-paths.mjs";

const REPOS = [
  "homebrew-tap", "chairlift", "snosi", "repogen", "updex", "bootc-debian", "intuneme", "std", "clix",
  "snowkit", "pilothouse", "frostyard-org", "testsuite", "lab", "firn", "core", "omarchy-apps", "nsl",
  "igloo", "flatpak-index", "frostmail", "frostnotes", "lodge", "porter", "frostread", "problem-intake",
].map((name) => `frostyard/${name}`);
const AUTHOR = "frostyard-machines";
const SYNC_BRANCH = "chore/sync-core-skills";
const MAX_LINES = 300;
const MAX_FILES = 15;

const args = Object.fromEntries(
  process.argv.slice(2).reduce((acc, a, i, all) => (a.startsWith("--") ? [...acc, [a.slice(2), all[i + 1]]] : acc), []),
);
const SINCE = args.since ?? "2026-10-07";
const UNTIL = args.until ?? "2026-11-06";
const OUT = args.out ?? "out";
const TOKEN = process.env.GH_TOKEN;
if (!TOKEN) {
  console.error("GH_TOKEN=$(gh auth token) node replay.mjs");
  process.exit(2);
}

// ---- Floor (plan section "Never in a batch") ------------------------------
// A pattern without "/" matches the basename at any depth; with "/", from the root.
const FLOOR = {
  "F-build": ["go.mod", "go.sum", "Cargo.toml", "Cargo.lock", "package.json", "*.lock", "*-lock.*", ".npmrc",
    "requirements*.txt", "pyproject.toml", "Makefile", "Justfile", "meson.build", "meson_options.txt", "build.rs",
    "vite.config.*", "rust-toolchain*", "mise.toml", "mise.lock", ".tool-versions", "Containerfile*", "Dockerfile*",
    "*.sh", "**/scripts/**", "**/tools/**"],
  "F-config": ["*.yml", "*.yaml", "*.json", "*.toml", "*.conf", "**/.github/**"],
  "F-package": ["**/debian/**", "**/packaging/**", "*.spec", ".goreleaser*", "nfpm*", "mkosi*", "**/mkosi.*/**",
    "*.chroot", "*.finalize", "*.postinst", "*.preset", "*.desktop", "*.metainfo.xml", "**/src-tauri/capabilities/**"],
  "F-trust": ["**/trust/**", "**/keys/**", "*.pub", "*.pem", "*.asc", "*.gpg"],
  "F-privilege": ["*.service", "*.socket", "*.timer", "**/systemd/**", "*.policy", "*.rules", "sudoers*", "**/pam.d/**"],
  "F-policy": ["AGENTS.md", "CLAUDE.md", "GEMINI.md", ".cursorrules", "**/.claude/**", "**/.knowledge/**",
    "**/.memory/**", "**/.agents/**", "docs/agents/**", "docs/adr/**", "docs/specs/**", "docs/design/**",
    "docs/security/**", "docs/tenets.md", "**/policies/**", ".mill.toml", ".github/pull_request_template.md",
    "**/ISSUE_TEMPLATE/**"],
};
const TAURI = ["**/tauri.conf.json", "**/src-tauri/**"];
const REPO_PATHS = {
  snosi: ["shared/**/tree/**", "shared/download/**", "workers/**", "test/*.py", "*policy.json", "cosign.pub"],
  lab: ["argo/**", "argocd/**", "manifests/**", "site/**", "tests/test_*_lifecycle*.py",
    "tests/test_workflow_permissions.py", "tests/test_risk_paths.py"],
  "problem-intake": ["src/suppress.ts", "src/jobs.ts", "src/index.ts", "src/envelope.ts", "src/forward.ts",
    "src/sql.ts", "src/generated/**", "schema/**", "triage/**", "test/node/*privacy*"],
  testsuite: ["tests/shared/**"],
  firn: ["internal/disk/**", "internal/luks/**", "internal/secureboot/**", "internal/bootcimg/**",
    "internal/recipe/**", "internal/catalog/**", "internal/steps/**", "gui/go.mod"],
  intuneme: ["ubuntu-intune/**", "*_templ.go"],
  frostread: ["internal/workflowcheck/**", "internal/packagecheck/**", ...TAURI],
  frostmail: TAURI,
  frostnotes: TAURI,
  porter: TAURI,
  lodge: [...TAURI, "**/kit/**"],
};
// nsl: site/** is never low except Markdown under it (the plan keeps it docs-only).
const NSL_SITE = "site/**";

const toGlob = (p) => (p.includes("/") ? p : `**/${p}`);
const matchAny = (patterns, path) => patterns.find((p) => matchGlob(toGlob(p), path));

function floorMatch(repoName, paths, title) {
  if (/!:/.test(title)) return { id: "F-breaking", detail: title };
  for (const path of paths) {
    for (const [id, patterns] of Object.entries(FLOOR)) {
      const p = matchAny(patterns, path);
      if (p) return { id, detail: `${path} (${p})` };
    }
    const extra = REPO_PATHS[repoName];
    if (extra) {
      const p = matchAny(extra, path);
      if (p) return { id: "F-repo-paths", detail: `${path} (${p})` };
    }
    if (repoName === "nsl" && matchGlob(NSL_SITE, path) && !path.endsWith(".md")) {
      return { id: "F-repo-paths", detail: `${path} (${NSL_SITE})` };
    }
  }
  return null;
}

// ---- GitHub ---------------------------------------------------------------
async function gql(query, variables = {}) {
  for (let attempt = 0; ; attempt++) {
    const res = await fetch("https://api.github.com/graphql", {
      method: "POST",
      headers: { authorization: `bearer ${TOKEN}`, "content-type": "application/json" },
      body: JSON.stringify({ query, variables }),
    });
    const body = await res.json().catch(() => ({}));
    if (res.ok && !body.errors) return body.data;
    if (attempt >= 3) throw new Error(`GraphQL ${res.status}: ${JSON.stringify(body.errors ?? body).slice(0, 500)}`);
    await new Promise((r) => setTimeout(r, 2000 * (attempt + 1)));
  }
}

async function rest(path) {
  for (let attempt = 0; ; attempt++) {
    const res = await fetch(`https://api.github.com${path}`, {
      headers: { authorization: `bearer ${TOKEN}`, accept: "application/vnd.github+json" },
    });
    if (res.status === 404) return { status: 404, body: null };
    if (res.ok) return { status: res.status, body: await res.json() };
    if (attempt >= 3) throw new Error(`REST ${path}: ${res.status}`);
    await new Promise((r) => setTimeout(r, 2000 * (attempt + 1)));
  }
}

const PR_FIELDS = `
  number title body url mergedAt baseRefName headRefName isCrossRepository additions deletions changedFiles
  author { login }
  labels(first: 50) { nodes { name } }
  mergeCommit { oid parents(first: 1) { nodes { oid } } }
  files(first: 100) { totalCount pageInfo { hasNextPage } nodes { path } }
`;

async function searchPRs(repo, from, to) {
  const out = [];
  let cursor = null;
  const q = `repo:${repo} is:pr is:merged author:${AUTHOR} merged:${from}..${to}`;
  for (;;) {
    const data = await gql(
      `query($q: String!, $after: String) { search(query: $q, type: ISSUE, first: 50, after: $after) {
        issueCount pageInfo { hasNextPage endCursor } nodes { ... on PullRequest { ${PR_FIELDS} } } } }`,
      { q, after: cursor },
    );
    const s = data.search;
    if (s.issueCount > 1000) return null; // caller splits the window
    out.push(...s.nodes);
    if (!s.pageInfo.hasNextPage) return out;
    cursor = s.pageInfo.endCursor;
  }
}

function addDays(day, n) {
  const d = new Date(`${day}T00:00:00Z`);
  d.setUTCDate(d.getUTCDate() + n);
  return d.toISOString().slice(0, 10);
}

async function listPRs(repo, from, to) {
  const got = await searchPRs(repo, from, to);
  if (got) return got;
  const days = (Date.parse(to) - Date.parse(from)) / 86400000;
  if (days < 1) throw new Error(`more than 1000 PRs in 1 day in ${repo}`);
  const mid = addDays(from, Math.floor(days / 2));
  return [...(await listPRs(repo, from, mid)), ...(await listPRs(repo, addDays(mid, 1), to))];
}

// REST file list with previous_filename (renames); used for every PR so both rename names are checked.
async function prFiles(repo, number) {
  const files = [];
  for (let page = 1; page <= 30; page++) {
    const { body } = await rest(`/repos/${repo}/pulls/${number}/files?per_page=100&page=${page}`);
    files.push(...body);
    if (body.length < 100) break;
  }
  return files;
}

const riskCache = new Map();
async function riskPathsAt(repo, ref) {
  const key = `${repo}@${ref}`;
  if (riskCache.has(key)) return riskCache.get(key);
  const [owner, name] = repo.split("/");
  const data = await gql(
    `query($o: String!, $n: String!, $e: String!) { repository(owner: $o, name: $n) {
      object(expression: $e) { ... on Blob { text } } } }`,
    { o: owner, n: name, e: `${ref}:.github/risk-paths.json` },
  );
  let result = null;
  const text = data.repository?.object?.text;
  if (typeof text === "string") {
    try {
      const value = parseStrictJson(text);
      if (validateRiskPaths(value).ok) result = value;
    } catch {
      result = null;
    }
  }
  riskCache.set(key, result);
  return result;
}

async function mapLimit(items, limit, fn) {
  const results = new Array(items.length);
  let next = 0;
  await Promise.all(Array.from({ length: limit }, async () => {
    while (next < items.length) {
      const i = next++;
      results[i] = await fn(items[i], i);
    }
  }));
  return results;
}

// ---- Replay ---------------------------------------------------------------
function days(from, to) {
  const out = [];
  for (let d = from; d <= to; d = addDays(d, 1)) out.push(d);
  return out;
}

async function repoInfo(repo) {
  const { body: meta } = await rest(`/repos/${repo}`);
  const branch = meta.default_branch;
  const { body: rules } = await rest(`/repos/${repo}/rules/branches/${encodeURIComponent(branch)}?per_page=100`);
  const required = (rules ?? [])
    .filter((r) => r.type === "required_status_checks")
    .flatMap((r) => r.parameters?.required_status_checks ?? []);
  const current = await riskPathsAt(repo, branch);
  return { private: meta.private, branch, requiredChecks: required.length, currentRisk: current };
}

function evaluate(repo, info, pr, files, risk, riskSource) {
  const name = repo.split("/")[1];
  const labels = pr.labels.nodes.map((l) => l.name);
  const lines = pr.additions + pr.deletions;
  const paths = [...new Set(files.flatMap((f) => [f.filename, f.previous_filename].filter(Boolean)))];
  const base = { repo, number: pr.number, title: pr.title, url: pr.url, mergedAt: pr.mergedAt,
    day: pr.mergedAt.slice(0, 10), lines, files: pr.changedFiles, riskSource };
  const out = (rule, detail = "") => ({ ...base, outcome: "left-out", rule, detail });

  if (info.private) return out("F-repo", "private");
  if (pr.author?.login !== AUTHOR || pr.baseRefName !== info.branch || pr.isCrossRepository) {
    return out("C1", `base ${pr.baseRefName}`);
  }
  if (!labels.includes("ready-for-human")) return out("C1", "no ready-for-human label");
  if (labels.includes("risk:high")) return out("C3", "risk:high label");
  if (!risk) return out("C3", "no valid risk-paths.json");
  const hits = matchFiles(risk, files);
  if (hits.length) return out("C3", `${hits[0].path} (${hits[0].glob})`);
  if (info.requiredChecks === 0) return out("C4-none", "no required checks on the default branch today");
  const body = pr.body ?? "";
  if (body.split(/\r?\n/).some((l) => l.trim() === "merge-lane: skip")) return out("C7");
  if (pr.title.startsWith("Revert ") || body.split(/\r?\n/).some((l) => l.startsWith("This reverts commit"))) {
    return out("C8");
  }
  if (files.length !== pr.changedFiles || pr.changedFiles > 3000) {
    return out("C9", `files ${files.length} of ${pr.changedFiles}`);
  }
  const sync = pr.headRefName === SYNC_BRANCH && paths.every((p) => /^\.agents\/skills\/[^/]+\/.+/.test(p));
  if (pr.headRefName === SYNC_BRANCH && !sync) return out("S3", "a path outside .agents/skills/<name>/");
  if (!sync) {
    const f = floorMatch(name, paths, pr.title);
    if (f) return out(f.id, f.detail);
  }
  const label = sync ? "sync" : paths.every((p) => p.endsWith(".md")) ? "docs" : "code";
  const large = lines > MAX_LINES || pr.changedFiles > MAX_FILES;
  return { ...base, outcome: large ? "selectable-L" : "default", label };
}

async function main() {
  mkdirSync(OUT, { recursive: true });
  const results = [];
  const repoMeta = {};
  for (const repo of REPOS) {
    const info = await repoInfo(repo);
    repoMeta[repo] = { private: info.private, branch: info.branch, requiredChecks: info.requiredChecks,
      currentRiskPaths: Boolean(info.currentRisk) };
    // One day of margin on each side; the UTC filter below is exact.
    const prs = (await listPRs(repo, addDays(SINCE, -1), addDays(UNTIL, 1)))
      .filter((pr) => pr.mergedAt && pr.mergedAt.slice(0, 10) >= SINCE && pr.mergedAt.slice(0, 10) <= UNTIL);
    const rows = await mapLimit(prs, 6, async (pr) => {
      const files = await prFiles(repo, pr.number);
      const parent = pr.mergeCommit?.parents?.nodes?.[0]?.oid;
      let risk = parent ? await riskPathsAt(repo, parent) : null;
      let riskSource = "first-parent";
      if (!risk) {
        risk = info.currentRisk;
        riskSource = risk ? "c3_fallback" : "none";
      }
      const row = evaluate(repo, info, pr, files, risk, riskSource);
      // Sensitivity: the same PR if the repository had required checks (C4-none met).
      const alt = evaluate(repo, { ...info, requiredChecks: 1 }, pr, files, risk, riskSource);
      return { ...row, ifChecks: alt.outcome === "left-out" ? alt.rule : alt.outcome };
    });
    results.push(...rows);
    console.error(`${repo}: ${rows.length} PRs`);
  }
  writeFileSync(`${OUT}/replay.json`, JSON.stringify({ since: SINCE, until: UNTIL, repos: repoMeta, results }, null, 1));
  writeFileSync(`${OUT}/replay.md`, report(results, repoMeta));
}

// ---- Report ---------------------------------------------------------------
function report(results, repoMeta) {
  const allDays = days(SINCE, UNTIL);
  const n = allDays.length;
  const count = (pred) => results.filter(pred).length;
  const def = count((r) => r.outcome === "default");
  const sel = count((r) => r.outcome === "selectable-L");
  const left = count((r) => r.outcome === "left-out");
  const perDay = (x) => (x / n).toFixed(1);
  const min = (prs, s) => ((prs * s) / 60 / n).toFixed(1);
  const L = [];
  L.push(`Window: ${SINCE} to ${UNTIL} (UTC, inclusive, ${n} days). PRs by \`${AUTHOR}\` merged in the 26 repositories: ${results.length}.`);
  L.push("");
  L.push("| Outcome | PRs | A day |");
  L.push("| --- | ---: | ---: |");
  L.push(`| Default-selected | ${def} | ${perDay(def)} |`);
  L.push(`| Selectable (L: more than ${MAX_LINES} lines or ${MAX_FILES} files) | ${sel} | ${perDay(sel)} |`);
  L.push(`| Left out | ${left} | ${perDay(left)} |`);
  L.push("");
  const byRule = {};
  for (const r of results.filter((x) => x.outcome === "left-out")) byRule[r.rule] = (byRule[r.rule] ?? 0) + 1;
  L.push("Left out, by first failing rule: " + Object.entries(byRule).sort((a, b) => b[1] - a[1]).map(([k, v]) => `${k} ${v}`).join(", ") + ".");
  const fb = count((r) => r.riskSource === "c3_fallback");
  L.push("");
  L.push(`C3 used the current risk-paths.json for ${fb} PRs (no valid file at the merge commit's first parent).`);
  L.push("");
  const alt = (o) => results.filter((r) => r.ifChecks === o).length;
  const altLeft = {};
  for (const r of results.filter((x) => !["default", "selectable-L"].includes(x.ifChecks))) altLeft[r.ifChecks] = (altLeft[r.ifChecks] ?? 0) + 1;
  L.push(`Sensitivity: if every repository had required checks (no \`C4-none\`), default-selected ${alt("default")} (${perDay(alt("default"))} a day), L ${alt("selectable-L")}, left out ${results.length - alt("default") - alt("selectable-L")} (` + Object.entries(altLeft).sort((a, b) => b[1] - a[1]).map(([k, v]) => `${k} ${v}`).join(", ") + ").");
  L.push("");
  L.push("### Saving");
  L.push("");
  L.push("Minutes a day over the 31 days. Today's cost is 37.5 s a PR (the middle of 30 to 45 s).");
  L.push("");
  L.push("| Batch cost a PR | Saving a PR | Default-selected | Default plus L | Default-selected, no C4-none |");
  L.push("| --- | ---: | ---: | ---: | ---: |");
  for (const [label, s] of [["8 s", 29.5], ["0 s (37.5 s saved, upper bound)", 37.5]]) {
    L.push(`| ${label} | ${s} s | ${min(def, s)} | ${min(def + sel, s)} | ${min(alt("default"), s)} |`);
  }
  L.push("");
  L.push("### A day");
  L.push("");
  L.push("| Day (UTC) | Default | L | Left out | All |");
  L.push("| --- | ---: | ---: | ---: | ---: |");
  for (const d of allDays) {
    const rs = results.filter((r) => r.day === d);
    const c = (o) => rs.filter((r) => r.outcome === o).length;
    L.push(`| ${d} | ${c("default")} | ${c("selectable-L")} | ${c("left-out")} | ${rs.length} |`);
  }
  const first = results.map((r) => r.day).sort()[0];
  if (first) {
    const active = allDays.filter((d) => d >= first);
    const ra = results.filter((r) => r.day >= first);
    const k = active.length;
    const c = (o) => ra.filter((r) => r.outcome === o).length;
    L.push("");
    L.push(`From the first merge by \`${AUTHOR}\` (${first}) to ${UNTIL}, ${k} days: default-selected ${(c("default") / k).toFixed(1)} a day, L ${(c("selectable-L") / k).toFixed(1)} a day, left out ${(c("left-out") / k).toFixed(1)} a day, all ${(ra.length / k).toFixed(1)} a day.`);
  }
  const lastWeek = allDays.slice(-7);
  const lw = results.filter((r) => lastWeek.includes(r.day));
  L.push("");
  L.push(`Last 7 days (${lastWeek[0]} to ${lastWeek.at(-1)}): default-selected ${(lw.filter((r) => r.outcome === "default").length / 7).toFixed(1)} a day, L ${(lw.filter((r) => r.outcome === "selectable-L").length / 7).toFixed(1)} a day, left out ${(lw.filter((r) => r.outcome === "left-out").length / 7).toFixed(1)} a day.`);
  L.push("");
  L.push("### Per repository");
  for (const repo of REPOS) {
    const rs = results.filter((r) => r.repo === repo).sort((a, b) => a.number - b.number);
    const m = repoMeta[repo];
    L.push("");
    L.push(`#### ${repo} (${rs.length} PRs; required checks: ${m.requiredChecks})`);
    if (!rs.length) continue;
    const fmt = (r) => `#${r.number}`;
    const d = rs.filter((r) => r.outcome === "default");
    const s = rs.filter((r) => r.outcome === "selectable-L");
    const lo = rs.filter((r) => r.outcome === "left-out");
    L.push("");
    L.push(`- Default-selected (${d.length}): ${d.map((r) => `${fmt(r)} ${r.label}`).join(", ") || "none"}`);
    const would = rs.filter((r) => r.outcome === "left-out" && r.rule === "C4-none" && r.ifChecks === "default");
    L.push(`- Selectable, L (${s.length}): ${s.map((r) => `${fmt(r)} ${r.label}`).join(", ") || "none"}`);
    const groups = {};
    for (const r of lo) (groups[r.rule] ??= []).push(fmt(r));
    L.push(`- Left out (${lo.length}): ${Object.entries(groups).map(([k, v]) => `${k}: ${v.join(" ")}`).join("; ") || "none"}`);
    if (would.length) L.push(`- Of the \`C4-none\` PRs, default-selected with required checks (${would.length}): ${would.map(fmt).join(" ")}`);
  }
  return L.join("\n") + "\n";
}

await main();

Activity

  1. frostyard-machines commented on Nov 7, 2026

    @frostyard-machines
    ContributorAuthor

    Outcome

    Plan T1072 stops before its build step. The batch merge is not built.

    • Numbers (this replay): of 585 PRs by frostyard-machines merged in the 26 repositories from 2026-10-07 to 2026-11-06, the batch rules select 26. That is 0.8 a day over 31 days, or 1.6 a day over the 16 days with agent merges. At 8 seconds a batch PR against 37.5 seconds today, the saving is about 0.4 minutes a day.
    • Reason to stop: the saving does not pay for the build or its upkeep. Most agent PRs touch paths that the repositories list as risky (C3: 245 PRs, 42%), and a safe rule leaves those to the owner.
    • Ceiling if the rules were loosened: with every rule dropped except C3 (risk paths and risk:high), 340 PRs pass. That is about 11 to 12 a day over 31 days (21 a day over the 16 active days), about 5 to 10 minutes a day at 29.5 seconds saved a PR.

    Side finding for the repository owners: 13 of the 26 repositories have no required_status_checks rule on the default branch (listed above under C4-none).

    The replay answered its question, so this issue closes as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions