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
test: reuse Python scan and workbench fixtures (#1491)
mldangelo-oaif2821cf18f46
diff --git a/plugins/codex-security/tests/test_finalize_scan_contract.py b/plugins/codex-security/tests/test_finalize_scan_contract.pyindex 6f280a3b9..d9950455f 100644--- a/plugins/codex-security/tests/test_finalize_scan_contract.py+++ b/plugins/codex-security/tests/test_finalize_scan_contract.py@@ -28,96 +28,28 @@ class FinalizeScanContractTest(ScanFixtureTestCase):def setUp(self) -> None:self.temp_dir = tempfile.TemporaryDirectory()self.scan_dir = Path(self.temp_dir.name).resolve()- self.manifest = {- "documentType": "codex-security.scan-manifest",- "schemaVersion": "1.0",- "scan": {- "id": "scan_001",- "producer": {- "name": "codex-security-plugin",- "version": "0.1.0",- },- "status": "completed",- "startedAt": "2026-05-31T18:00:00Z",- "completedAt": "2026-05-31T18:09:00Z",- "target": {- "kind": "git_worktree",- "targetId": "target_sha256_example",- "displayName": "example/repo",- "remote": "https://github.com/example/repo",- "revision": "deadbeef",- "snapshotDigest": "codex-security-snapshot/v1:sha256:0000000000000000000000000000000000000000000000000000000000000000",- },- "scope": {- "includePaths": ["src/"],- "excludePaths": [],- },- "coverageRef": "coverage.json",- "findingsRef": "findings.json",- },- }- self.finding = {- "ruleId": "path-traversal.archive-extraction",- "identity": {- "anchor": "archive-entry-write-without-containment",- },- "title": "Unsafe archive extraction can escape the output directory",- "summary": "An attacker-controlled path reaches a filesystem write without containment validation.",- "severity": {- "level": "high",- "score": 8.1,- "scoringSystem": "CVSS:3.1",- },- "confidence": {- "level": "high",- "rationale": "Direct source trace reaches the filesystem write without a containment check.",- },- "taxonomy": {- "category": "path-traversal",- "cwe": ["CWE-22"],- },- "locations": [- {- "path": "src/extract.py",- "startLine": 41,- "endLine": 44,- "role": "sink",- }- ],- "remediation": "Normalize destinations and reject entries that escape the extraction root.",- "validation": None,- "attackPath": None,- "provenance": {- "source": "local_plugin",- },- "extensions": {},- }- self.findings = {- "documentType": "codex-security.findings",- "schemaVersion": "1.0",- "scanId": "scan_001",- "findings": [copy.deepcopy(self.finding)],- }- self.coverage = {- "documentType": "codex-security.coverage",- "schemaVersion": "1.0",- "scanId": "scan_001",- "mode": "repository",- "completeness": "complete",- "inventoryStrategy": "repository",- "includePaths": ["src/"],- "excludePaths": [],- "surfaces": [- {- "id": "surface_archive_extraction",- "label": "Archive extraction",- "disposition": "reported",- "receiptRefs": [],- }- ],- "explicitExclusions": [],- "deferred": [],- }+ self.manifest = json.loads((EXAMPLE_DIR / "scan-manifest.json").read_text(encoding="utf-8"))+ scan = self.manifest["scan"]+ scan["id"] = "scan_001"+ scan.pop("sealedAt")+ scan.pop("artifacts")+ scan["scope"]["includePaths"] = ["src/"]+ scan["target"]["snapshotDigest"] = "codex-security-snapshot/v1:sha256:" + "0" * 64+ self.findings = json.loads((EXAMPLE_DIR / "findings.json").read_text(encoding="utf-8"))+ self.finding = self.findings["findings"][0]+ for field in (+ "findingId",+ "occurrenceId",+ "fingerprints",+ "remediationTests",+ "preventiveControls",+ ):+ self.finding.pop(field)+ self.findings["scanId"] = "scan_001"+ self.findings["findings"] = [copy.deepcopy(self.finding)]+ self.coverage = json.loads((EXAMPLE_DIR / "coverage.json").read_text(encoding="utf-8"))+ self.coverage["scanId"] = "scan_001"+ self.coverage["includePaths"] = ["src/"]def write_sealed_scan(self) -> None:self.write_scan()diff --git a/plugins/codex-security/tests/test_workbench_db.py b/plugins/codex-security/tests/test_workbench_db.pyindex 0fd91c4f3..fd3bde5fd 100644--- a/plugins/codex-security/tests/test_workbench_db.py+++ b/plugins/codex-security/tests/test_workbench_db.py@@ -1508,9 +1508,7 @@ def test_finding_remediation_rejects_apply_after_checkout_changes(tmp_path: Path).strip()nested_repository = target / "untracked-repository"initialize_git_repository(nested_repository)- workspace_id = str(uuid.uuid4())- create_workspace(state_dir, workspace_id, "--target-path", str(target))- save_workspace(state_dir, workspace_id, str(target), ".", "standard")+ workspace_id = str(create_saved_git_workspace(state_dir, target)["id"])started = start_delivered_scan(state_dir,"--workspace-id",diff --git a/plugins/codex-security/tests/test_workbench_db_exports.py b/plugins/codex-security/tests/test_workbench_db_exports.pyindex 39f2f18b4..00fbefe88 100644--- a/plugins/codex-security/tests/test_workbench_db_exports.py+++ b/plugins/codex-security/tests/test_workbench_db_exports.py@@ -34,7 +34,6 @@ from workbench_test_support import (scan_command,set_remediation,set_triage,- start_delivered_scan,start_saved_scan,start_scan_command,start_workspace_scan,@@ -173,14 +172,7 @@ def test_stopped_clean_git_checkpoint_uses_revision_target(tmp_path: Path) -> Notarget = tmp_path / "target"revision = initialize_git_repository(target)saved = create_saved_git_workspace(state_dir, target)- started = start_delivered_scan(- state_dir,- "--workspace-id",- str(saved["id"]),- "--scan-root",- str(tmp_path / "scans"),- )["results"]- scan_id, scan_dir = str(started["scanId"]), Path(str(started["scanDir"]))+ scan_id, scan_dir = start_workspace_scan(state_dir, str(saved["id"]), tmp_path / "scans")with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:connection.execute("UPDATE scans SET target_snapshot_digest = NULL WHERE id = ?", (scan_id,)@@ -431,9 +423,7 @@ def test_final_candidate_disposition_supersedes_pending_checkpoint(def test_incomplete_parent_checkpoint_cannot_complete_scan(tmp_path: Path) -> None:- state_dir, target = tmp_path / "state", tmp_path / "target"- target.mkdir()- scan_id, scan_dir = start_saved_scan(state_dir, target, tmp_path / "scans")+ state_dir, target, scan_id, scan_dir = empty_target_scan(tmp_path)write_completed_contract(scan_dir, scan_id, target)manifest = json.loads((scan_dir / "scan-manifest.json").read_text())manifest["scan"]["complete"] = False@@ -453,14 +443,7 @@ def test_model_only_draft_is_available_before_findings_and_survives_stop(target = tmp_path / "target"target.mkdir()saved = create_saved_workspace(state_dir, target)- started = start_delivered_scan(- state_dir,- "--workspace-id",- str(saved["id"]),- "--scan-root",- str(tmp_path / "scans"),- )["results"]- scan_id, scan_dir = str(started["scanId"]), Path(str(started["scanDir"]))+ scan_id, scan_dir = start_workspace_scan(state_dir, str(saved["id"]), tmp_path / "scans")update_progress(state_dir, scan_id, "--phase", "threat_model")write_completed_contract(scan_dir, scan_id, target)documents = {@@ -576,14 +559,7 @@ def test_invalid_model_or_binding_keeps_history_available_for_semantic_repair(target = tmp_path / "target"target.mkdir()saved = create_saved_workspace(state_dir, target)- started = start_delivered_scan(- state_dir,- "--workspace-id",- str(saved["id"]),- "--scan-root",- str(tmp_path / "scans"),- )["results"]- scan_id, scan_dir = str(started["scanId"]), Path(str(started["scanDir"]))+ scan_id, scan_dir = start_workspace_scan(state_dir, str(saved["id"]), tmp_path / "scans")write_completed_contract(scan_dir, scan_id, target)documents = {key: json.loads((scan_dir / filename).read_text())@@ -888,17 +864,7 @@ def test_completed_findings_are_returned_in_bounded_pages(tmp_path: Path) -> Nondef test_embedded_and_paged_findings_bound_large_stored_fields(tmp_path: Path) -> None:- state_dir = tmp_path / "state"- target = tmp_path / "target"- target.mkdir()- saved = create_saved_workspace(state_dir, target)- started = start_scan_command(- state_dir, str(saved["id"]), "--scan-root", str(tmp_path / "scans")- )- scan_id = str(started["results"]["scanId"])- scan_dir = Path(str(started["results"]["scanDir"]))- with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:- connection.execute("UPDATE scans SET handoff_status = 'delivered' WHERE id = ?", (scan_id,))+ state_dir, target, scan_id, scan_dir = empty_target_scan(tmp_path)write_completed_contract(scan_dir, scan_id, target)completed = scan_command(state_dir, "complete-scan", scan_id)["scan"]occurrence_id = completed["findings"][0]["occurrenceId"]@@ -1089,19 +1055,7 @@ def test_primary_location_prefers_root_control_in_bounded_and_csv_results(def test_csv_export_preserves_a_sealed_export(tmp_path: Path, workbench_api) -> None:- state_dir = tmp_path / "state"- target = tmp_path / "target"- target.mkdir()- saved = create_saved_workspace(state_dir, target)- started = start_delivered_scan(- state_dir,- "--workspace-id",- str(saved["id"]),- "--scan-root",- str(tmp_path / "scans"),- )["results"]- scan_id = str(started["scanId"])- scan_dir = Path(str(started["scanDir"]))+ state_dir, target, scan_id, scan_dir = empty_target_scan(tmp_path)write_completed_contract(scan_dir, scan_id, target)with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:connection.row_factory = sqlite3.Rowdiff --git a/plugins/codex-security/tests/test_workbench_deep_scan.py b/plugins/codex-security/tests/test_workbench_deep_scan.pyindex 38f47c999..b8693a481 100644--- a/plugins/codex-security/tests/test_workbench_deep_scan.py+++ b/plugins/codex-security/tests/test_workbench_deep_scan.py@@ -130,12 +130,12 @@ def upsert_worker(*,scan_id: str,worker_id: str,- kind: str,- status: str,+ kind: str = "discovery",+ status: str = "running",prompt_path: Path,artifact_dir: Path,result_path: Path | None = None,- attempt: int | None = None,+ attempt: int | None = 1,thread_id: str | None = None,error: str | None = None,replaceable_failure_kind: str | None = None,@@ -184,11 +184,8 @@ def dispatch_discovery_worker(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt_path,artifact_dir=artifact_dir,- attempt=1,coordinator_generation=coordinator_generation,)if succeed:@@ -198,12 +195,10 @@ def dispatch_discovery_worker(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="succeeded",prompt_path=prompt_path,artifact_dir=artifact_dir,result_path=result_path,- attempt=1,coordinator_generation=coordinator_generation,)return worker_id, prompt_path, artifact_dir, result_path@@ -242,10 +237,8 @@ def commit_reducer(scan_id=scan_id,worker_id=worker_id,kind="dedup",- status="running",prompt_path=prompt_path,artifact_dir=artifact_dir,- attempt=1,coordinator_generation=coordinator_generation,)write_canonical_artifacts(scan_dir)@@ -572,10 +565,8 @@ def test_expired_coordinator_recovers_reducer_publication_after_process_death(scan_id=scan_id,worker_id=reducer_id,kind="dedup",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,coordinator_generation=2,)canonical = write_canonical_artifacts(scan_dir)["candidateLedgerPath"]@@ -707,7 +698,6 @@ def test_expired_generation_preserves_receipts_and_recovers_abandoned_workers(status="failed",prompt_path=prompt,artifact_dir=artifacts,- attempt=1,error="fixture reducer failure",coordinator_generation=2,)@@ -789,11 +779,9 @@ def test_expired_generation_refunds_shutdown_canceled_discovery(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="canceled",prompt_path=prompt,artifact_dir=artifacts,- attempt=1,error=None if legacy else "coordinator_shutdown: mcp_transport_closed",coordinator_generation=coordinator_generation,)@@ -967,10 +955,8 @@ def test_reducer_commit_requires_safe_standard_canonical_artifacts(scan_id=scan_id,worker_id=reducer_id,kind="dedup",- status="running",prompt_path=prompt_path,artifact_dir=artifact_dir,- attempt=1,)canonical = write_canonical_artifacts(scan_dir)@@ -1081,22 +1067,16 @@ def test_scan_progress_projects_active_and_completed_independent_reviews(codex_home,scan_id=scan_id,worker_id=first_worker_id,- kind="discovery",- status="running",prompt_path=first_prompt,artifact_dir=first_artifacts,- attempt=1,)upsert_worker(state_dir,codex_home,scan_id=scan_id,worker_id=second_worker_id,- kind="discovery",- status="running",prompt_path=second_prompt,artifact_dir=second_artifacts,- attempt=1,)assert independent_reviews() == {"active": 2,@@ -1111,12 +1091,10 @@ def test_scan_progress_projects_active_and_completed_independent_reviews(codex_home,scan_id=scan_id,worker_id=first_worker_id,- kind="discovery",status="succeeded",prompt_path=first_prompt,artifact_dir=first_artifacts,result_path=first_result,- attempt=1,)assert independent_reviews() == {"active": 1,@@ -1130,11 +1108,9 @@ def test_scan_progress_projects_active_and_completed_independent_reviews(codex_home,scan_id=scan_id,worker_id=second_worker_id,- kind="discovery",status="canceled",prompt_path=second_prompt,artifact_dir=second_artifacts,- attempt=1,)assert independent_reviews() == {"active": 0,@@ -1578,11 +1554,8 @@ def test_replaceable_discovery_failures_count_once_and_reset_on_success(codex_home,scan_id=scan_id,worker_id=failed_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)for _ in range(2):@@ -1591,11 +1564,9 @@ def test_replaceable_discovery_failures_count_once_and_reset_on_success(codex_home,scan_id=scan_id,worker_id=failed_id,- kind="discovery",status="canceled",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,error="policy_refusal: request refused by cybersecurity policy",replaceable_failure_kind="policy_refusal",)["deepScan"]@@ -1694,11 +1665,9 @@ def test_failed_reducer_rebuffers_claimed_inputs_for_same_generation_replacementcodex_home,scan_id=scan_id,worker_id=discovery_failure,- kind="discovery",status="canceled",prompt_path=discovery_prompt,artifact_dir=discovery_dir,- attempt=1,error="transient_error: fixture discovery failure",replaceable_failure_kind="transient_error",coordinator_generation=2,@@ -1724,10 +1693,8 @@ def test_failed_reducer_rebuffers_claimed_inputs_for_same_generation_replacementscan_id=scan_id,worker_id=failed_reducer,kind="dedup",- status="running",prompt_path=failed_prompt,artifact_dir=failed_dir,- attempt=1,coordinator_generation=2,)@@ -1740,7 +1707,6 @@ def test_failed_reducer_rebuffers_claimed_inputs_for_same_generation_replacementstatus="failed",prompt_path=failed_prompt,artifact_dir=failed_dir,- attempt=1,error="fixture reducer exhausted its attempts",coordinator_generation=2,)["deepScan"]@@ -1781,7 +1747,6 @@ def test_failed_reducer_rebuffers_claimed_inputs_for_same_generation_replacementstatus="failed",prompt_path=failed_prompt,artifact_dir=failed_dir,- attempt=1,error="fixture reducer exhausted its attempts",coordinator_generation=2,)["deepScan"]@@ -1796,10 +1761,8 @@ def test_failed_reducer_rebuffers_claimed_inputs_for_same_generation_replacementscan_id=scan_id,worker_id=replacement_reducer,kind="dedup",- status="running",prompt_path=replacement_prompt,artifact_dir=replacement_dir,- attempt=1,coordinator_generation=2,)replacement_result.write_text("{}\n")@@ -1862,11 +1825,8 @@ def test_ordinary_discovery_cancellation_does_not_increment_failure_streak(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)result = upsert_worker(@@ -1874,11 +1834,9 @@ def test_ordinary_discovery_cancellation_does_not_increment_failure_streak(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="canceled",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)["deepScan"]assert result["consecutiveErrors"] == 0@@ -2253,9 +2211,9 @@ def test_app_scan_begin_validates_mode_and_owner(tmp_path: Path) -> None:scan_id=scan_id,worker_id=worker_id,kind="setup",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,+ attempt=None,)setup_complete = upsert_worker(state_dir,@@ -2266,6 +2224,7 @@ def test_app_scan_begin_validates_mode_and_owner(tmp_path: Path) -> None:status="succeeded",prompt_path=prompt,artifact_dir=artifact_dir,+ attempt=None,)assert setup_complete["deepScan"]["workers"][0]["status"] == "succeeded"@@ -2425,11 +2384,8 @@ def test_maximum_one_discovery_run_allows_hard_cap_singleton_reducer(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)result.write_text("{}\n")upsert_worker(@@ -2437,12 +2393,10 @@ def test_maximum_one_discovery_run_allows_hard_cap_singleton_reducer(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="succeeded",prompt_path=prompt,artifact_dir=artifact_dir,result_path=result,- attempt=1,)reducer_id = str(uuid.uuid4())reducer_prompt, reducer_dir, reducer_result = worker_paths(scan_dir, "singleton-reducer")@@ -2465,10 +2419,8 @@ def test_maximum_one_discovery_run_allows_hard_cap_singleton_reducer(scan_id=scan_id,worker_id=reducer_id,kind="dedup",- status="running",prompt_path=reducer_prompt,artifact_dir=reducer_dir,- attempt=1,)write_canonical_artifacts(scan_dir)reducer_result.write_text("{}\n")@@ -2500,10 +2452,8 @@ def test_maximum_one_discovery_run_allows_hard_cap_singleton_reducer(scan_id=scan_id,worker_id=failed_setup_id,kind="setup",- status="running",prompt_path=failed_setup_prompt,artifact_dir=failed_setup_dir,- attempt=1,)upsert_worker(state_dir,@@ -2514,7 +2464,6 @@ def test_maximum_one_discovery_run_allows_hard_cap_singleton_reducer(status="failed",prompt_path=failed_setup_prompt,artifact_dir=failed_setup_dir,- attempt=1,error="Setup failed.",)rejected = finish_deep_scan(@@ -2673,11 +2622,9 @@ def test_discovery_deadline_caps_without_a_completed_discovery(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="canceled",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)running = get_deep_scan(@@ -2792,22 +2739,17 @@ def test_capped_completion_requires_canonical_artifacts(tmp_path: Path) -> None:codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)upsert_worker(state_dir,codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="failed",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,error="Retries exhausted.",)manifest = scan_dir / "coordinator-manifest.json"@@ -2961,11 +2903,9 @@ def test_failure_capped_completion_preserves_partial_results_and_exact_omissionscodex_home,scan_id=scan_id,worker_id=failed_id,- kind="discovery",status="failed",prompt_path=failed_prompt,artifact_dir=failed_dir,- attempt=1,error="Worker retries exhausted.",)finish_args = (@@ -3048,11 +2988,8 @@ def test_late_worker_rejection_supersedes_stopped_checkpoint_finding(tmp_path: Pcodex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt_path,artifact_dir=artifact_dir,- attempt=1,)checkpoint = saved_draft(scan_id, completeness="partial", findings=[provisional])encoded = json.dumps(checkpoint).encode()@@ -3127,10 +3064,8 @@ def test_failure_capped_completion_recovers_canceled_reducer_inputs(tmp_path: Pascan_id=scan_id,worker_id=reducer_id,kind="dedup",- status="running",prompt_path=reducer_prompt,artifact_dir=reducer_dir,- attempt=1,)finish_args = ("finish-deep-scan",@@ -3157,7 +3092,6 @@ def test_failure_capped_completion_recovers_canceled_reducer_inputs(tmp_path: Pastatus="canceled",prompt_path=reducer_prompt,artifact_dir=reducer_dir,- attempt=1,)finished = run_workbench(state_dir, *finish_args, environment=deep_environment(codex_home))["deepScan"@@ -3271,6 +3205,7 @@ def test_saturated_completion_rejects_merging_workers(tmp_path: Path) -> None:status="canceled",prompt_path=reducer_prompt,artifact_dir=reducer_dir,+ attempt=None,)manifest = scan_dir / "coordinator-manifest.json"manifest.write_text("{}\n")@@ -3299,11 +3234,8 @@ def test_running_worker_updates_preserve_identity_and_dispatch_count(tmp_path: Pupdate = {"scan_id": scan_id,"worker_id": worker_id,- "kind": "discovery",- "status": "running","prompt_path": prompt,"artifact_dir": artifact_dir,- "attempt": 1,}initial = upsert_worker(state_dir, codex_home, **update)["deepScan"]@@ -3341,11 +3273,8 @@ def test_terminal_worker_updates_are_exact_idempotent_replays(tmp_path: Path) ->codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)result.write_text("{}\n")accepted = upsert_worker(@@ -3353,12 +3282,10 @@ def test_terminal_worker_updates_are_exact_idempotent_replays(tmp_path: Path) ->codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="succeeded",prompt_path=prompt,artifact_dir=artifact_dir,result_path=result,- attempt=1,)["deepScan"]accepted_worker = next(worker for worker in accepted["workers"] if worker["id"] == worker_id)replayed = upsert_worker(@@ -3366,12 +3293,10 @@ def test_terminal_worker_updates_are_exact_idempotent_replays(tmp_path: Path) ->codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="succeeded",prompt_path=prompt,artifact_dir=artifact_dir,result_path=result,- attempt=1,)["deepScan"]replayed_worker = next(worker for worker in replayed["workers"] if worker["id"] == worker_id)assert replayed_worker == accepted_worker@@ -3435,11 +3360,8 @@ def test_discovery_buffer_prefix_dedup_and_saturation_are_transactional(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)result.write_text("{}\n")accepted = upsert_worker(@@ -3447,12 +3369,10 @@ def test_discovery_buffer_prefix_dedup_and_saturation_are_transactional(codex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",status="succeeded",prompt_path=prompt,artifact_dir=artifact_dir,result_path=result,- attempt=1,)assert accepted["deepScan"]["workers"][-1]["mergeState"] == "buffered"@@ -3479,10 +3399,8 @@ def test_discovery_buffer_prefix_dedup_and_saturation_are_transactional(scan_id=scan_id,worker_id=reducer_id,kind="dedup",- status="running",prompt_path=reducer_prompt,artifact_dir=reducer_dir,- attempt=1,error="Transient reducer failure.",)write_canonical_artifacts(scan_dir)@@ -3528,10 +3446,8 @@ def test_discovery_buffer_prefix_dedup_and_saturation_are_transactional(scan_id=scan_id,worker_id=second_reducer_id,kind="dedup",- status="running",prompt_path=second_prompt,artifact_dir=second_dir,- attempt=1,)second_result.write_text("{}\n")late_worker_id, late_prompt, late_dir, late_result = dispatch_discovery_worker(@@ -3570,12 +3486,10 @@ def test_discovery_buffer_prefix_dedup_and_saturation_are_transactional(codex_home,scan_id=scan_id,worker_id=late_worker_id,- kind="discovery",status="succeeded",prompt_path=late_prompt,artifact_dir=late_dir,result_path=late_result,- attempt=1,)["deepScan"]accepted_late_worker = next(worker for worker in accepted_late["workers"] if worker["id"] == late_worker_id@@ -3765,11 +3679,8 @@ def test_cancel_scan_cancels_coordinator_and_active_workers(tmp_path: Path) -> Ncodex_home,scan_id=scan_id,worker_id=worker_id,- kind="discovery",- status="running",prompt_path=prompt,artifact_dir=artifact_dir,- attempt=1,)cancel_scan(state_dir, scan_id, "thread-deep-scan", environment=deep_environment(codex_home))diff --git a/plugins/codex-security/tests/test_workbench_feedback.py b/plugins/codex-security/tests/test_workbench_feedback.pyindex 4491ee29a..51360a4ed 100644--- a/plugins/codex-security/tests/test_workbench_feedback.py+++ b/plugins/codex-security/tests/test_workbench_feedback.py@@ -15,6 +15,7 @@ from workbench_test_support import (set_triage,stable_target_id,start_delivered_scan,+ start_workspace_scan,write_completed_contract,)@@ -44,9 +45,7 @@ def _complete_scan(*,anchors: tuple[str, ...] | None = None,) -> dict[str, Any]:- started = _start_scan(state_dir, workspace_id, scan_root)- scan_id = str(started["scanId"])- scan_dir = Path(str(started["scanDir"]))+ scan_id, scan_dir = start_workspace_scan(state_dir, workspace_id, scan_root)write_completed_contract(scan_dir, scan_id, target)if anchors is not None:findings_path = scan_dir / "findings.json"@@ -70,18 +69,10 @@ def _close_finding(close_reason: str,note: str | None = None,) -> dict[str, Any]:- arguments = [- "set-finding-triage",- "--occurrence-id",- occurrence_id,- "--status",- "closed",- "--close-reason",- close_reason,- ]+ arguments = ["--close-reason", close_reason]if note is not None:arguments.extend(("--note", note))- return run_workbench(state_dir, *arguments)["scan"]+ return set_triage(state_dir, occurrence_id, "closed", *arguments)["scan"]def _feedback(state_dir: Path, scan_id: str) -> dict[str, Any]:diff --git a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py b/plugins/codex-security/tests/test_workbench_setup_and_migrations.pyindex d3c548617..50ac33fe5 100644--- a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py+++ b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py@@ -24,6 +24,7 @@ from workbench_test_support import (create_saved_git_workspace,create_saved_workspace,create_workspace,+ empty_target_scan,get_scan,initialize_git_repository,load_script,@@ -452,11 +453,7 @@ def test_workbench_counts_scope_before_taking_sqlite_writer_lock(tmp_path: Path)assert started["results"]["progress"]["coverage"]["filesTotal"] == 1-def test_scan_start_rejects_dirty_initialized_submodule(tmp_path: Path) -> None:- state_dir = tmp_path / "state"- dependency = tmp_path / "dependency"- initialize_git_repository(dependency)- target = tmp_path / "target"+def initialize_git_repository_with_submodule(target: Path, dependency: Path) -> None:initialize_git_repository(target)subprocess.run([@@ -473,6 +470,14 @@ def test_scan_start_rejects_dirty_initialized_submodule(tmp_path: Path) -> None:check=True,)subprocess.run(["git", "commit", "-qam", "Add dependency"], cwd=target, check=True)+++def test_scan_start_rejects_dirty_initialized_submodule(tmp_path: Path) -> None:+ state_dir = tmp_path / "state"+ dependency = tmp_path / "dependency"+ initialize_git_repository(dependency)+ target = tmp_path / "target"+ initialize_git_repository_with_submodule(target, dependency)saved = create_saved_git_workspace(state_dir, target)(target / "vendor/dependency/README.md").write_text("dirty dependency\n")@@ -487,22 +492,7 @@ def test_scan_start_allows_uninitialized_submodule(tmp_path: Path) -> None:dependency = tmp_path / "dependency"initialize_git_repository(dependency)target = tmp_path / "target"- initialize_git_repository(target)- subprocess.run(- [- "git",- "-c",- "protocol.file.allow=always",- "submodule",- "add",- "-q",- str(dependency),- "vendor/dependency",- ],- cwd=target,- check=True,- )- subprocess.run(["git", "commit", "-qam", "Add dependency"], cwd=target, check=True)+ initialize_git_repository_with_submodule(target, dependency)subprocess.run(["git", "submodule", "deinit", "-f", "-q", "--", "vendor/dependency"],cwd=target,@@ -523,22 +513,7 @@ def test_scan_start_rejects_submodule_at_unrecorded_revision(tmp_path: Path) ->(dependency / "README.md").write_text("second revision\n")subprocess.run(["git", "commit", "-qam", "Second revision"], cwd=dependency, check=True)target = tmp_path / "target"- initialize_git_repository(target)- subprocess.run(- [- "git",- "-c",- "protocol.file.allow=always",- "submodule",- "add",- "-q",- str(dependency),- "vendor/dependency",- ],- cwd=target,- check=True,- )- subprocess.run(["git", "commit", "-qam", "Add dependency"], cwd=target, check=True)+ initialize_git_repository_with_submodule(target, dependency)submodule = target / "vendor/dependency"subprocess.run(["git", "checkout", "-q", revision_a], cwd=submodule, check=True)subprocess.run(@@ -567,9 +542,7 @@ def test_nested_target_name_is_a_literal_git_pathspec(tmp_path: Path) -> None:revision = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repository, text=True).strip()- workspace_id = str(uuid.uuid4())- create_workspace(state_dir, workspace_id, "--target-path", str(target))- save_workspace(state_dir, workspace_id, str(target), ".", "standard")+ workspace_id = str(create_saved_git_workspace(state_dir, target)["id"])scan_id, scan_dir = start_workspace_scan(state_dir, workspace_id, tmp_path / "scans")(repository / "outside.py").write_text("outside = 2\n")write_completed_contract(@@ -629,11 +602,7 @@ def test_workbench_serializes_concurrent_migrations(tmp_path: Path, upgrade: boodef test_workbench_retries_writer_admission_and_legacy_backfill(tmp_path: Path) -> None:- state_dir = tmp_path / "state"- target = tmp_path / "target"- target.mkdir()- workspace = create_saved_workspace(state_dir, target)- scan_id, scan_dir = start_workspace_scan(state_dir, str(workspace["id"]), tmp_path / "scans")+ state_dir, target, scan_id, scan_dir = empty_target_scan(tmp_path)write_completed_contract(scan_dir, scan_id, target)scan_command(state_dir, "complete-scan", scan_id)database = state_dir / "workbench.sqlite3"