473473 * H by DIFF (C2) — an added or changed `permissions:`; a `secrets` or
474474 * job-token line (`github.token` in any case, any `github[…]` index,
475475 * `toJSON(github)`) added, changed or moved;
476- * `pull_request_target`; a `uses:` (or image) not already used at the
477- * base; a deleted job, a changed literal check-run name or a changed
476+ * `pull_request_target`; a `uses:` (or image) no workflow uses at the
477+ * base (`.github/actions/**` vouches for nothing: no register row
478+ * governs it); a deleted job, a changed literal check-run name or a changed
478479 * `needs:`; a new `continue-on-error`; an `if:` the base does not hold for
479480 * the same owner with the same text, unless its job is new on the head.
480481 * S otherwise — a contract-review PASS on the current head, every check
495496 *
496497 * Known limit, S by the ruling: the TEXT of a `run:` or `shell:` edit is not
497498 * judged beyond a dropped gate token or an added risky pattern, so
498- * `echo "pnpm check:x"`, `|| :` or `shell: bash {0}` read S. The contract
499+ * `echo "pnpm check:x"`, `|| :` or `shell: bash {0}` read S. A gate token is
500+ * one `WORKFLOW_INVOCATIONS` spelling: `check:*`, a `scripts/` path, vitest,
501+ * eslint, tsc, playwright, lychee, `turbo run X`, `pnpm X`, `git diff
502+ * --exit-code` / `--quiet` with its arguments, `npx X`, or `node` / `bash` /
503+ * `sh` on a file path. A gate spelled any other way (`python3 -c`,
504+ * `/bin/bash x.sh`, an inline `test` / `[`, a bin `pnpm exec` names) is not
505+ * tracked per job, so moving it out of its job reads S. The contract
499506 * review of record is the control there.
500507 *
501508 * `readWorkflowDiff` is the one reader; the queue guard calls it per queued
@@ -1085,7 +1092,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
10851092 '⭐ the argv is CLOSED: a flag the mode does not read, or a second repository beside a bare --pr, is refused': 22,
10861093 'the per-row repository scope (ruled B2, 2026-10-13)': 20,
10871094 'the nested `ui/` workspace rows, on the register (#25712)': 16,
1088- '⭐ the workflows split: Tier H by path or by C2 trigger, else Tier S (ruling record 6722205630)': 66 ,
1095+ '⭐ the workflows split: Tier H by path or by C2 trigger, else Tier S (ruling record 6722205630)': 75 ,
10891096});
10901097
10911098// DELETING an entry silences that battery's floor exactly as effectively as
@@ -1633,13 +1640,20 @@ export const WORKFLOW_TIER_H_FILES = Object.freeze([
16331640const WORKFLOW_RISKY_LINE = /\|\|\s*true\b|\bset\s+\+e\b|\bexit\s+0\b|\bOS_(?:SKIP|DISABLE|ALLOW)_[A-Z0-9_]+/;
16341641/** `secrets`, or the job's token: `github.token` in any case, any `github[…]` index, or `toJSON(github)` whole. */
16351642const WORKFLOW_CREDENTIAL = /\bsecrets\b|\bgithub\s*(?:\.\s*token\b|\[)|\btojson\s*\(\s*github\s*\)/i;
1636- /** The gate invocations a run block carries, each as a token; one dropped from a file is Tier H (biased: a removed check). */
1643+ /**
1644+ * The gate invocations a run block carries, each as a token; one dropped from a file is Tier H (biased: a removed check).
1645+ * `git diff --exit-code` / `--quiet` keeps its arguments (a narrowed pathspec is a narrowed gate); `npx` drops the
1646+ * package's `@version` (a bump is not a lost gate); `node` / `bash` / `sh` take the first file path after them.
1647+ */
16371648const WORKFLOW_INVOCATIONS = Object.freeze([
16381649 [/check:[A-Za-z0-9:._-]+/g, (m) => m[0]],
16391650 [/scripts\/[A-Za-z0-9._/-]+\.(?:mjs|cjs|js|mts|ts|sh|py)/g, (m) => m[0]],
16401651 [/\b(vitest|eslint|tsc|playwright|lychee)\b/g, (m) => m[1]],
16411652 [/\bturbo\s+run\s+([A-Za-z0-9:._-]+)/g, (m) => `turbo run ${m[1]}`],
16421653 [/\bpnpm(?:\s+--?[A-Za-z][\w-]*(?:[= ](?!-)\S+)?)*\s+(?:run\s+)?([A-Za-z][\w:.-]*)/g, (m) => `pnpm ${m[1]}`],
1654+ [/\bgit\s+diff\b(?=[^;&|)\n]*\s--(?:exit-code|quiet)\b)[^;&|)\n]*/g, (m) => m[0].replace(/\s+/g, ' ').trim()],
1655+ [/\bnpx(?:\s+--?[A-Za-z][\w-]*(?:=\S+)?)*\s+["']?(@?[A-Za-z0-9][\w.-]*(?:\/[\w.-]+)?)/g, (m) => `npx ${m[1]}`],
1656+ [/(?<![\w./-])(node|bash|sh)\s[^;&|\n]*?["']?(?:\.\/)?((?:[\w.@-]+\/)*[\w@-][\w.@-]*\.(?:mjs|cjs|js|mts|ts|sh|py))\b/g, (m) => `${m[1]} ${m[2]}`],
16431657]);
16441658
16451659const unquote = (value) => {
@@ -1930,8 +1944,9 @@ export function workflowFacts(text) {
19301944}
19311945
19321946/**
1933- * What a base tree already uses and names, across every workflow and local
1934- * action: the `uses:` / image identities a head may use without Tier H, and
1947+ * What a base tree already uses and names, across every workflow (the files
1948+ * `readWorkflowDiff` hands in, never `.github/actions/**`, which is no register
1949+ * row): the `uses:` / image identities a head may use without Tier H, and
19351950 * the job names a NEW job may not take (two jobs, one check-run name). An
19361951 * unparseable file still contributes its `uses:` lines, read by pattern.
19371952 */
@@ -2071,7 +2086,8 @@ export function readWorkflowDiff({ paths, base, head, inventoryBase = base, git,
20712086 const show = (rev, path) => git(['show', `${rev}:${path}`]);
20722087 let inventory = cache?.get(inventoryBase) ?? null;
20732088 if (inventory === null) {
2074- const files = listAt(inventoryBase, '.github/workflows', '.github/actions').filter((p) => /\.ya?ml$/.test(p));
2089+ // Workflows only: `.github/actions/**` is no register row, so an action used there alone vouches for nothing.
2090+ const files = listAt(inventoryBase, WORKFLOWS_PREFIX).filter((p) => /\.ya?ml$/.test(p));
20752091 inventory = workflowInventory(files.map((p) => ({ path: p, text: show(inventoryBase, p) })));
20762092 cache?.set(inventoryBase, inventory);
20772093 }
@@ -5284,6 +5300,24 @@ async function selfTest() {
52845300 }
52855301 const addedNeeds = tierOf(edit(' needs: [build]', ' needs: [build, opt-in]'));
52865302 assert('⛔ S1-a-needs-added-on-an-existing-job-is-H', isH(addedNeeds, /`needs:` changed: `shards` \[build\] → \[build, opt-in\]/), show(addedNeeds));
5303+ // The review nits N5: gate spellings WORKFLOW_INVOCATIONS did not see — each moved out of its job is H.
5304+ const GATE_LINE = ' node scripts/check-required-contexts.mjs\n';
5305+ for (const [spelling, token] of [
5306+ ['git diff --exit-code -- packages/spec/json-schema', 'git diff --exit-code -- packages/spec/json-schema'],
5307+ ['if ! git diff --quiet -- sdui.manifest.json; then exit 1; fi', 'git diff --quiet -- sdui.manifest.json'],
5308+ ['npx --yes publint@0.3.2 --strict', 'npx publint'],
5309+ ['npx -y "@arethetypeswrong/cli@0.17.0" --pack .', 'npx @arethetypeswrong/cli'],
5310+ ['node ui/e2e/check-gate.mjs --strict', 'node ui/e2e/check-gate.mjs'],
5311+ ['bash ./tools/verify.sh "$RUNNER_TEMP"', 'bash tools/verify.sh'],
5312+ ]) {
5313+ const base = edit(GATE_LINE, `${GATE_LINE} ${spelling}\n`);
5314+ const moved = tierOf(`${base.replace(` ${spelling}\n`, '')} gate2:\n if: false\n runs-on: ubuntu-latest\n steps:\n - run: ${spelling}\n`, { base });
5315+ const re = new RegExp(`an existing job no longer holds \`${token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\`: \`build\``);
5316+ assert(`⛔ N5-a-gate-spelled-${token}-moved-out-of-its-job-is-H`, isH(moved, re), show(moved));
5317+ }
5318+ const npxBase = edit(GATE_LINE, `${GATE_LINE} npx --yes publint@0.3.2 --strict\n node ./tools/gate.mjs\n`);
5319+ const npxBumped = tierOf(npxBase.replace('publint@0.3.2', 'publint@0.3.3').replace('node ./tools/gate.mjs', 'node tools/gate.mjs'), { base: npxBase });
5320+ assert('N5-near-miss-an-npx-version-bump-and-a-dropped-dot-slash-are-S', isS(npxBumped), show(npxBumped));
52875321
52885322 // The near-misses: each is Tier S.
52895323 const BUILD_RUN = ' run: pnpm turbo run build --filter=@objectstack/spec';
@@ -5313,7 +5347,8 @@ async function selfTest() {
53135347 assert('closed-a-new-a-deleted-and-a-non-yaml-file-are-H', isH(tierOf(BASE_WF, { base: null }), /new workflow file/) && isH(tierOf(null), /deleted workflow file/) && isH(tierOf('x', { path: `${WORKFLOWS_PREFIX}notes.md` }), /not a `.yml`/));
53145348 assert('closed-no-inventory-is-H', isH(tierOf(edit('timeout-minutes: 20', 'timeout-minutes: 30'), { inventory: null }), /no inventory/));
53155349 const fakeGit = (tree) => (argv) => {
5316- if (argv[0] === 'ls-tree') return Object.keys(tree[argv[3]] ?? (() => { throw new Error(`unknown revision ${argv[3]}`); })()).join('\n');
5350+ // ls-tree honours its pathspecs (argv after `--`), as git does: the inventory's directory list is under test.
5351+ if (argv[0] === 'ls-tree') return Object.keys(tree[argv[3]] ?? (() => { throw new Error(`unknown revision ${argv[3]}`); })()).filter((p) => argv.slice(5).some((d) => p.startsWith(d.endsWith('/') ? d : `${d}/`))).join('\n');
53175352 const [rev, path] = argv[1].split(':');
53185353 if (tree[rev]?.[path] === undefined) throw new Error(`fatal: path '${path}' does not exist in '${rev}'`);
53195354 return tree[rev][path];
@@ -5322,6 +5357,15 @@ async function selfTest() {
53225357 const readS = readWorkflowDiff({ paths: [WF, 'README.md'], base: 'b', head: 'h', git: fakeGit(TREES) });
53235358 const readH = readWorkflowDiff({ paths: [WF], base: 'b', head: 'x', git: fakeGit(TREES) });
53245359 assert('readWorkflowDiff-classifies-only-the-workflow-paths-it-read', readS.measured === true && readS.files.length === 1 && readS.files[0].tier === GOVERNED_TIER_S && readH.files[0].tier === GOVERNED_TIER_H, JSON.stringify(readS));
5360+ // The review nit N3: an action used only under `.github/actions/**` (no register row) vouches for nothing.
5361+ const ACTION = '.github/actions/setup/action.yml';
5362+ const ACTION_TEXT = "name: setup\nruns:\n using: composite\n steps:\n - uses: someone/composite-only@v1\n";
5363+ const ADOPT = (u) => edit(' - uses: actions/checkout@v7\n', ` - uses: actions/checkout@v7\n - uses: ${u}\n`);
5364+ const ADOPTING = { b: { [WF]: BASE_WF, [ACTION]: ACTION_TEXT }, n: { [WF]: ADOPT('someone/composite-only@v1'), [ACTION]: ACTION_TEXT }, c: { [WF]: ADOPT('actions/cache@v4'), [ACTION]: ACTION_TEXT } };
5365+ const adopted = readWorkflowDiff({ paths: [WF], base: 'b', head: 'n', git: fakeGit(ADOPTING) });
5366+ assert('⛔ N3-a-workflow-adopting-an-action-used-only-under-github-actions-on-the-base-is-H', adopted.measured === true && isH(adopted.files[0], /not used anywhere on the base tree: `someone\/composite-only`/), JSON.stringify(adopted.files));
5367+ const reused = readWorkflowDiff({ paths: [WF], base: 'b', head: 'c', git: fakeGit(ADOPTING) });
5368+ assert('N3-control-an-action-a-base-workflow-already-uses-is-S', reused.measured === true && isS(reused.files[0]), JSON.stringify(reused.files));
53255369 const noBase = readWorkflowDiff({ paths: [WF], base: null, head: 'h', git: fakeGit(TREES) });
53265370 const badRev = readWorkflowDiff({ paths: [WF], base: 'gone', head: 'h', git: fakeGit(TREES) });
53275371 assert('closed-a-missing-base-or-a-git-failure-is-UNMEASURED', noBase.measured === false && /no base commit/.test(noBase.reason) && badRev.measured === false && /unknown revision gone/.test(badRev.reason), JSON.stringify([noBase.reason, badRev.reason]));
0 commit comments