From 7351aa8334b2c393df007ea41ee12d936c6c95e3 Mon Sep 17 00:00:00 2001 From: deathpie <10750179+deathpie@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:21:06 -0500 Subject: [PATCH] fix: read the audited owner's standard in the fleet audit ## What C5.7 read `standards/owner.md` from the local checkout, so a full-fleet run from one clone applied that clone's owner standard to every owner. It now fetches `standards/owner.md` from the audited owner's `.github` repository, once per owner and cached, so each owner's `## CI-only required checks` section is honoured when `just fleet-audit` runs from a single clone. The script stays read-only and no other behaviour changes. The file stays byte-identical across the five owner `.github` repositories. ## Verification - `just check` - `just fleet-audit --owner simpsonm09-projects` - `just fleet-audit --owner deathpie` --- scripts/fleet-audit.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/fleet-audit.ts b/scripts/fleet-audit.ts index 88e2210..2e2a299 100644 --- a/scripts/fleet-audit.ts +++ b/scripts/fleet-audit.ts @@ -16,7 +16,6 @@ // gh runs from the temp directory so the per-owner gh wrapper picks the token // from the target owner instead of refusing a cross-account call. This script // only issues GET requests and never prints a token or a secret value. -import { readFileSync } from "node:fs"; import { tmpdir } from "node:os"; // Keep this list, and its order, identical to `owners` in scripts/core-drift.ts. @@ -176,15 +175,17 @@ function ciOnlyChecks(ownerStandard: string | null): Set { return names; } -// The owner standard is this repository's `standards/owner.md`: the audit runs -// from one owner's `.github` repository, so the file beside the script is the -// policy for every repository it audits. -function ownerStandard(): string | null { - try { - return readFileSync(new URL("../standards/owner.md", import.meta.url), "utf8"); - } catch { - return null; +// The owner standard is that owner's `.github` repository's +// `standards/owner.md`, fetched once per owner: a full-fleet run from one clone +// applies each owner's own policy, not the local one. +const ownerStandards = new Map(); + +function ownerStandard(owner: Owner): string | null { + if (!ownerStandards.has(owner)) { + const branch = api(`repos/${owner}/.github`)?.default_branch ?? "main"; + ownerStandards.set(owner, raw(`${owner}/.github`, "standards/owner.md", branch)); } + return ownerStandards.get(owner) ?? null; } // A workflow triggers on pull requests when its `on:` block names @@ -445,7 +446,7 @@ function audit(owner: Owner, listed: any, timing: boolean): Report { // C5.7: the required pull-request checks are the hook recipes, unless the // owner standard names them under `## CI-only required checks`. - const ciOnly = ciOnlyChecks(ownerStandard()); + const ciOnly = ciOnlyChecks(ownerStandard(owner)); for (const context of requiredContexts(full, pub, workflows, read)) { const name = context.trim().toLowerCase(); if (isHookRecipe(context) || ciOnly.has(name) || ciOnly.has(jobPart(name))) continue;