Merge the refreshed diff scope count base

This commit is contained in:
Michael D'Angelo
2026-10-25 06:38:34 +00:00
16 changed files with 181 additions and 59 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
paths:
.github/workflows/{container-release,node-github-release,node-release-cut,node-release,release-progress}.yml:
.github/workflows/{container-release,node-github-release,node-release-cut,node-release-pr,node-release,release-progress}.yml:
ignore:
# actionlint 1.7.12 predates GitHub's queue: max support. Keep release queuing.
# https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/control-workflow-concurrency
@@ -4,7 +4,7 @@ runs:
using: composite
steps:
- name: Set up Action Node.js runtime
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "24"
package-manager-cache: false
+1 -1
View File
@@ -3,7 +3,7 @@ description: Prepare the verified universal native payload for package builds.
runs:
using: composite
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: native-universal-${{ github.sha }}
path: plugins/codex-security/native/prebuilt
+1 -1
View File
@@ -20,7 +20,7 @@ runs:
package_json_file: package.json
# setup-node saves its cache only after a successful job.
- name: Set up Node.js and pnpm cache
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: ${{ inputs.setup-node == 'true' && '22.13.0' || '' }}
architecture: ${{ inputs.architecture }}
+3 -1
View File
@@ -55,7 +55,9 @@ updates:
- package-ecosystem: github-actions
labels: [dependencies]
directory: /
directories:
- /
- "/.github/actions/*"
schedule:
interval: cron
cronjob: "0 9 * * *"
+1 -7
View File
@@ -343,16 +343,10 @@ jobs:
matrix: ${{ fromJSON(needs.classify-changes.outputs.python-matrix) }}
steps:
- *checkout-repository
- name: Set up Node.js
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22.13.0"
- name: Set up pnpm
- name: Set up TypeScript tools
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.12'
uses: ./.github/actions/setup-tools
with:
setup-node: false
compile: true
cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
+14 -4
View File
@@ -10,12 +10,22 @@ on:
permissions:
contents: read
concurrency:
group: node-release-cut
queue: max
jobs:
progress:
if: >-
github.repository == 'openai/codex-security' &&
github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'push'
uses: ./.github/workflows/release-progress.yml
permissions:
actions: write
contents: read
pull-requests: write
cut:
concurrency:
group: node-release-cut
queue: max
if: >-
github.repository == 'openai/codex-security' &&
(github.event_name == 'workflow_dispatch' ||
+7 -1
View File
@@ -15,7 +15,8 @@ permissions:
pull-requests: read
concurrency:
group: node-release-pr
# A newer push can replace a pending push without displacing a manual run.
group: node-release-pr-${{ github.event_name == 'push' && 'push' || github.run_id }}
cancel-in-progress: false
jobs:
@@ -26,6 +27,10 @@ jobs:
(github.event_name != 'workflow_dispatch' && vars.RELEASE_PR_ENABLED != 'true'))
name: preview release PR
runs-on: ubuntu-latest
# Keep the writer from changing the release branch while a preview reads it.
concurrency: &release-pr-queue
group: node-release-pr
queue: max
env:
RELEASE_PR_DRY_RUN: "true"
@@ -56,6 +61,7 @@ jobs:
(github.event_name != 'workflow_dispatch' && vars.RELEASE_PR_ENABLED == 'true'))
name: maintain release PR
runs-on: ubuntu-latest
concurrency: *release-pr-queue
permissions:
contents: write
pull-requests: write
+5 -11
View File
@@ -1,8 +1,9 @@
name: release-progress
on:
workflow_call:
workflow_run:
workflows: ["node-ci", "node-release", "node-github-release"]
workflows: ["node-release", "node-github-release"]
types: [in_progress, completed]
workflow_dispatch:
inputs:
@@ -20,19 +21,14 @@ permissions: {}
concurrency:
# Refreshes read the latest upstream state, so only one pending refresh is needed.
# Observers must not hold that slot while their upstream run awaits approval.
group: release-progress-${{ inputs.run-id || github.event.workflow_run.id }}-${{ (inputs.watch || (github.event.action == 'in_progress' && github.event.workflow_run.name != 'node-ci')) && github.run_id || 'refresh' }}
group: release-progress-${{ inputs.run-id || github.event.workflow_run.id }}-${{ (inputs.watch || github.event.action == 'in_progress') && github.run_id || 'refresh' }}
cancel-in-progress: false
jobs:
identify:
if: >-
github.repository == 'openai/codex-security' &&
(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main') &&
(github.event_name != 'workflow_run' ||
github.event.workflow_run.name != 'node-ci' ||
(github.event.action == 'completed' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'))
(github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main')
name: identify release
runs-on: ubuntu-latest
continue-on-error: true
@@ -116,9 +112,7 @@ jobs:
if: >-
needs.report.outputs.pull != '' &&
((github.event_name == 'workflow_dispatch' && inputs.watch) ||
(github.event_name == 'workflow_run' &&
github.event.action == 'in_progress' &&
github.event.workflow_run.name != 'node-ci'))
(github.event_name == 'workflow_run' && github.event.action == 'in_progress'))
name: observe release milestones
runs-on: ubuntu-latest
continue-on-error: true
+6 -11
View File
@@ -101,14 +101,9 @@ jobs:
python-version: "3.12"
- name: Prepare native runtime
uses: ./.github/actions/download-native
- &actions-setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22.13.0"
- name: Set up pnpm
- name: Set up TypeScript tools
uses: ./.github/actions/setup-tools
with:
setup-node: false
cache-dependency-path: |
sdk/typescript/pnpm-lock.yaml
plugins/codex-security/mcp-app/pnpm-lock.yaml
@@ -181,11 +176,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- *actions-checkout
- *actions-setup-node
- &github-actions-setup-tools
- name: Set up TypeScript tools
uses: ./.github/actions/setup-tools
with:
setup-node: false
- name: Install dependencies
run: pnpm --dir sdk/typescript install --frozen-lockfile
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
@@ -230,7 +222,10 @@ jobs:
with:
# Stryker 10's Babel 8 requires Node 22.18+ or 24.11+.
node-version: "24.15.0"
- *github-actions-setup-tools
- name: Set up pnpm
uses: ./.github/actions/setup-tools
with:
setup-node: false
- *set-up-bun
- name: Install dependencies
run: pnpm --dir sdk/typescript install --frozen-lockfile
+6 -3
View File
@@ -92,6 +92,8 @@ Review this policy before enabling automation for `1.x`.
## Rolling release PRs
`node-release-pr` runs after pushes to `main` and can be dispatched manually.
Newer pushes can replace pending pushes. Manual runs keep their own place.
Previews and writes share one queue so a preview sees a consistent proposal.
It defaults to a read-only preview. It does not merge, tag, publish, or change
the existing publication gates.
@@ -320,8 +322,9 @@ do not prepare a release by editing or committing files there.
The merged release PR receives one progress comment covering post-merge CI,
release verification, protected npm approval, public-package provenance,
installation checks, Action publication, and container approval and publication.
It links to the relevant workflow
runs and updates at workflow boundaries. Each automatic release dispatch starts
The main CI completion handler requests the first update for a merged release
PR, including when CI fails. Subsequent updates link to the relevant workflows
and track each publication stage. Each automatic release dispatch starts
a separate observer using the returned run ID; this does not depend on chained
`workflow_run` events from the built-in token. The observer checks release jobs
every 30 seconds, including while protected approval is pending, and requests a refresh
@@ -336,7 +339,7 @@ and `watch` enabled. GitHub publication starts its own observer after npm succee
The observer and comment writer execute only helpers from protected `main`.
Only the comment writer can update PR comments, and only the observer can request
a refresh. Both run outside the publication workflows. Verification and
a refresh. Reporting runs independently of the tag-cut job. Verification and
publication jobs retain their existing permissions. The dispatch jobs use their
existing Actions permission for a best-effort notification bounded to 15 seconds,
within the downstream resolver's 60-second completion wait. Progress-reporting
+22 -11
View File
@@ -9426,11 +9426,7 @@ async function executeScan(
`Reviews: ${deepProgress.completed} completed, ${deepProgress.active} active, cap ${deepProgress.maximum}`,
);
} else if (fileProgress !== null) {
const count = scanProgressCount(fileProgress);
if (count.total > 0)
details.push(
`${count.label === "reviews" ? "Reviews" : "Files"}: ${count.completed.toLocaleString("en-US")}/${count.total.toLocaleString("en-US")}`,
);
details.push(formatScanProgressCount(fileProgress, "status"));
}
const tokens =
runningCost !== null
@@ -9701,10 +9697,8 @@ async function executeScan(
}
if (progress === null) return;
progress.stopTimer();
const count = scanProgressCount(update);
progress.stage(
`Scan phase: ${phase}${count.total === 0 ? "" : ` (${count.completed.toLocaleString("en-US")}/${count.total.toLocaleString("en-US")} ${count.label})`}.`,
);
const count = formatScanProgressCount(update, "phase");
progress.stage(`Scan phase: ${phase} (${count}).`);
progress.startTimer(runningMessage());
},
onDeepProgress: (update) => {
@@ -10703,6 +10697,23 @@ function printScanSummary(
}
}
function formatScanProgressCount(
progress: ScanProgress,
style: "phase" | "status",
): string {
const { label, completed, total } = scanProgressCount(progress);
const totalText = total.toLocaleString("en-US");
if (label === "files" && completed === 0) {
return style === "phase"
? `${totalText} ${total === 1 ? "file" : "files"} inventoried`
: `File inventory: ${totalText}`;
}
const ratio = `${completed.toLocaleString("en-US")}/${totalText}`;
return style === "phase"
? `${ratio} ${label}`
: `${label === "reviews" ? "Reviews" : "Files"}: ${ratio}`;
}
function componentScanEventLine(
componentName: string,
event: ComponentScanEvent,
@@ -10716,8 +10727,8 @@ function componentScanEventLine(
}
if (event.type === "progress") {
const progress = event.value;
const count = scanProgressCount(progress);
return `codex-security: ${componentName} ${scanPhase(progress.phase)} | ${count.label === "reviews" ? "Reviews" : "Files"}: ${count.completed.toLocaleString("en-US")}/${count.total.toLocaleString("en-US")}\n`;
const count = formatScanProgressCount(progress, "status");
return `codex-security: ${componentName} ${scanPhase(progress.phase)} | ${count}\n`;
}
if (event.type === "usage") {
const tokens = formatTokenUsage(event.value);
+16 -5
View File
@@ -2511,6 +2511,7 @@ describe("CLI", () => {
expect(JSON.parse(stdout.text())).toEqual(fakeResult().toJSON());
expect(stderr.text()).toContain("Preparing scan");
expect(stderr.text()).toContain("Running scan");
expect(stderr.text()).not.toContain("File inventory:");
expect(stderr.text()).not.toContain("\u001B");
expect(stderr.text()).not.toContain("\r");
expect(setIntervalMock).toHaveBeenCalledTimes(0);
@@ -2561,7 +2562,7 @@ describe("CLI", () => {
phase: "validation",
filesCompleted: 0,
filesTotal: 8,
reviewItems: { completed: 11, total: 13 },
reviewItems: { completed: 0, total: 13 },
},
{
phase: "validation",
@@ -2572,15 +2573,20 @@ describe("CLI", () => {
],
});
deps.setInterval = mock(fakeInterval);
expect(await runCli(["scan", ".", "--headless"], deps)).toBe(0);
expect(
await runCli(["scan", ".", "--headless", "--diff", "HEAD^"], deps),
).toBe(0);
expect(stderr.text()).toContain(
"Scan phase: validating findings (11/13 reviews).",
"Running scan: preflight (committed changes) | File inventory: 8",
);
expect(stderr.text()).toContain(
"Scan phase: validating findings (0/13 reviews).",
);
expect(stderr.text()).toContain(
"Scan phase: validating findings (13/13 reviews).",
);
expect(stderr.text()).toContain(
"Running scan: validating findings | Reviews: 13/13",
"Running scan: validating findings (committed changes) | Reviews: 13/13",
);
expect(stderr.text()).not.toContain("Files: 13/13");
});
@@ -5227,7 +5233,12 @@ describe("CLI", () => {
expect(stderr.text()).toContain(
"Tokens: unavailable uncached input, 200 cache reads, unavailable cache writes, 30 output, 1,280 total. Estimated cost: $0.00488–$0.01156 (standard, context unknown, cache writes unknown).",
);
expect(stderr.text()).toContain("Scan phase: reviewing files (0/8 files).");
expect(stderr.text()).toContain(
"Scan phase: reviewing files (8 files inventoried).",
);
expect(stderr.text()).toContain(
"Running scan: reviewing files | File inventory: 8",
);
expect(stderr.text()).toContain("Scan phase: reviewing files (3/8 files).");
expect(stderr.text()).toContain(
"Running scan: reviewing files | Workers: 4/6 | Files: 3/8 | Tokens: unavailable uncached input, 200 cache reads, unavailable cache writes, 30 output, 1,280 total | Cost: $0.00488–$0.01156",
@@ -619,6 +619,13 @@ test.each([
.text()
.includes("apps/api | ChatGPT allowance not reported"),
).toBe(presentation === "headless");
for (const filesTotal of [0, 2]) {
options.onProgress?.({
phase: "preflight",
filesCompleted: 0,
filesTotal,
});
}
options.onProgress?.({
phase: "validation",
filesCompleted: 2,
@@ -667,6 +674,8 @@ test.each([
);
} else expect(stderr.text()).toContain("apps/api completed");
if (presentation !== "dashboard") {
expect(stderr.text()).toContain("apps/api preflight | File inventory: 0");
expect(stderr.text()).toContain("apps/api preflight | File inventory: 2");
expect(stderr.text()).toContain(
"apps/api validating findings | Files: 2/2",
);
+32 -1
View File
@@ -842,19 +842,50 @@ describe("GitHub request transport", () => {
});
describe("release workflow controls", () => {
const { permissions, jobs } = Bun.YAML.parse(workflow) as {
const { permissions, jobs, concurrency } = Bun.YAML.parse(workflow) as {
permissions: Record<string, string>;
concurrency: { group: string; "cancel-in-progress": boolean };
jobs: Record<
string,
{
if: string;
permissions?: Record<string, string>;
concurrency?: { group: string; queue: string };
env: { RELEASE_PR_DRY_RUN: string };
steps: { id?: string; if?: string }[];
}
>;
};
test("manual release runs keep their place during a burst of main pushes", () => {
const slot = (event_name: string, run_id: number) =>
concurrency.group.replace(/\$\{\{(.*?)\}\}/gu, (_, expression) =>
String(
new Function("github", `return (${expression})`)({
event_name,
run_id,
}),
),
);
const push = slot("push", 10);
expect(slot("push", 11)).toBe(push);
const slots = [
push,
slot("workflow_dispatch", 12),
slot("workflow_dispatch", 13),
];
expect(new Set(slots).size).toBe(slots.length);
expect(concurrency["cancel-in-progress"]).toBe(false);
expect(slots).not.toContain(jobs["reconcile"]?.concurrency?.group);
expect(jobs["reconcile"]?.concurrency).toEqual({
group: "node-release-pr",
queue: "max",
});
expect(jobs["preview"]?.concurrency).toEqual(
jobs["reconcile"]?.concurrency,
);
});
test.each([
{ dryRun: "false", clientId: "", createsAppToken: false },
{ dryRun: "false", clientId: "synthetic-app-id", createsAppToken: true },
@@ -7,6 +7,7 @@ const workflow = Bun.YAML.parse(
"utf8",
),
) as {
on: { workflow_run: { workflows: string[]; types: string[] } };
concurrency: { group: string };
jobs: {
identify: {
@@ -80,6 +81,61 @@ function identify(
return { output: output.join(""), calls };
}
test("main CI completions report independently of cutting a release", () => {
expect(workflow.on).toHaveProperty("workflow_call");
expect(workflow.on.workflow_run).toEqual({
workflows: ["node-release", "node-github-release"],
types: ["in_progress", "completed"],
});
const cut = Bun.YAML.parse(
readFileSync(
new URL(
"../../../.github/workflows/node-release-cut.yml",
import.meta.url,
),
"utf8",
),
) as {
on: { workflow_run: unknown };
jobs: { progress: { if: string; uses: string }; cut: unknown };
};
expect(cut.on.workflow_run).toEqual({
workflows: ["node-ci"],
types: ["completed"],
branches: ["main"],
});
expect(cut.jobs.progress.uses).toBe(
"./.github/workflows/release-progress.yml",
);
expect(cut.jobs.cut).not.toHaveProperty("needs");
expect(cut.jobs.progress).not.toHaveProperty("needs");
expect(cut.jobs.cut).toHaveProperty("concurrency", {
group: "node-release-cut",
queue: "max",
});
const selected = new Function("github", `return (${cut.jobs.progress.if})`);
const context = {
repository: "openai/codex-security",
event_name: "workflow_run",
event: { workflow_run: ciRun },
};
for (const conclusion of ["success", "failure", "cancelled"]) {
expect(
selected({
...context,
event: { workflow_run: { ...ciRun, conclusion } },
}),
).toBe(true);
}
expect(selected({ ...context, event_name: "workflow_dispatch" })).toBe(false);
expect(
selected({
...context,
event: { workflow_run: { ...ciRun, event: "pull_request" } },
}),
).toBe(false);
});
test("ordinary CI commits do not reach release checkout or reporting", () => {
for (const pull of [
{ ...releasePull, title: "fix: improve reporting" },