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

refactor(deep-scan): stop passing host CPU counts to worker setup (#2482)

Michael D'Angelo228003abbd58
diff --git a/plugins/codex-security/mcp-app/src/deep-scan/store.ts b/plugins/codex-security/mcp-app/src/deep-scan/store.ts
index fe7e34ddb..b0a6c26a6 100644
--- a/plugins/codex-security/mcp-app/src/deep-scan/store.ts
+++ b/plugins/codex-security/mcp-app/src/deep-scan/store.ts
@@ -1,6 +1,5 @@
import { workbenchArgs } from "../workbench-arguments.js";
import { readDeepScanProjectConfig } from "./project-config.js";
-import { availableParallelism } from "node:os";
import { join } from "node:path";
import { setTimeout as delay } from "node:timers/promises";
import { writeJsonAtomic } from "./artifacts.js";
@@ -153,7 +152,6 @@ export class WorkbenchDeepScanStore {
reasoningEffort: input.reasoningEffort || undefined,
serviceTier: input.serviceTier,
scanRoot: input.scanRoot,
- availableParallelism: availableParallelism(),
workflowVersion: WORKFLOW_VERSION,
};
let result = await this.enqueueWrite(
diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_store.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_store.ts
index 9e764c690..d1b2c8c60 100644
--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_store.ts
+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_store.ts
@@ -3,7 +3,7 @@ import { mock } from "node:test";
import assert from "node:assert/strict";
import { randomUUID } from "node:crypto";
import { mkdtemp, rm } from "node:fs/promises";
-import { availableParallelism, tmpdir } from "node:os";
+import { tmpdir } from "node:os";
import { join } from "node:path";
import { importSource } from "./import-module.ts";
import type { WorkbenchDeepScanStore as Store } from "../src/deep-scan/store.js";
@@ -80,10 +80,7 @@ async function testBeginProtocolAndParsing() {
assert.equal(calls[0].args.includes("--user-context-stdin"), true);
assert.equal(calls[0].input, "focus on archive parsing");
assert.equal(flagValue(calls[0].args, "--scan-root"), "/fixture/scans");
- assert.equal(
- flagValue(calls[0].args, "--available-parallelism"),
- String(availableParallelism()),
- );
+ assert.equal(calls[0].args.includes("--available-parallelism"), false);
assert.equal(
flagValue(calls[0].args, "--workflow-version"),
"deep-scan-mcp/v1",
diff --git a/plugins/codex-security/scripts/deep_scan_config.py b/plugins/codex-security/scripts/deep_scan_config.py
index 3ee192f54..a6474a97c 100644
--- a/plugins/codex-security/scripts/deep_scan_config.py
+++ b/plugins/codex-security/scripts/deep_scan_config.py
@@ -54,13 +54,12 @@ def resolve_deep_scan_config(available_parallelism: int) -> dict[str, int | floa
def resolve_deep_scan_setup(
- available_parallelism: int, project_json: str | None = None
+ available_parallelism: int = 1, project_json: str | None = None
) -> dict[str, Any]:
"""Resolve project overrides, per-user TOML settings, and bundled defaults in that order.
Args:
- available_parallelism (int): Positive parallelism reported by the caller.
- The configured worker count is independent of this value.
+ available_parallelism (int): Legacy caller argument. Any positive value selects the same settings.
project_json (str | None): Serialized project configuration with path and settings keys.
Returns:
diff --git a/plugins/codex-security/scripts/deep_scan_workbench.py b/plugins/codex-security/scripts/deep_scan_workbench.py
index f2da154ae..6c49d158e 100644
--- a/plugins/codex-security/scripts/deep_scan_workbench.py
+++ b/plugins/codex-security/scripts/deep_scan_workbench.py
@@ -465,8 +465,7 @@ def effective_deep_scan_config(
"""Use persisted workspace settings when available, otherwise resolve the current launch configuration."""
if workspace is not None and workspace["deep_scan_config_json"] is not None:
return json.loads(workspace["deep_scan_config_json"])
- available_parallelism = args.available_parallelism or os.cpu_count() or 1
- return resolve_deep_scan_setup(available_parallelism, args.deep_scan_project_json)
+ return resolve_deep_scan_setup(project_json=args.deep_scan_project_json)
def ensure_deep_scan_run(
diff --git a/plugins/codex-security/scripts/workbench_setup.py b/plugins/codex-security/scripts/workbench_setup.py
index fcfeafede..6117ce609 100644
--- a/plugins/codex-security/scripts/workbench_setup.py
+++ b/plugins/codex-security/scripts/workbench_setup.py
@@ -232,7 +232,7 @@ def inspect_selected_setup(args: argparse.Namespace) -> dict[str, Any]:
)
if args.mode == "deep":
inspected["deepScanConfig"] = resolve_deep_scan_setup(
- os.cpu_count() or 1, args.deep_scan_project_json
+ project_json=args.deep_scan_project_json
)
elif args.deep_scan_project_json is not None:
raise SystemExit("Project Deep Scan settings require Deep Scan mode.")
diff --git a/plugins/codex-security/tests/test_workbench_deep_scan.py b/plugins/codex-security/tests/test_workbench_deep_scan.py
index 59f6377da..14676dca0 100644
--- a/plugins/codex-security/tests/test_workbench_deep_scan.py
+++ b/plugins/codex-security/tests/test_workbench_deep_scan.py
@@ -78,8 +78,6 @@ def begin_target_scan(
".",
"--scan-root",
str(scan_root),
- "--available-parallelism",
- "16",
*(("--user-context-stdin",) if user_context is not None else ()),
*(("--service-tier", service_tier) if service_tier is not None else ()),
environment=deep_environment(codex_home),
@@ -1185,8 +1183,6 @@ def test_deep_scan_prefers_explicit_config_path(tmp_path: Path) -> None:
".",
"--scan-root",
str(tmp_path / "scans"),
- "--available-parallelism",
- "16",
environment={
**deep_environment(codex_home),
"CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH": str(isolated_config_path),
@@ -1567,8 +1563,6 @@ def assert_rejected_config(tmp_path: Path, setting: str, value: str, requirement
"thread-deep-scan",
"--target-path",
str(target),
- "--available-parallelism",
- "8",
environment=deep_environment(codex_home),
check=False,
)
@@ -2025,8 +2019,6 @@ def test_app_scan_begin_validates_mode_and_owner(tmp_path: Path) -> None:
scan_id,
"--claim-token",
claim_token,
- "--available-parallelism",
- "8",
environment=deep_environment(codex_home),
)
assert begun["startDisposition"] == "created"
diff --git a/plugins/codex-security/tests/test_workbench_feedback.py b/plugins/codex-security/tests/test_workbench_feedback.py
index 1f468187b..f5c27821a 100644
--- a/plugins/codex-security/tests/test_workbench_feedback.py
+++ b/plugins/codex-security/tests/test_workbench_feedback.py
@@ -103,8 +103,6 @@ def test_native_scan_materializes_false_positive_feedback(tmp_path: Path, mode:
"begin-deep-scan",
"--thread-id",
"feedback-parent",
- "--available-parallelism",
- "4",
"--target-path",
str(target),
"--scan-root",
diff --git a/plugins/codex-security/tests/test_workbench_scan_usage.py b/plugins/codex-security/tests/test_workbench_scan_usage.py
index ae5f31bc7..b6bb5bf32 100644
--- a/plugins/codex-security/tests/test_workbench_scan_usage.py
+++ b/plugins/codex-security/tests/test_workbench_scan_usage.py
@@ -133,8 +133,6 @@ def _start_scan(tmp_path: Path, *, mode: str = "standard") -> ScanFixture:
"scan-parent",
"--scan-id",
str(started["scanId"]),
- "--available-parallelism",
- "4",
environment=environment,
)
with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:
diff --git a/plugins/codex-security/tests/test_workbench_standard_deep_results.py b/plugins/codex-security/tests/test_workbench_standard_deep_results.py
index de082d40f..a5a63533f 100644
--- a/plugins/codex-security/tests/test_workbench_standard_deep_results.py
+++ b/plugins/codex-security/tests/test_workbench_standard_deep_results.py
@@ -1172,8 +1172,6 @@ def deep_scan_fixture(
".",
"--scan-root",
str(tmp_path / "scans"),
- "--available-parallelism",
- "16",
environment=environment,
)["deepScan"]
scan_id = str(begun["scanId"])
diff --git a/sdk/typescript/tests-ts/deep-scan-workbench.test.ts b/sdk/typescript/tests-ts/deep-scan-workbench.test.ts
index 6a8d2f0a7..e2bed886c 100644
--- a/sdk/typescript/tests-ts/deep-scan-workbench.test.ts
+++ b/sdk/typescript/tests-ts/deep-scan-workbench.test.ts
@@ -193,8 +193,6 @@ test.each([
"synthetic-thread",
"--scan-root",
join(root, "scans"),
- "--available-parallelism",
- "4",
"--workflow-version",
"deep-scan-mcp/v1",
]);
@@ -274,8 +272,6 @@ describe("deep scan workbench ownership", () => {
"--user-context-stdin",
"--scan-root",
join(root, "scans"),
- "--available-parallelism",
- "4",
],
{
env: { ...process.env, CODEX_SECURITY_STATE_DIR: stateDir },
@@ -452,8 +448,6 @@ describe("deep scan workbench ownership", () => {
"budget-recovery-thread",
"--scan-root",
join(root, "scans"),
- "--available-parallelism",
- "4",
"--workflow-version",
"deep-scan-mcp/v1",
]);
@@ -786,8 +780,6 @@ describe("deep scan workbench ownership", () => {
"empty-deadline-thread",
"--scan-root",
join(root, "scans"),
- "--available-parallelism",
- "4",
"--workflow-version",
"deep-scan-mcp/v1",
])
diff --git a/sdk/typescript/tests-ts/scan-resume.test.ts b/sdk/typescript/tests-ts/scan-resume.test.ts
index bc1b0b85c..d404a1bba 100644
--- a/sdk/typescript/tests-ts/scan-resume.test.ts
+++ b/sdk/typescript/tests-ts/scan-resume.test.ts
@@ -229,8 +229,6 @@ async function interruptedScan(
scanId,
"--thread-id",
threadId,
- "--available-parallelism",
- "4",
"--workflow-version",
"deep-scan-mcp/v1",
]);
@@ -523,8 +521,6 @@ test("CLI resumes through native execution with current permissions and preserve
f.scanId,
"--thread-id",
threadId,
- "--available-parallelism",
- "4",
]);
expect(joined["deepScan"]).toMatchObject({
scanId: f.scanId,
diff --git a/sdk/typescript/tests-ts/stopped-scan-results.test.ts b/sdk/typescript/tests-ts/stopped-scan-results.test.ts
index da95f32d2..3a8868a35 100644
--- a/sdk/typescript/tests-ts/stopped-scan-results.test.ts
+++ b/sdk/typescript/tests-ts/stopped-scan-results.test.ts
@@ -27,7 +27,7 @@ const stoppedScanProbe = [
"def run(*arguments):",
" completed = subprocess.run([sys.executable, '-I', '-B', str(script), *arguments], check=True, capture_output=True, text=True, env=environment)",
" return json.loads(completed.stdout)",
- "started = run('begin-deep-scan', '--thread-id', 'stopped-result-owner', '--target-path', str(target), '--scope', '.', '--scan-root', str(root / 'scans'), '--available-parallelism', '4')['deepScan']",
+ "started = run('begin-deep-scan', '--thread-id', 'stopped-result-owner', '--target-path', str(target), '--scope', '.', '--scan-root', str(root / 'scans'))['deepScan']",
"scan_id = started['scanId']",
"scan_dir = pathlib.Path(started['scanDir'])",
"worker_id = str(uuid.uuid4())",