Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

ci: include runtime helpers in native proof cache keys (#1984)

Michael D'Angelo23f8ceded5a5
diff --git a/.github/workflows/native-artifacts.yml b/.github/workflows/native-artifacts.yml
index e80d961d1..ad82eff43 100644
--- a/.github/workflows/native-artifacts.yml
+++ b/.github/workflows/native-artifacts.yml
@@ -36,9 +36,15 @@ jobs:
# Include filenames and modes, not only file contents. Windows proofs
# bundle MCP helpers, including their schema and workbench dependencies.
empty_tree="$(git hash-object -t tree --stdin </dev/null)"
+ # These existing CI entrypoints run outside the native jobs.
+ ci_only=':(exclude).github/scripts/'
source_hash="$(git diff-tree -r -z --no-abbrev "$empty_tree" HEAD -- \
.gitattributes .cargo .npmrc .pnpmfile.cjs package.json pnpm-workspace.yaml \
- .github/actions/setup-tools '.github/scripts/*.mts' \
+ .github/actions/setup-tools .github/scripts \
+ "${ci_only}"invoice-desk-{source,target}{,.test}.mjs \
+ "${ci_only}"{check-ci-results,select-ci-checks,test-ci-selection,test-release-guide}.mjs \
+ "${ci_only}"{verify-pr-source,test-verify-pr-source,release-progress,test_release_progress}.mjs \
+ "${ci_only}"{install-ripgrep.sh,require_native_python_report.py,test_require_native_python_report.py} \
.github/workflows/native-artifacts.yml \
.github/workflows/native-unix.yml \
.github/workflows/native-windows.yml \
diff --git a/docs/ci.md b/docs/ci.md
index a11de33af..643a48a0c 100644
--- a/docs/ci.md
+++ b/docs/ci.md
@@ -132,8 +132,8 @@ a PR that leaves those inputs unchanged, look for the exact key in
matter which `main` run saved it. Different inputs can build in parallel.
The key uses the UTC week and the paths listed in **Identify native build and
-proof inputs**. For repository CI scripts, the native jobs compile
-`.github/scripts/*.mts` through `build:ci`; changing unrelated workflow scripts
-does not require rebuilding native artifacts. Compare the next change against
-current `main`: its PR run may have tested an older base or skipped native
-preparation entirely. PR runs cannot populate this cache for `main`.
+proof inputs**. Repository scripts are included by default: a native proof can
+load a helper at runtime. The workflow excludes known CI entrypoints that run
+elsewhere. Compare the next change against current `main`: its PR run may have
+tested an older base or skipped native preparation. PRs cannot populate this
+cache for `main`.
diff --git a/sdk/typescript/tests-ts/native-artifact-cache.test.ts b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
index f6efa5d5b..9216cdd30 100644
--- a/sdk/typescript/tests-ts/native-artifact-cache.test.ts
+++ b/sdk/typescript/tests-ts/native-artifact-cache.test.ts
@@ -46,9 +46,17 @@ test("native reuse hashes committed inputs with Git alone across platforms", ()
const output = join(root, "output");
const source = "plugins/codex-security/native/src/lib.rs";
const helper = "plugins/codex-security/mcp-app/src/native.ts";
- writeSource(repository, source, "native source\n");
- writeSource(repository, helper, "helper source\n");
- writeSource(repository, "README.md", "documentation\n");
+ const proof = "plugins/codex-security/native/proof.mjs";
+ const proofHelper = ".github/scripts/native-proof-helper.mjs";
+ const write = (path: string, contents: string) =>
+ writeSource(repository, path, contents);
+ const runProof = () =>
+ spawnSync(process.execPath, [proof], { cwd: repository }).status;
+ write(source, "native source\n");
+ write(helper, "helper source\n");
+ write(proof, `import "../../../${proofHelper}";\n`);
+ write(proofHelper, "process.exitCode = 0;\n");
+ write("README.md", "documentation\n");
git(repository, "init", "-q");
const commit = () => {
git(repository, "add", ".");
@@ -85,46 +93,45 @@ test("native reuse hashes committed inputs with Git alone across platforms", ()
commit();
const initial = key();
expect(initial).toMatch(/^key=native-universal-v1-2026-43-[a-f0-9]{40}$/);
- writeSource(repository, "README.md", "updated documentation\n");
- writeSource(
- repository,
- ".github/scripts/verify-pr-source.mjs",
- "ci selection\n",
- );
- writeSource(
- repository,
- "plugins/codex-security/mcp-app/tests/support/new.ts",
- "fixture\n",
- );
- commit();
- expect(key()).toBe(initial);
+ expect(runProof()).toBe(0);
- writeSource(
- repository,
- ".github/scripts/new-proof-input.mts",
- "compile me\n",
- );
+ write("README.md", "updated documentation\n");
+ for (const script of [
+ "invoice-desk-target",
+ "check-ci-results",
+ "select-ci-checks",
+ "test-ci-selection",
+ "test-release-guide",
+ "verify-pr-source",
+ ]) {
+ write(`.github/scripts/${script}.mjs`, "// CI only\n");
+ }
+ write("plugins/codex-security/mcp-app/tests/support/new.ts", "fixture\n");
commit();
- const changedCompilerInput = key();
- expect(changedCompilerInput).not.toBe(initial);
-
- writeSource(repository, source, "updated native source\n");
- commit();
- const changedNative = key();
- expect(changedNative).not.toBe(changedCompilerInput);
-
- writeSource(repository, helper, "updated helper source\n");
- commit();
- const changedHelper = key();
- expect(changedHelper).not.toBe(changedNative);
+ expect(key()).toBe(initial);
+ let previous = initial;
+ const expectNewKey = () => {
+ commit();
+ const next = key();
+ expect(next).not.toBe(previous);
+ previous = next;
+ };
+ write(proofHelper, "process.exitCode = 1;\n");
+ expect(runProof()).toBe(1);
+ expectNewKey();
+ write(".github/scripts/new-proof-input.mts", "compile me\n");
+ expectNewKey();
+ write(source, "updated native source\n");
+ expectNewKey();
+ write(helper, "updated helper source\n");
+ expectNewKey();
renameSync(
join(repository, source),
join(repository, "plugins/codex-security/native/src/renamed.rs"),
);
- commit();
- expect(key()).not.toBe(changedHelper);
- expect(key("2026-44")).not.toBe(key());
+ expectNewKey();
+ expect(key("2026-44")).not.toBe(previous);
} finally {
rmSync(root, { recursive: true, force: true });
}