OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(plugin): inherit the launching turn's Deep Scan speed (#2231)
Michael D'Angelo223dea63905b
diff --git a/docs/project-configuration.md b/docs/project-configuration.mdindex 0fe923ba5..376c7da1a 100644--- a/docs/project-configuration.md+++ b/docs/project-configuration.md@@ -78,6 +78,15 @@ node sdk/typescript/bin/codex-security.mjs scan . -c docs/examples/codex-securit## Desktop and conversational Deep Scans+When the Codex host supplies the launching turn’s speed, Deep Scan uses it for+discovery and reducer workers, including resumed workers. Selecting Default+overrides a faster tier in the worker’s Codex config. On hosts that omit the+turn’s speed, each worker uses the Codex configuration it loads. To keep a scan+at Default on those hosts, leave `service_tier = "default"` in the worker’s+config for the duration of the scan, including any resumes. Other scans that+load the same config also use that setting. The usual config file is+`$CODEX_HOME/config.toml`, or `~/.codex/config.toml` when `$CODEX_HOME` is unset.+Deep Scan setup accepts an explicitly selected `.yaml`, `.yml`, or `.json` projectfile using the same format. For example:diff --git a/plugins/codex-security/mcp-app/server.ts b/plugins/codex-security/mcp-app/server.tsindex ccba371fd..1c04b86ac 100644--- a/plugins/codex-security/mcp-app/server.ts+++ b/plugins/codex-security/mcp-app/server.ts@@ -979,6 +979,8 @@ export function createCodexSecurityServer(): McpServer {);}const modelSettings = codexModelSettingsFromExtra(extra);+ const serviceTier =+ requestMetadataFromExtra(extra)?.["codex/turn-service-tier"];let parentSandbox: DeepWorkerParentSandbox;try {parentSandbox = resolveDeepWorkerParentSandbox(extra);@@ -1031,6 +1033,8 @@ export function createCodexSecurityServer(): McpServer {threadId,projectConfigPath,...modelSettings,+ serviceTier:+ typeof serviceTier === "string" ? serviceTier : undefined,scanRoot: await scanRoot(),});if (handoffClaimToken) {diff --git a/plugins/codex-security/mcp-app/src/deep-scan/engine.ts b/plugins/codex-security/mcp-app/src/deep-scan/engine.tsindex a1309f2d5..0548510c9 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/engine.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/engine.ts@@ -39,6 +39,7 @@ export function startDeepScanEngine(options: {executor: new CodexSdkWorkerExecutor({model: options.model,reasoningEffort: options.reasoningEffort,+ serviceTier: run.serviceTier,deepScanConfig: run.config,parentSandbox: options.parentSandbox,parentTurn: options.parentTurn,diff --git a/plugins/codex-security/mcp-app/src/deep-scan/executor.ts b/plugins/codex-security/mcp-app/src/deep-scan/executor.tsindex 6a49c11e4..6297ba84f 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/executor.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/executor.ts@@ -57,6 +57,7 @@ import type {export interface CodexSdkWorkerModelSettings {model?: string;reasoningEffort?: string;+ serviceTier?: string;deepScanConfig?: DeepScanConfig;artifactContext?: CodexSdkWorkerArtifactContext;parentSandbox?: DeepWorkerParentSandbox;@@ -174,6 +175,9 @@ export class CodexSdkWorkerExecutor implements CodexWorkerExecutor {...(this.modelSettings.reasoningEffort? { model_reasoning_effort: this.modelSettings.reasoningEffort }: {}),+ ...(this.modelSettings.serviceTier === undefined+ ? {}+ : { service_tier: this.modelSettings.serviceTier }),mcp_servers: {// A disabled server still needs a valid transport during native resolution."codex-security": { command: "node", enabled: false },diff --git a/plugins/codex-security/mcp-app/src/deep-scan/response.ts b/plugins/codex-security/mcp-app/src/deep-scan/response.tsindex 75822038c..d7c7301ba 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/response.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/response.ts@@ -77,6 +77,7 @@ export const runSchema = zfilePaths: z.array(z.string()).optional(),scanId: requiredString,sdkOwnsCompletion: z.boolean().optional(),+ serviceTier: optionalString,coordinatorGeneration: optionalValue(positiveInteger),createdAt: optionalString,updatedAt: optionalString,diff --git a/plugins/codex-security/mcp-app/src/deep-scan/store.ts b/plugins/codex-security/mcp-app/src/deep-scan/store.tsindex 8017448b1..36d13f9bd 100644--- a/plugins/codex-security/mcp-app/src/deep-scan/store.ts+++ b/plugins/codex-security/mcp-app/src/deep-scan/store.ts@@ -138,6 +138,7 @@ export class WorkbenchDeepScanStore {handoffClaimToken?: string;model?: string;reasoningEffort?: string;+ serviceTier?: string;threadId: string;scanRoot: string;}): Promise<DeepScanRunState> {@@ -152,6 +153,7 @@ export class WorkbenchDeepScanStore {claimToken: input.handoffClaimToken || undefined,model: input.model || undefined,reasoningEffort: input.reasoningEffort || undefined,+ serviceTier: input.serviceTier,scanRoot: input.scanRoot,availableParallelism: availableParallelism(),workflowVersion: WORKFLOW_VERSION,diff --git a/plugins/codex-security/mcp-app/src/workbench/migrations.ts b/plugins/codex-security/mcp-app/src/workbench/migrations.tsindex b5b4a3416..654e8d909 100644--- a/plugins/codex-security/mcp-app/src/workbench/migrations.ts+++ b/plugins/codex-security/mcp-app/src/workbench/migrations.ts@@ -225,7 +225,7 @@ export function applyMigrations(} else if (item.version === 16) backfill = repairStableTargets(database);else if (applied.has(item.version)) {if (- [2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58].includes(+ [2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59].includes(item.version,))diff --git a/plugins/codex-security/mcp-app/tests/deep_scan_worker_settings_cases.ts b/plugins/codex-security/mcp-app/tests/deep_scan_worker_settings_cases.tsindex 8f06be4fc..042f55e8d 100644--- a/plugins/codex-security/mcp-app/tests/deep_scan_worker_settings_cases.ts+++ b/plugins/codex-security/mcp-app/tests/deep_scan_worker_settings_cases.ts@@ -51,6 +51,7 @@ export async function testWorkerCyberAccessSettings({parentTurn?: { threadId: string; turnId: string };missingParentTurn?: boolean;failParentReadOnce?: boolean;+ parentServiceTier?: string;serviceTier?: string;features?: Record<string, boolean>;configPath?: string;@@ -58,6 +59,18 @@ export async function testWorkerCyberAccessSettings({executor?: import("../src/deep-scan/executor.js").CodexSdkWorkerExecutor;}[] = [{ name: "unset", configuration: "" },+ {+ name: "parent-default-speed",+ configuration: 'service_tier = "ultrafast"\n',+ parentServiceTier: "default",+ serviceTier: "default",+ },+ {+ name: "parent-fast-speed",+ configuration: 'service_tier = "ultrafast"\n',+ parentServiceTier: "fast",+ serviceTier: "fast",+ },{name: "blue",configuration:@@ -302,6 +315,7 @@ export async function testWorkerCyberAccessSettings({model: testCase.name,parentSandbox,parentTurn: testCase.parentTurn,+ serviceTier: testCase.parentServiceTier,});}for (const testCase of cases.filter(diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.tsindex 0f1bc506f..ab710518b 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_stdio_lifecycle.ts@@ -1,7 +1,11 @@import { jsonLineInputSource } from "./support/json-line-input-source.ts";import type { PersistedDeepScanWorker } from "../src/deep-scan/types.js";import { readJson, readJsonLines } from "./support/json.ts";-import { assertNoError, assertFlagPair } from "./assertions.ts";+import {+ assertConfigOverrides,+ assertNoError,+ assertFlagPair,+} from "./assertions.ts";import { readOnlyParentSandboxState } from "./sandbox-state.ts";import { temporaryDirectory } from "./support/temporary-directories.ts";import assert from "node:assert/strict";@@ -155,6 +159,7 @@ max_discovery_runs = 2profile = "selected"[profiles.selected]model_reasoning_summary = "none"+service_tier = "ultrafast"`,);await writePythonWrapper(`${pythonWrapperPath}.mjs`);@@ -285,10 +290,13 @@ model_reasoning_summary = "none"},threadId,{- model: "gpt-5.5",- reasoning_effort: "xhigh",- thread_id: threadId,- turn_id: "active-parent-turn",+ "x-codex-turn-metadata": {+ model: "gpt-5.5",+ reasoning_effort: "xhigh",+ thread_id: threadId,+ turn_id: "active-parent-turn",+ service_tier: "default",+ },},),);@@ -335,6 +343,7 @@ model_reasoning_summary = "none"{ code: "ENOENT" },);assertFlagPair(startedWorker.argv, "--model", "gpt-5.5");+ assertConfigOverrides(startedWorker.argv, { service_tier: "ultrafast" });assertFlagPair(startedWorker.argv,"--cyber-access-program",@@ -573,7 +582,12 @@ model_reasoning_summary = "none"userContext: "stdio failure fixture",},failureThreadId,- { model: "gpt-5.6-sol", reasoning_effort: "high" },+ {+ "x-codex-turn-metadata": {+ model: "gpt-5.6-sol",+ reasoning_effort: "high",+ },+ },),);const failedScanId = await waitForScanId({@@ -807,7 +821,13 @@ model_reasoning_summary = "none""start_codex_security_deep_scan",{ scanId: resumedScanId, handoffClaimToken },resumedThreadId,- { model: "gpt-5.6-sol", reasoning_effort: "high" },+ {+ "x-codex-turn-metadata": {+ model: "gpt-5.6-sol",+ reasoning_effort: "high",+ },+ "codex/turn-service-tier": "default",+ },),);let partial;@@ -909,7 +929,13 @@ model_reasoning_summary = "none""start_codex_security_deep_scan",{ scanId: resumedScanId, handoffClaimToken },resumedThreadId,- { model: "gpt-6.1-sol", reasoning_effort: "max" },+ {+ "x-codex-turn-metadata": {+ model: "gpt-6.1-sol",+ reasoning_effort: "max",+ },+ "codex/turn-service-tier": "fast",+ },),);await waitFor(@@ -956,7 +982,12 @@ model_reasoning_summary = "none""start_codex_security_deep_scan",{ scanId: resumedScanId, handoffClaimToken },resumedThreadId,- { model: "gpt-6.1-sol", reasoning_effort: "max" },+ {+ "x-codex-turn-metadata": {+ model: "gpt-6.1-sol",+ reasoning_effort: "max",+ },+ },),);assertNoError(resumed);@@ -1064,6 +1095,7 @@ model_reasoning_summary = "none");for (const [index, execution] of executions.entries()) {const afterRestart = index + restartStartIndex >= resumedStartIndex;+ assertConfigOverrides(execution.argv, { service_tier: "default" });assertReadOnlyWorkerInvocation(execution.argv, codexHome);assert.equal(execution.readCoreScanReference, true);const context = discoveryPromptContext(execution.stdin);@@ -1555,12 +1587,7 @@ function toolCall(name: string,args: Record<string, unknown>,threadId: string,- turnMetadata?: {- model: string;- reasoning_effort: string;- thread_id?: string;- turn_id?: string;- },+ metadata: Record<string, unknown> = {},sandboxState: unknown = parentSandboxState,) {return {@@ -1569,7 +1596,7 @@ function toolCall(_meta: {"openai/threadId": threadId,...(sandboxState ? { "codex/sandbox-state-meta": sandboxState } : {}),- ...(turnMetadata ? { "x-codex-turn-metadata": turnMetadata } : {}),+ ...metadata,},};}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.tsindex 478aea00b..69723bff6 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@@ -38,12 +38,16 @@ async function testBeginProtocolAndParsing() {const calls: { args: string[]; input?: string }[] = [];const runner = async (args: string[], input?: string) => {calls.push({ args, input });- return stateResult(scanId, { startDisposition: "created" });+ return stateResult(scanId, {+ startDisposition: "created",+ deepScan: { serviceTier: "default" },+ });};const store = new WorkbenchDeepScanStore(runner);const result = await store.begin({model: "gpt-5.6-sol",reasoningEffort: "high",+ serviceTier: "default",targetPath: "/fixture/repository",scope: ".",userContext: "focus on archive parsing",@@ -51,6 +55,7 @@ async function testBeginProtocolAndParsing() {scanRoot: "/fixture/scans",});assert.equal(result.scanId, scanId);+ assert.equal(result.serviceTier, "default");assert.deepEqual(result.config, {workers: 6,subagents: 3,@@ -69,6 +74,7 @@ async function testBeginProtocolAndParsing() {);assert.equal(flagValue(calls[0].args, "--model"), "gpt-5.6-sol");assert.equal(flagValue(calls[0].args, "--reasoning-effort"), "high");+ assert.equal(flagValue(calls[0].args, "--service-tier"), "default");assert.equal(flagValue(calls[0].args, "--scope"), ".");assert.equal(calls[0].args.includes("--user-context-stdin"), true);assert.equal(calls[0].input, "focus on archive parsing");diff --git a/plugins/codex-security/mcp-app/tests/test_workbench_database.ts b/plugins/codex-security/mcp-app/tests/test_workbench_database.tsindex 48af1bbb8..870364498 100644--- a/plugins/codex-security/mcp-app/tests/test_workbench_database.ts+++ b/plugins/codex-security/mcp-app/tests/test_workbench_database.ts@@ -169,7 +169,7 @@ test("every released schema upgrades to the same current schema and remains idem});for (const { missingVersions, legacyCheckpoint, mainReader } of [- { missingVersions: [57, 58], legacyCheckpoint: 0, mainReader: false },+ { missingVersions: [57, 58, 59], legacyCheckpoint: 0, mainReader: false },{ missingVersions: [], legacyCheckpoint: 47, mainReader: false },{ missingVersions: [], legacyCheckpoint: 47, mainReader: true },{ missingVersions: [], legacyCheckpoint: 48, mainReader: false },@@ -915,11 +915,16 @@ test("recorded additive migrations restore missing columns and configured errordatabase.exec(`INSERT INTO deep_scan_runs (scan_id, schema_version, workflow_version, status, phase,workers, subagents, stop_after_no_new, max_discovery_runs, created_at, updated_at)VALUES ('scan', 1, 'v1', 'running', 'discovery', 1, 0, 7, 10, 'created', 'updated')`);- for (const version of [27, 28, 31, 32, 47, 54, 55, 58])+ for (const version of [27, 28, 31, 32, 47, 54, 55, 58, 59])database.prepare("INSERT INTO schema_migrations VALUES (?, ?, 'original')").run(version, migrations[version - 1].name);applyMigrations(database);+ assert.equal(+ database.prepare("SELECT service_tier FROM deep_scan_runs").get()+ ?.service_tier,+ null,+ );assert.equal(database.prepare("SELECT terminal_reviewed_surface_count FROM deep_scan_runs")diff --git a/plugins/codex-security/scripts/deep_scan_workbench.py b/plugins/codex-security/scripts/deep_scan_workbench.pyindex 8ca4dc727..20244fff9 100644--- a/plugins/codex-security/scripts/deep_scan_workbench.py+++ b/plugins/codex-security/scripts/deep_scan_workbench.py@@ -328,6 +328,7 @@ def deep_scan_state(connection: sqlite3.Connection, scan_id: str) -> dict[str, Areturn {"scanId": run["scan_id"],"sdkOwnsCompletion": scan["recipe_json"] is not None,+ "serviceTier": run["service_tier"],"targetPath": scan["target_path"],"scope": scan["scope"],"includePaths": dependencies().requested_scan_paths(scan),@@ -455,6 +456,7 @@ def ensure_deep_scan_run(workflow_version: str,timestamp: str,*,+ service_tier: str | None,pending_target_project_path: str | None = None,) -> sqlite3.Row:existing = connection.execute(@@ -472,8 +474,8 @@ def ensure_deep_scan_run(scan_id, schema_version, workflow_version, status, phase,workers, subagents, stop_after_no_new, stop_after_consecutive_errors,max_discovery_runs, max_time_hours, discovery_user_context_json,- created_at, updated_at, pending_target_project_path- ) VALUES (?, 1, ?, 'running', 'setup', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)+ created_at, updated_at, service_tier, pending_target_project_path+ ) VALUES (?, 1, ?, 'running', 'setup', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",(scan["id"],@@ -487,6 +489,7 @@ def ensure_deep_scan_run(json.dumps(scan["user_context"]),timestamp,timestamp,+ service_tier,pending_target_project_path,),)@@ -661,7 +664,14 @@ def begin_deep_scan_for_scan("UPDATE workspaces SET deep_scan_config_json = ? WHERE id = ? AND deep_scan_config_json IS NULL",(json.dumps(configuration), workspace["id"]),)- ensure_deep_scan_run(connection, scan, config, workflow_version, dependencies().now())+ ensure_deep_scan_run(+ connection,+ scan,+ config,+ workflow_version,+ dependencies().now(),+ service_tier=args.service_tier,+ )return deep_scan_result(connection, scan_id, start_disposition="created")@@ -810,6 +820,7 @@ def begin_deep_scan_for_target(config,workflow_version,timestamp,+ service_tier=args.service_tier,pending_target_project_path=project_path,)return deep_scan_result(connection, scan_id, start_disposition="created")diff --git a/plugins/codex-security/scripts/workbench_cli.py b/plugins/codex-security/scripts/workbench_cli.pyindex df09335e1..be1a26391 100644--- a/plugins/codex-security/scripts/workbench_cli.py+++ b/plugins/codex-security/scripts/workbench_cli.py@@ -121,6 +121,7 @@ def parse_args(description: str, *, inspection_only: bool = False) -> argparse.Nbegin_deep_scan.add_argument("--claim-token")begin_deep_scan.add_argument("--model")begin_deep_scan.add_argument("--reasoning-effort")+ begin_deep_scan.add_argument("--service-tier")begin_deep_scan.add_argument("--available-parallelism", type=positive_int)begin_deep_scan.add_argument("--deep-scan-project-json")begin_deep_scan.add_argument("--project-config-path")diff --git a/plugins/codex-security/scripts/workbench_schema.py b/plugins/codex-security/scripts/workbench_schema.pyindex 024e3c13c..39e5038ba 100644--- a/plugins/codex-security/scripts/workbench_schema.py+++ b/plugins/codex-security/scripts/workbench_schema.py@@ -75,7 +75,7 @@ def apply_migrations(elif version == 16:should_backfill_targets = repair_stable_targets_migration(connection)elif version in applied:- if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58):+ if version in (2, 12, 13, 26, 28, 31, 32, 42, 47, 50, 54, 55, 58, 59):repair_additive_migration(connection, version)elif version == 11:repair_deep_scan_migration(connection)diff --git a/plugins/codex-security/shared/workbench-migrations.json b/plugins/codex-security/shared/workbench-migrations.jsonindex 94b945de0..9468d50a0 100644--- a/plugins/codex-security/shared/workbench-migrations.json+++ b/plugins/codex-security/shared/workbench-migrations.json@@ -476,5 +476,10 @@"statements": ["ALTER TABLE deep_scan_runs ADD COLUMN terminal_reviewed_surface_count INTEGER CHECK (terminal_reviewed_surface_count >= 0);"]+ },+ {+ "version": 59,+ "name": "retain the launching Deep Scan service tier",+ "statements": ["ALTER TABLE deep_scan_runs ADD COLUMN service_tier TEXT;"]}]diff --git a/plugins/codex-security/tests/test_checkpoint_schema.py b/plugins/codex-security/tests/test_checkpoint_schema.pyindex f0d2ced0a..bd2e1e97a 100644--- a/plugins/codex-security/tests/test_checkpoint_schema.py+++ b/plugins/codex-security/tests/test_checkpoint_schema.py@@ -11,7 +11,7 @@ import pytest"omitted_versions, legacy_checkpoint, main_reader",[((), False, False),- ((57, 58), False, False),+ ((57, 58, 59), False, False),((), 47, False),((), 47, True),((), 48, False),diff --git a/plugins/codex-security/tests/test_workbench_deep_scan.py b/plugins/codex-security/tests/test_workbench_deep_scan.pyindex 77dd6eb95..777f1fdbe 100644--- a/plugins/codex-security/tests/test_workbench_deep_scan.py+++ b/plugins/codex-security/tests/test_workbench_deep_scan.py@@ -64,6 +64,7 @@ def begin_target_scan(*,thread_id: str = "thread-deep-scan",user_context: str | None = None,+ service_tier: str | None = None,) -> dict[str, object]:return begin_deep_scan(state_dir,@@ -77,6 +78,7 @@ def begin_target_scan("--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),input_text=user_context,)@@ -95,6 +97,7 @@ def start_empty_target_scan(tmp_path: Path, *, config: str | None = None) -> Deedef restore_v53_schema(state_dir: Path) -> None:with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:+ connection.execute("ALTER TABLE deep_scan_runs DROP COLUMN service_tier")connection.execute("ALTER TABLE deep_scan_runs DROP COLUMN terminal_reviewed_surface_count")connection.execute("ALTER TABLE scans DROP COLUMN retained_checkpoint_heads_json")connection.execute("ALTER TABLE workspaces DROP COLUMN deep_scan_config_json")@@ -1198,9 +1201,10 @@ def test_target_begin_is_atomic_idempotent_and_snapshots_config(tmp_path: Path)(target / "source.py").write_text("print('fixture')\n")scan_root = tmp_path / "scans"- first = begin_target_scan(state_dir, codex_home, target, scan_root)+ first = begin_target_scan(state_dir, codex_home, target, scan_root, service_tier="default")assert first["startDisposition"] == "created"deep_scan = first["deepScan"]+ assert deep_scan["serviceTier"] == "default"assert deep_scan["status"] == "running"assert deep_scan["phase"] == "setup"assert deep_scan["config"] == {@@ -1220,10 +1224,11 @@ def test_target_begin_is_atomic_idempotent_and_snapshots_config(tmp_path: Path)assert deep_scan["canonicalArtifacts"] is Noneconfig_path.write_text("[deep_scan]\nworkers = 1\nmax_time_hours = 8\n")- second = begin_target_scan(state_dir, codex_home, target, scan_root)+ second = begin_target_scan(state_dir, codex_home, target, scan_root, service_tier="priority")assert second["startDisposition"] == "joined"assert second["deepScan"]["scanId"] == deep_scan["scanId"]assert second["deepScan"]["config"] == deep_scan["config"]+ assert second["deepScan"]["serviceTier"] == "default"with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:assert connection.execute("SELECT COUNT(*) FROM workspaces").fetchone() == (1,)@@ -1298,14 +1303,30 @@ def test_sdk_scan_begin_claims_its_existing_scan(tmp_path: Path) -> None:assert "orchestration must finish and persist its manifest" in str(premature["stderr"])begun = begin_deep_scan(- state_dir, "sdk-thread", "--scan-id", scan_id, environment=deep_environment(codex_home)+ state_dir,+ "sdk-thread",+ "--scan-id",+ scan_id,+ "--service-tier",+ "priority",+ environment=deep_environment(codex_home),)+ assert begun["deepScan"]["serviceTier"] == "priority"assert begun["deepScan"]["scanId"] == scan_idassert begun["deepScan"]["scanDir"] == str(scan_dir)assert begun["deepScan"]["userContext"] == user_contextrestore_v53_schema(state_dir)- get_deep_scan(state_dir, scan_id, "sdk-thread", environment=deep_environment(codex_home))+ # An existing run from a host without tier metadata keeps using its config.+ resumed = resume_deep_scan(+ state_dir,+ scan_id,+ "sdk-thread",+ "--service-tier",+ "default",+ environment=deep_environment(codex_home),+ )+ assert resumed["deepScan"]["serviceTier"] is Nonewith sqlite3.connect(state_dir / "workbench.sqlite3") as connection:assert connection.execute("SELECT COUNT(*) FROM scans").fetchone() == (1,)assert connection.execute("SELECT thread_id FROM workspaces").fetchone() == ("sdk-thread",)diff --git a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py b/plugins/codex-security/tests/test_workbench_setup_and_migrations.pyindex c00af1b92..af07a5741 100644--- a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py+++ b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py@@ -101,6 +101,7 @@ EXPECTED_MIGRATIONS = [(56, "recover unfinished legacy headless deep scans"),(57, "freeze stopped scan checkpoint selections"),(58, "record the final Deep Scan reviewed surface count"),+ (59, "retain the launching Deep Scan service tier"),]