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: move timestamp and database checks into Python suites (#1399)
mldangelo-oai015fd18c7750
diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.ymlindex a581b8a68..0fbe038d0 100644--- a/.github/workflows/node-ci.yml+++ b/.github/workflows/node-ci.yml@@ -368,19 +368,19 @@ jobs:include:- os: ubuntu-latestpython: "3.10"- tests: plugins/codex-security/tests+ markers: ""- os: ubuntu-latestpython: "3.12"- tests: plugins/codex-security/tests+ markers: ""- os: ubuntu-latestpython: "3.14"- tests: plugins/codex-security/tests+ markers: ""- os: macos-latestpython: "3.12"- tests: plugins/codex-security/tests/test_workbench_scan_usage.py+ markers: cross_platform or native_macos- os: windows-latestpython: "3.12"- tests: plugins/codex-security/tests/test_windows_scan_local_files.py+ markers: cross_platform or native_windowssteps:- name: Checkout repositoryuses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1@@ -428,8 +428,8 @@ jobs:- name: Test Python source contractsshell: bashenv:- PYTHON_TEST_PATH: ${{ matrix.tests }}- run: python -m pytest "$PYTHON_TEST_PATH" -q -n 4 --dist worksteal --max-worker-restart 0 --durations=30 --junitxml=reports/python.xml+ PYTEST_MARKERS: ${{ matrix.markers }}+ run: python -m pytest plugins/codex-security/tests -m "$PYTEST_MARKERS" -q -n 4 --dist worksteal --max-worker-restart 0 --durations=30 --junitxml=reports/python.xml- name: Require native platform coverageif: runner.os != 'Linux'run: python -c "import xml.etree.ElementTree as ET; assert not ET.parse('reports/python.xml').findall('.//testcase/skipped'), 'Native platform tests must run without skips'"diff --git a/plugins/codex-security/pyproject.toml b/plugins/codex-security/pyproject.tomlindex 501a11d31..78b428b31 100644--- a/plugins/codex-security/pyproject.toml+++ b/plugins/codex-security/pyproject.toml@@ -15,6 +15,11 @@ test = [[tool.pytest.ini_options]testpaths = ["tests"]+markers = [+ "cross_platform: source contracts exercised on Linux, macOS, and Windows",+ "native_macos: source contracts exercised by the native macOS job",+ "native_windows: source contracts exercised by the native Windows job",+][tool.ruff]line-length = 100diff --git a/plugins/codex-security/tests/test_finalize_scan_contract.py b/plugins/codex-security/tests/test_finalize_scan_contract.pyindex cbf4d619c..01479484a 100644--- a/plugins/codex-security/tests/test_finalize_scan_contract.py+++ b/plugins/codex-security/tests/test_finalize_scan_contract.py@@ -15,6 +15,7 @@ from datetime import datetime, timezonefrom pathlib import Pathfrom unittest import mock+import pytestfrom workbench_test_support import ScanFixtureTestCase, load_script, windows_file_backendFINALIZER = load_script("finalize_scan_contract")@@ -409,6 +410,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual(path.read_bytes(), compact)+ @pytest.mark.cross_platformdef test_sealed_rerun_accepts_legacy_unknown_evidence_references(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -438,6 +440,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_findings)+ @pytest.mark.cross_platformdef test_sealed_rerun_ignores_malformed_legacy_evidence_references(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -483,6 +486,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_findings)+ @pytest.mark.cross_platformdef test_sealed_rerun_ignores_non_string_legacy_validation_scalars(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -498,6 +502,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_findings)+ @pytest.mark.cross_platformdef test_sealed_rerun_accepts_formerly_free_form_finding_details(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -515,6 +520,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_findings)+ @pytest.mark.cross_platformdef test_sealed_rerun_ignores_blank_legacy_attack_path_details(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -537,6 +543,7 @@ The extraction root is not enforced.self.assertEqual(accepted, findings)self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_findings)+ @pytest.mark.cross_platformdef test_sealed_rerun_rejects_nullable_canonical_evidence_catalog(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -1606,6 +1613,7 @@ The extraction root is not enforced.self.assertIn("legacy validation evidence", report)self.assertIn("legacy data flow", report)+ @pytest.mark.cross_platformdef test_report_projection_preserves_data_flow_aliases_and_scalar_reachability(self) -> None:for data_flow_key in ("dataFlow", "data_flow", "dataflow"):with self.subTest(data_flow_key=data_flow_key):@@ -1622,6 +1630,7 @@ The extraction root is not enforced.self.assertIn("request -\\> filesystem write", report)self.assertIn("An authenticated uploader can reach extraction.", report)+ @pytest.mark.cross_platformdef test_report_projection_prefers_populated_data_flow_alias(self) -> None:findings = copy.deepcopy(self.findings)findings["findings"][0]["attackPath"] = {@@ -1674,6 +1683,7 @@ The extraction root is not enforced.):FINALIZER.finalize_scan(self.scan_dir)+ @pytest.mark.cross_platformdef test_finalize_rejects_unknown_nested_code_evidence_reference(self) -> None:finding = self.findings["findings"][0]finding["attackPath"] = {@@ -1689,6 +1699,7 @@ The extraction root is not enforced.):FINALIZER.finalize_scan(self.scan_dir)+ @pytest.mark.cross_platformdef test_finalize_accepts_nested_reference_to_legacy_code_evidence(self) -> None:finding = self.findings["findings"][0]finding["code_evidence"] = [@@ -1707,6 +1718,7 @@ The extraction root is not enforced.["legacy-source"],)+ @pytest.mark.cross_platformdef test_finalize_rejects_duplicate_ids_across_code_evidence_aliases(self) -> None:finding = self.findings["findings"][0]finding["codeEvidence"] = [@@ -1728,6 +1740,7 @@ The extraction root is not enforced.):FINALIZER.finalize_scan(self.scan_dir)+ @pytest.mark.cross_platformdef test_sealed_rerun_accepts_legacy_scalar_finding_details(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -1780,6 +1793,7 @@ The extraction root is not enforced.self.assertIsNone(accepted["findings"][0]["root_cause"])self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_bytes)+ @pytest.mark.cross_platformdef test_sealed_rerun_rejects_malformed_canonical_root_cause(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -1795,6 +1809,7 @@ The extraction root is not enforced.self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_bytes)+ @pytest.mark.cross_platformdef test_sealed_rerun_accepts_nullable_legacy_evidence_catalog(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -1819,6 +1834,7 @@ The extraction root is not enforced.self.assertEqual(accepted["findings"][0]["root_cause"], "")self.assertEqual((self.scan_dir / "findings.json").read_bytes(), sealed_bytes)+ @pytest.mark.cross_platformdef test_sealed_rerun_ignores_malformed_legacy_evidence_rows(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -1871,6 +1887,7 @@ The extraction root is not enforced.):FINALIZER.finalize_scan(self.scan_dir)+ @pytest.mark.cross_platformdef test_sealed_rerun_accepts_legacy_sequence_attack_path_details(self) -> None:self.write_sealed_scan()findings = self.read_json("findings.json")@@ -2193,6 +2210,7 @@ The extraction root is not enforced.self.assertEqual(warnings, ["Recovered finding 1: normalized severity change conditions."])self.assertEqual(prepared[4]["completeness"], "complete")+ @pytest.mark.cross_platformdef test_recovery_ranks_legacy_and_canonical_code_evidence_equally(self) -> None:canonical_evidence = {"id": "canonical-source",@@ -2231,6 +2249,7 @@ The extraction root is not enforced.))+ @pytest.mark.cross_platformdef test_recovery_ranks_embedded_root_cause_evidence(self) -> None:for name, root_cause in ((@@ -2764,6 +2783,7 @@ The extraction root is not enforced.)self.assertNotIn("relatedLocations", result)+ @pytest.mark.cross_platformdef test_sarif_includes_legacy_code_evidence_locations(self) -> None:sarif_finding = copy.deepcopy(self.finding)sarif_finding["findingId"] = "csf_example"@@ -2806,6 +2826,7 @@ The extraction root is not enforced.},)+ @pytest.mark.cross_platformdef test_sarif_normalizes_invalid_legacy_code_evidence_bounds(self) -> None:sarif_finding = copy.deepcopy(self.finding)sarif_finding["findingId"] = "csf_example"@@ -2847,6 +2868,7 @@ The extraction root is not enforced.self.assertEqual(regions["src/reversed_end.py"], {"startLine": 48, "endLine": 48})self.assertEqual(regions["src/text_end.py"], {"startLine": 59, "endLine": 59})+ @pytest.mark.cross_platformdef test_sarif_omits_invalid_legacy_code_evidence_locations(self) -> None:sarif_finding = copy.deepcopy(self.finding)sarif_finding["findingId"] = "csf_example"diff --git a/plugins/codex-security/tests/test_report_projection.py b/plugins/codex-security/tests/test_report_projection.pyindex d797ce326..070e41e8c 100644--- a/plugins/codex-security/tests/test_report_projection.py+++ b/plugins/codex-security/tests/test_report_projection.py@@ -5,6 +5,8 @@ import copyimport pytestfrom workbench_test_support import load_script+pytestmark = pytest.mark.cross_platform+PROJECTION = load_script("report_projection")diff --git a/plugins/codex-security/tests/test_windows_scan_local_files.py b/plugins/codex-security/tests/test_windows_scan_local_files.pyindex 7fde5aa2b..5a51c7ae1 100644--- a/plugins/codex-security/tests/test_windows_scan_local_files.py+++ b/plugins/codex-security/tests/test_windows_scan_local_files.py@@ -6,6 +6,8 @@ from pathlib import Pathimport pytestfrom workbench_test_support import load_script+pytestmark = pytest.mark.native_windows+WINDOWS_FILES = load_script("windows_scan_local_files")diff --git a/plugins/codex-security/tests/test_workbench_db.py b/plugins/codex-security/tests/test_workbench_db.pyindex 5b679d25c..2395caa7f 100644--- a/plugins/codex-security/tests/test_workbench_db.py+++ b/plugins/codex-security/tests/test_workbench_db.py@@ -4176,3 +4176,27 @@ def test_workbench_hides_missing_artifact_on_reopen(tmp_path: Path) -> None:reopened = run_workbench(state_dir, "get-scan", "--scan-id", scan_id)assert reopened["scan"]["reportAvailable"] is Falseassert "markdownReport" not in reopened["scan"]["artifacts"]++[email protected]_platform+def test_large_patch_preview_preserves_digest_checks(+ tmp_path: Path, capfd: pytest.CaptureFixture[str]+) -> None:+ namespace = runpy.run_path(str(SCRIPT), run_name="codex_security_workbench_db")+ patch = b"diff --git a/src.ts b/src.ts\n+" + b"x" * (2 * 1024 * 1024) + b"\n"+ (tmp_path / "remediation.patch").write_bytes(patch)+ digest = f"sha256:{hashlib.sha256(patch).hexdigest()}"+ scan = {"scan_dir": str(tmp_path)}+ namespace["require_matching_patch_digest"](scan, "remediation.patch", digest)+ preview, stats = namespace["patch_artifact_preview"](tmp_path, "remediation.patch", digest)+ assert preview.startswith("diff --git a/src.ts b/src.ts\n+")+ assert preview.endswith("... patch preview truncated ...")+ assert stats["additions"] == 1+ assert stats["fileCount"] == 1+ assert stats["previewTruncated"] is True+ with pytest.raises(SystemExit) as mismatch:+ namespace["require_matching_patch_digest"](scan, "remediation.patch", f"sha256:{'0' * 64}")+ assert str(mismatch.value) == "Patch digest does not match the scan-local patch file."+ captured = capfd.readouterr()+ assert captured.out.removeprefix("\ufeff").strip(" \t\r\n") == ""+ assert captured.err.removeprefix("\ufeff") == ""diff --git a/plugins/codex-security/tests/test_workbench_scan_usage.py b/plugins/codex-security/tests/test_workbench_scan_usage.pyindex 7d76b3cad..f7db562dc 100644--- a/plugins/codex-security/tests/test_workbench_scan_usage.py+++ b/plugins/codex-security/tests/test_workbench_scan_usage.py@@ -21,6 +21,8 @@ from workbench_test_support import (write_completed_contract,)+pytestmark = pytest.mark.native_macos+@dataclass(frozen=True)class ScanFixture:diff --git a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py b/plugins/codex-security/tests/test_workbench_setup_and_migrations.pyindex 1adafa983..79d9ee897 100644--- a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py+++ b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py@@ -9,9 +9,11 @@ import sqlite3import subprocessimport sysimport uuid+from collections.abc import Iterablefrom concurrent.futures import ThreadPoolExecutorfrom pathlib import Pathfrom threading import Timer+from typing import Anyfrom unittest import mockimport pytest@@ -73,6 +75,21 @@ EXPECTED_MIGRATIONS = []+def apply_historical_migrations(+ connection: sqlite3.Connection,+ namespace: dict[str, Any],+ migrations: Iterable[tuple[int, str, str]],+ timestamp: str,+) -> None:+ for version, name, sql in migrations:+ for statement in namespace["sql_statements"](sql):+ connection.execute(statement)+ connection.execute(+ "INSERT INTO schema_migrations (version, name, applied_at) VALUES (?, ?, ?)",+ (version, name, timestamp),+ )++def test_sqlite_snapshot_includes_uncheckpointed_wal_rows(tmp_path: Path) -> None:source = tmp_path / "source.sqlite3"snapshot = tmp_path / "snapshot.sqlite3"@@ -840,6 +857,7 @@ def test_workbench_repairs_recorded_deep_scan_failure_counter_migration(}[email protected]_platform@pytest.mark.parametrize("migration_recorded", (False, True))def test_deep_scan_time_limit_migration_backfills_and_repairs_existing_runs(migration_recorded: bool,@@ -2286,6 +2304,7 @@ def test_workbench_preserves_diff_target_summary_on_scan(tmp_path: Path) -> None)[email protected]_platformdef test_workbench_upgrades_public_cli_completion_warning_migration() -> None:namespace = runpy.run_path(str(SCRIPT), run_name="codex_security_workbench_db")apply_migrations = namespace["apply_migrations"]@@ -2681,3 +2700,80 @@ def test_workbench_rejects_unknown_execution_profile_migration_without_mutating_scan_columns = {row["name"] for row in connection.execute("PRAGMA table_info(scans)")}assert {"execution_model", "reasoning_effort"}.issubset(scan_columns)assert "legacy_execution_model" not in scan_columns++[email protected]_platform+ ("profile_migration", "follow_up_migration", "supported"),+ (+ ("scan execution profiles", "scan continuation threads", True),+ ("scan execution profiles", "phase-specific scan progress", True),+ ("unknown execution profile migration", "scan continuation threads", False),+ ),+)+def test_workbench_reconciles_profile_and_public_warning_histories(+ tmp_path: Path, profile_migration: str, follow_up_migration: str, supported: bool+) -> None:+ state_dir = tmp_path / "state"+ state_dir.mkdir()+ database = state_dir / "workbench.sqlite3"+ namespace = runpy.run_path(str(SCRIPT), run_name="codex_security_workbench_schema")+ timestamp = "2026-07-30T00:00:00Z"+ with sqlite3.connect(database) as connection:+ connection.execute(+ "CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, "+ "name TEXT NOT NULL, applied_at TEXT NOT NULL)"+ )+ apply_historical_migrations(connection, namespace, namespace["MIGRATIONS"][:10], timestamp)+ for table in ("workspaces", "scans"):+ connection.execute(f"ALTER TABLE {table} ADD COLUMN execution_model TEXT")+ connection.execute(f"ALTER TABLE {table} ADD COLUMN reasoning_effort TEXT")+ follow_up = next(item for item in namespace["MIGRATIONS"] if item[1] == follow_up_migration)+ for statement in namespace["sql_statements"](follow_up[2]):+ connection.execute(statement)+ connection.executemany(+ "INSERT INTO schema_migrations VALUES (?, ?, ?)",+ ((11, profile_migration, timestamp), (12, follow_up_migration, timestamp)),+ )+ connection.execute(+ "ALTER TABLE scans ADD COLUMN completion_warnings_json TEXT NOT NULL DEFAULT '[]'"+ )+ connection.execute(+ "INSERT INTO schema_migrations VALUES (?, ?, ?)",+ (25, "persist scan completion warnings", timestamp),+ )++ upgrade = run_workbench(state_dir, "database-info", check=False)+ assert upgrade["returncode"] == (0 if supported else 1)+ if not supported:+ assert "unsupported execution-profile migration history" in upgrade["stderr"]++ with sqlite3.connect(database) as connection:+ migrations = dict(+ connection.execute(+ "SELECT version, name FROM schema_migrations WHERE version IN (11, 12, 20, 25, 26)"+ )+ )+ assert migrations == (+ {+ 11: "deep scan orchestration state",+ 12: "scan continuation threads",+ 20: "phase-specific scan progress",+ 25: "persist scan model settings",+ 26: "persist scan completion warnings",+ }+ if supported+ else {+ 11: profile_migration,+ 12: follow_up_migration,+ 25: "persist scan completion warnings",+ }+ )+ columns = {row[1] for row in connection.execute("PRAGMA table_info(scans)")}+ assert ("legacy_execution_model" in columns) is supported+ assert (+ connection.execute(+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'deep_scan_runs'"+ ).fetchone()+ is not None+ ) is supporteddiff --git a/plugins/codex-security/tests/test_workbench_timestamps.py b/plugins/codex-security/tests/test_workbench_timestamps.pyindex ca2e8ecc4..5bd9097b6 100644--- a/plugins/codex-security/tests/test_workbench_timestamps.py+++ b/plugins/codex-security/tests/test_workbench_timestamps.py@@ -9,11 +9,13 @@ from types import SimpleNamespaceimport pytest+pytestmark = pytest.mark.cross_platform+class Python310DateTime(datetime):@classmethoddef fromisoformat(cls, value: str) -> datetime:- if value.endswith(("Z", "z")):+ if isinstance(value, str) and value.endswith(("Z", "z")):raise ValueError("Python 3.10 rejects Z-suffixed timestamps")return datetime.fromisoformat(value)@@ -49,24 +51,72 @@ def test_remediation_leases_on_python310(monkeypatch, fields, active) -> None:assert remediation.remediation_claim_is_active(claim) is active-def test_deep_scan_deadline_and_heartbeat_on_python310(monkeypatch, tmp_path: Path) -> None:+ ("created_at", "timestamp", "reached"),+ [+ ("2026-08-15T00:00:00Z", "2026-08-15T00:59:59Z", False),+ ("2026-08-15T00:00:00Z", "2026-08-15T01:00:00Z", True),+ ("2026-08-15T00:00:00z", "2026-08-15T01:00:00z", True),+ ("2026-08-15T02:00:00+02:00", "2026-08-15T01:00:00Z", True),+ ],+)+def test_deep_scan_deadlines_on_python310(monkeypatch, created_at, timestamp, reached) -> None:monkeypatch.syspath_prepend(str(Path(__file__).resolve().parents[1] / "scripts"))deep = importlib.import_module("deep_scan_workbench")monkeypatch.setattr(deep, "datetime", Python310DateTime)- monkeypatch.setattr(deep, "_dependencies", SimpleNamespace(now=lambda: "2026-08-15T12:00:00Z"))- assert deep.deep_scan_deadline_reached(- {"created_at": "2026-08-15T11:00:00z", "max_time_hours": 1}+ monkeypatch.setattr(deep, "_dependencies", SimpleNamespace(now=lambda: timestamp))+ assert (+ deep.deep_scan_deadline_reached({"created_at": created_at, "max_time_hours": 1}) is reached)- heartbeat = tmp_path / "artifacts/deep_discovery/coordinator-heartbeat-2.json"- heartbeat.parent.mkdir(parents=True)- heartbeat.write_text(- json.dumps({"coordinatorGeneration": 2, "updatedAt": "2026-08-15T11:59:45z"})- )- run = {"coordinator_generation": 2, "updated_at": "2026-08-15T11:00:00Z"}- with sqlite3.connect(":memory:") as connection:- assert deep.coordinator_lease_is_live(- connection, run, {"scan_dir": str(tmp_path)}, "2026-08-15T12:00:00Z"+++ ("generation", "updated_at", "heartbeat", "timestamp", "live"),+ [+ (1, "00:09:59Z", None, "00:10:00Z", True),+ (1, "00:08:00Z", None, "00:10:00Z", False),+ (2, "00:09:59Z", None, "00:10:00Z", True),+ (2, "00:09:30Z", None, "00:10:00Z", False),+ (2, "00:09:00Z", (2, "00:09:45Z"), "00:10:00Z", True),+ (2, "00:09:00Z", (1, "00:09:45Z"), "00:10:00Z", False),+ (2, "00:09:00Z", (2, None), "00:10:00Z", False),+ (2, "11:00:00Z", (2, "11:59:45z"), "12:00:00Z", True),+ (2, "11:00:00Z", (2, "11:59:45z"), "12:00:15Z", False),+ ],+)+def test_deep_scan_coordinator_leases_on_python310(+ monkeypatch, tmp_path: Path, generation, updated_at, heartbeat, timestamp, live+) -> None:+ monkeypatch.syspath_prepend(str(Path(__file__).resolve().parents[1] / "scripts"))+ deep = importlib.import_module("deep_scan_workbench")+ monkeypatch.setattr(deep, "datetime", Python310DateTime)+ run = {+ "scan_id": "scan",+ "coordinator_generation": generation,+ "updated_at": f"2026-08-15T{updated_at}",+ }+ if heartbeat is not None:+ heartbeat_generation, heartbeat_time = heartbeat+ heartbeat_path = (+ tmp_path / f"artifacts/deep_discovery/coordinator-heartbeat-{generation}.json")- assert not deep.coordinator_lease_is_live(- connection, run, {"scan_dir": str(tmp_path)}, "2026-08-15T12:00:15Z"+ heartbeat_path.parent.mkdir(parents=True)+ heartbeat_path.write_text(+ json.dumps(+ {+ "coordinatorGeneration": heartbeat_generation,+ "updatedAt": None if heartbeat_time is None else f"2026-08-15T{heartbeat_time}",+ }+ ),+ encoding="utf-8",+ )+ with sqlite3.connect(":memory:") as connection:+ connection.execute("CREATE TABLE deep_scan_workers (scan_id TEXT, status TEXT)")+ if generation == 1:+ connection.execute("INSERT INTO deep_scan_workers VALUES ('scan', 'running')")+ assert (+ deep.coordinator_lease_is_live(+ connection, run, {"scan_dir": str(tmp_path)}, f"2026-08-15T{timestamp}"+ )+ is live)diff --git a/sdk/typescript/scripts/ci-test-durations.json b/sdk/typescript/scripts/ci-test-durations.jsonindex e41fd1871..8ce13c631 100644--- a/sdk/typescript/scripts/ci-test-durations.json+++ b/sdk/typescript/scripts/ci-test-durations.json@@ -80,7 +80,6 @@"deep-review-input.test.ts": 15.767,"deep-scan-parent-denials.test.ts": 0.048,"deep-scan-reducer-recovery.test.ts": 0.407,- "deep-scan-timestamp-compat.test.ts": 1.27,"deep-scan-windows-executable.test.ts": 0.033,"deep-scan-workbench.test.ts": 27.622,"deep-scan-worker-shutdown.test.ts": 0.019,@@ -167,9 +166,7 @@"update-notice.test.ts": 0.125,"workbench-canonical-paths.test.ts": 0.873,"workbench-nested-git-utf8.test.ts": 0.154,- "workbench-patch.test.ts": 0.822,"workbench-progress.test.ts": 1.183,- "workbench-remediation-timestamp.test.ts": 1.512,"workbench-scan-history.test.ts": 3.351,"workbench-scan-root-alias.test.ts": 0.0,"workbench-windows-compatibility.test.ts": 0.939,@@ -251,7 +248,6 @@"deep-review-input.test.ts": 15.492,"deep-scan-parent-denials.test.ts": 0.034,"deep-scan-reducer-recovery.test.ts": 0.544,- "deep-scan-timestamp-compat.test.ts": 2.083,"deep-scan-windows-executable.test.ts": 0.033,"deep-scan-workbench.test.ts": 29.766,"deep-scan-worker-shutdown.test.ts": 0.024,@@ -338,9 +334,7 @@"update-notice.test.ts": 0.034,"workbench-canonical-paths.test.ts": 4.027,"workbench-nested-git-utf8.test.ts": 1.221,- "workbench-patch.test.ts": 0.291,"workbench-progress.test.ts": 0.807,- "workbench-remediation-timestamp.test.ts": 1.303,"workbench-scan-history.test.ts": 4.08,"workbench-scan-root-alias.test.ts": 0.298,"workbench-windows-compatibility.test.ts": 1.935,diff --git a/sdk/typescript/tests-ts/build-plugin.test.ts b/sdk/typescript/tests-ts/build-plugin.test.tsindex 02eb832f7..2f9d58dfc 100644--- a/sdk/typescript/tests-ts/build-plugin.test.ts+++ b/sdk/typescript/tests-ts/build-plugin.test.ts@@ -17,6 +17,7 @@ import { afterEach, describe, expect, test } from "bun:test";import { buildBundledPlugin } from "../scripts/build-plugin.mjs";import { assertGeneratedPluginUntracked } from "../scripts/check-plugin-source.mjs";+import { PLUGIN_ROOT } from "./plugin-root.js";import { createTemporaryDirectories } from "./support/temporary-directories.js";const temporaryDirectories = createTemporaryDirectories(false);@@ -62,6 +63,25 @@ async function snapshot(root: string) {afterEach(temporaryDirectories.cleanup);describe("bundled plugin build", () => {+ test("copies Python contracts and completed examples unchanged from source", async () => {+ const source = fileURLToPath(+ new URL("../../../plugins/codex-security/", import.meta.url),+ );+ const contract = JSON.parse(+ await readFile(join(source, "plugin-files.json"), "utf8"),+ ) as { shippedExact: string[] };+ for (const path of contract.shippedExact.filter(+ (path) =>+ (path.startsWith("scripts/") && path.endsWith(".py")) ||+ path.startsWith("schemas/") ||+ path.startsWith("examples/completed-scan/"),+ )) {+ expect(await readFile(join(PLUGIN_ROOT, path)), path).toEqual(+ await readFile(join(source, path)),+ );+ }+ });+test.each(["missing", "stale"])("builds the MCP runtime from source with %s native wrappers and no npm launcher",async (emitted) => {diff --git a/sdk/typescript/tests-ts/deep-scan-timestamp-compat.test.ts b/sdk/typescript/tests-ts/deep-scan-timestamp-compat.test.tsdeleted file mode 100644index a3810901d..000000000--- a/sdk/typescript/tests-ts/deep-scan-timestamp-compat.test.ts+++ /dev/null@@ -1,131 +0,0 @@-import { describe, expect, test } from "bun:test";-import { runPythonJsonProbe } from "./support/python-probe.js";--const timestampProbe = `-import json, sqlite3, sys, tempfile-from datetime import datetime as native_datetime-from pathlib import Path-sys.path.insert(0, sys.argv[1])-import deep_scan_workbench as deep_scan--class Python310Datetime:- @staticmethod- def fromisoformat(value):- if isinstance(value, str) and value.endswith(("Z", "z")):- raise ValueError("Python 3.10 rejects Z-suffixed timestamps")- return native_datetime.fromisoformat(value)--if sys.version_info >= (3, 11):- deep_scan.datetime = Python310Datetime-case = json.loads(sys.argv[2])-deep_scan.now = lambda: case["now"]-deep_scan.configure(deep_scan)-connection = sqlite3.connect(":memory:")-connection.execute("CREATE TABLE deep_scan_workers (scan_id TEXT, status TEXT)")-if case.get("activeWorker"):- connection.execute("INSERT INTO deep_scan_workers VALUES ('scan', 'running')")-run = {- "scan_id": "scan",- "created_at": case.get("createdAt"),- "updated_at": case.get("updatedAt"),- "max_time_hours": case.get("maxTimeHours"),- "coordinator_generation": case.get("generation", 1),-}-with tempfile.TemporaryDirectory() as scan_dir:- if "heartbeat" in case:- heartbeat_path = Path(scan_dir) / "artifacts" / "deep_discovery" / f"coordinator-heartbeat-{run['coordinator_generation']}.json"- heartbeat_path.parent.mkdir(parents=True)- heartbeat_path.write_text(json.dumps(case["heartbeat"]), encoding="utf-8")- if case["operation"] == "deadline":- result = deep_scan.deep_scan_deadline_reached(run)- else:- result = deep_scan.coordinator_lease_is_live(connection, run, {"scan_dir": scan_dir}, case["now"])- print(json.dumps(result))-`;--interface TimestampProbe {- operation: "deadline" | "coordinator";- now: string;- createdAt?: string;- updatedAt?: string;- maxTimeHours?: number;- generation?: number;- activeWorker?: boolean;- heartbeat?: { coordinatorGeneration: number; updatedAt: unknown };-}--function runTimestampProbe(probe: TimestampProbe): boolean {- return runPythonJsonProbe(timestampProbe, probe) as boolean;-}--describe("Python 3.10 Deep Scan timestamps", () => {- test.each([- [- "before the deadline",- "2026-08-15T00:00:00Z",- "2026-08-15T00:59:59Z",- false,- ],- ["at the deadline", "2026-08-15T00:00:00Z", "2026-08-15T01:00:00Z", true],- [- "with lowercase UTC suffixes",- "2026-08-15T00:00:00z",- "2026-08-15T01:00:00z",- true,- ],- [- "with explicit UTC offsets",- "2026-08-15T02:00:00+02:00",- "2026-08-15T01:00:00Z",- true,- ],- ] as const)("evaluates timestamps %s", (_label, createdAt, now, reached) => {- expect(- runTimestampProbe({- operation: "deadline",- createdAt,- maxTimeHours: 1,- now,- }),- ).toBe(reached);- });-- test.each([- ["fresh legacy", 1, "2026-08-15T00:09:59Z", true],- ["expired legacy", 1, "2026-08-15T00:08:00Z", false],- ["fresh current", 2, "2026-08-15T00:09:59Z", true],- ["expired current", 2, "2026-08-15T00:09:30Z", false],- ] as const)(- "evaluates %s coordinator leases",- (_label, generation, updatedAt, live) => {- expect(- runTimestampProbe({- operation: "coordinator",- generation,- activeWorker: generation === 1,- updatedAt,- now: "2026-08-15T00:10:00Z",- }),- ).toBe(live);- },- );-- test.each([- ["current", 2, "2026-08-15T00:09:45Z", true],- ["older generation", 1, "2026-08-15T00:09:45Z", false],- ["invalid", 2, null, false],- ] as const)(- "uses the %s coordinator heartbeat",- (_label, coordinatorGeneration, updatedAt, live) => {- expect(- runTimestampProbe({- operation: "coordinator",- generation: 2,- updatedAt: "2026-08-15T00:09:00Z",- now: "2026-08-15T00:10:00Z",- heartbeat: { coordinatorGeneration, updatedAt },- }),- ).toBe(live);- },- );-});diff --git a/sdk/typescript/tests-ts/deep-scan-workbench.test.ts b/sdk/typescript/tests-ts/deep-scan-workbench.test.tsindex 3dd034383..b05aebea8 100644--- a/sdk/typescript/tests-ts/deep-scan-workbench.test.ts+++ b/sdk/typescript/tests-ts/deep-scan-workbench.test.ts@@ -441,52 +441,6 @@ describe("deep scan workbench ownership", () => {}});- test.each([false, true] as const)(- "backfills and repairs discovery deadline migration when already recorded: %p",- (migrationRecorded) => {- const python = Bun.which("python3") ?? Bun.which("python");- expect(python).not.toBeNull();- const script = [- "import json, runpy, sqlite3, sys",- "from unittest import mock",- "namespace = runpy.run_path(sys.argv[1], run_name='codex_security_workbench_db')",- "apply_migrations = namespace['apply_migrations']",- "connection = sqlite3.connect(':memory:')",- "connection.row_factory = sqlite3.Row",- "historical = tuple(item for item in namespace['MIGRATIONS'] if item[0] < 28)",- "with mock.patch.dict(apply_migrations.__globals__, {'MIGRATIONS': historical}):",- " apply_migrations(connection)",- "timestamp = '2026-07-01T00:00:00Z'",- "connection.execute('INSERT INTO workspaces (id, created_at, updated_at) VALUES (?, ?, ?)', ('legacy-workspace', timestamp, timestamp))",- "connection.execute(\"INSERT INTO scans (id, workspace_id, target_path, target_revision, scope, mode, scan_dir, status, phase, started_at, created_at, updated_at) VALUES (?, ?, '/legacy/target', 'legacy-revision', '.', 'deep', '/legacy/scan', 'running', 'discovery', ?, ?, ?)\", ('legacy-scan', 'legacy-workspace', timestamp, timestamp, timestamp))",- "connection.execute(\"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 (?, 1, 'legacy-workflow', 'running', 'discovery', 1, 0, 3, 10, ?, ?)\", ('legacy-scan', timestamp, timestamp))",- "if sys.argv[2] == 'true':",- " connection.execute('INSERT INTO schema_migrations (version, name, applied_at) VALUES (28, ?, ?)', ('persist deep scan discovery time limit', timestamp))",- "connection.commit()",- "apply_migrations(connection)",- "default = connection.execute('SELECT max_time_hours FROM deep_scan_runs').fetchone()[0]",- "connection.execute('UPDATE deep_scan_runs SET max_time_hours = 2.5')",- "connection.commit()",- "apply_migrations(connection)",- "configured = connection.execute('SELECT max_time_hours FROM deep_scan_runs').fetchone()[0]",- "migration = connection.execute('SELECT name FROM schema_migrations WHERE version = 28').fetchone()[0]",- "print(json.dumps({'default': default, 'configured': configured, 'migration': migration}))",- ].join("\n");- const result = runPython(python!, [- "-c",- script,- join(PLUGIN_ROOT, "scripts", "workbench_db.py"),- String(migrationRecorded),- ]);- expect(result.exitCode, new TextDecoder().decode(result.stderr)).toBe(0);- expect(JSON.parse(new TextDecoder().decode(result.stdout))).toEqual({- default: 96,- configured: 2.5,- migration: "persist deep scan discovery time limit",- });- },- );-test.each([["repository", false],["scoped_path", false],diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.tsindex 486d092ee..4a14f125a 100644--- a/sdk/typescript/tests-ts/runtime.test.ts+++ b/sdk/typescript/tests-ts/runtime.test.ts@@ -5168,249 +5168,6 @@ describe("runtime directories and plugin Python boundary", () => {});});- test.each([- [- "released continuation v12",- "scan execution profiles",- "scan continuation threads",- true,- ],- [- "historical phase-progress v12",- "scan execution profiles",- "phase-specific scan progress",- true,- ],- [- "unknown v11 plus released continuation v12",- "unknown execution profile migration",- "scan continuation threads",- false,- ],- ] as const)(- "reconciles %s without corrupting migration history",- async (_history, profileMigration, followUpMigration, supportedHistory) => {- const root = await temporaryDirectory(- "codex-security-migration-history-",- );- const stateDirectory = join(root, "state");- await mkdir(stateDirectory);- const database = join(stateDirectory, "workbench.sqlite3");- const python = Bun.which("python3") ?? Bun.which("python");- expect(python).not.toBeNull();-- const fixture = spawnSync(- python!,- [- "-I",- "-B",- "-c",- [- "import sqlite3, sys",- "sys.path.insert(0, sys.argv[1])",- "from workbench_schema import MIGRATIONS, sql_statements",- "connection = sqlite3.connect(sys.argv[2])",- "connection.execute('CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, name TEXT NOT NULL, applied_at TEXT NOT NULL)')",- "timestamp = '2026-07-30T00:00:00Z'",- "for version, name, migration in MIGRATIONS:",- " if version > 10: break",- " for statement in sql_statements(migration): connection.execute(statement)",- " connection.execute('INSERT INTO schema_migrations VALUES (?, ?, ?)', (version, name, timestamp))",- "for table in ('workspaces', 'scans'):",- " connection.execute(f'ALTER TABLE {table} ADD COLUMN execution_model TEXT')",- " connection.execute(f'ALTER TABLE {table} ADD COLUMN reasoning_effort TEXT')",- "follow_up = next(item for item in MIGRATIONS if item[1] == sys.argv[4])",- "for statement in sql_statements(follow_up[2]): connection.execute(statement)",- "connection.executemany('INSERT INTO schema_migrations VALUES (?, ?, ?)', [(11, sys.argv[3], timestamp), (12, sys.argv[4], timestamp)])",- "connection.execute(\"ALTER TABLE scans ADD COLUMN completion_warnings_json TEXT NOT NULL DEFAULT '[]'\")",- "connection.execute('INSERT INTO schema_migrations VALUES (?, ?, ?)', (25, 'persist scan completion warnings', timestamp))",- "connection.commit()",- "connection.close()",- ].join("\n"),- join(PLUGIN_ROOT, "scripts"),- database,- profileMigration,- followUpMigration,- ],- { encoding: "utf8" },- );- expect(fixture.status).toBe(0);- expect(fixture.stderr).toBe("");-- const upgrade = spawnSync(- python!,- [- "-I",- "-B",- join(PLUGIN_ROOT, "scripts", "workbench_db.py"),- "database-info",- ],- {- encoding: "utf8",- env: {- ...process.env,- CODEX_SECURITY_STATE_DIR: stateDirectory,- },- },- );- expect(upgrade.status).toBe(supportedHistory ? 0 : 1);- if (!supportedHistory) {- expect(upgrade.stderr).toContain(- "unsupported execution-profile migration history",- );- }-- const inspected = spawnSync(- python!,- [- "-I",- "-B",- "-c",- [- "import json, sqlite3, sys",- "connection = sqlite3.connect(sys.argv[1])",- "connection.row_factory = sqlite3.Row",- "migrations = {row['version']: row['name'] for row in connection.execute('SELECT version, name FROM schema_migrations WHERE version IN (11, 12, 20, 25, 26)')}",- "columns = {row['name'] for row in connection.execute('PRAGMA table_info(scans)')}",- "deep_scan_tables = connection.execute(\"SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'deep_scan_runs'\").fetchone()",- "print(json.dumps({'migrations': migrations, 'legacyColumnsRenamed': 'legacy_execution_model' in columns, 'deepScanTables': deep_scan_tables is not None}))",- ].join("\n"),- database,- ],- { encoding: "utf8" },- );- expect(inspected.status).toBe(0);- expect(inspected.stderr).toBe("");- if (!supportedHistory) {- expect(JSON.parse(inspected.stdout)).toEqual({- migrations: {- "11": "unknown execution profile migration",- "12": "scan continuation threads",- "25": "persist scan completion warnings",- },- legacyColumnsRenamed: false,- deepScanTables: false,- });- return;- }-- expect(JSON.parse(inspected.stdout)).toEqual({- migrations: {- "11": "deep scan orchestration state",- "12": "scan continuation threads",- "20": "phase-specific scan progress",- "25": "persist scan model settings",- "26": "persist scan completion warnings",- },- legacyColumnsRenamed: true,- deepScanTables: true,- });- },- );-- test("aligns an existing public CLI database with the maintained plugin schema", async () => {- const root = await temporaryDirectory("codex-security-public-migrations-");- const repository = join(root, "repository");- const stateDirectory = join(root, "state");- const scanDirectory = join(root, "scan");- await mkdir(repository);- await mkdir(stateDirectory);- await mkdir(scanDirectory, { mode: 0o700 });-- const python = Bun.which("python3") ?? Bun.which("python");- expect(python).not.toBeNull();- const fixture = spawnSync(- python!,- [- "-I",- "-B",- "-c",- [- "import sqlite3, sys",- "from pathlib import Path",- "sys.path.insert(0, sys.argv[1])",- "from workbench_schema import MIGRATIONS, sql_statements",- "repository = Path(sys.argv[2])",- "connection = sqlite3.connect(Path(sys.argv[3]) / 'workbench.sqlite3')",- "connection.execute('CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, name TEXT NOT NULL, applied_at TEXT NOT NULL)')",- "timestamp = '2026-07-30T00:00:00Z'",- "for version, name, migration in MIGRATIONS:",- " if version > 24: break",- " for statement in sql_statements(migration): connection.execute(statement)",- " connection.execute('INSERT INTO schema_migrations VALUES (?, ?, ?)', (version, name, timestamp))",- "connection.execute(\"ALTER TABLE scans ADD COLUMN completion_warnings_json TEXT NOT NULL DEFAULT '[]'\")",- "connection.execute('INSERT INTO schema_migrations VALUES (?, ?, ?)', (25, 'persist scan completion warnings', timestamp))",- "connection.execute('INSERT INTO workspaces (id, target_path, created_at, updated_at) VALUES (?, ?, ?, ?)', ('legacy-workspace', str(repository), timestamp, timestamp))",- "connection.execute('INSERT INTO scans (id, workspace_id, target_path, target_revision, scope, mode, scan_dir, status, phase, started_at, created_at, updated_at, completion_warnings_json) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', ('legacy-scan', 'legacy-workspace', str(repository), 'legacy-revision', '.', 'standard', str(repository / 'legacy-scan'), 'complete', 'reporting', timestamp, timestamp, timestamp, '[\"existing warning\"]'))",- "connection.commit()",- "connection.close()",- ].join("\n"),- join(PLUGIN_ROOT, "scripts"),- repository,- stateDirectory,- ],- { encoding: "utf8" },- );- expect(fixture.status).toBe(0);- expect(fixture.stderr).toBe("");-- const registration = await runWorkbench(- {- python: python!,- pluginRoot: PLUGIN_ROOT,- environment: {- PATH: process.env["PATH"],- CODEX_SECURITY_STATE_DIR: stateDirectory,- },- },- [- "register-cli-scan",- "--repository",- repository,- "--scan-dir",- scanDirectory,- "--recipe-json",- JSON.stringify({- config: {},- mode: "standard",- repository,- target: { kind: "repository", paths: [] },- }),- ],- );- expect(registration["scanId"]).toBeString();-- const upgraded = spawnSync(- python!,- [- "-I",- "-B",- "-c",- [- "import json, sqlite3, sys",- "connection = sqlite3.connect(sys.argv[1])",- "connection.row_factory = sqlite3.Row",- "columns = {row['name'] for row in connection.execute('PRAGMA table_info(scans)')}",- "migrations = {row['version']: row['name'] for row in connection.execute('SELECT version, name FROM schema_migrations WHERE version IN (25, 26)')}",- "warnings = connection.execute('SELECT completion_warnings_json FROM scans WHERE id = ?', ('legacy-scan',)).fetchone()[0]",- "print(json.dumps({'columns': sorted(columns & {'model', 'reasoning_effort', 'completion_warnings_json'}), 'migrations': migrations, 'warnings': json.loads(warnings)}))",- ].join("\n"),- join(stateDirectory, "workbench.sqlite3"),- ],- { encoding: "utf8" },- );- expect(upgraded.status).toBe(0);- expect(upgraded.stderr).toBe("");- expect(JSON.parse(upgraded.stdout)).toEqual({- columns: ["completion_warnings_json", "model", "reasoning_effort"],- migrations: {- "25": "persist scan model settings",- "26": "persist scan completion warnings",- },- warnings: ["existing warning"],- });- });-test.each([["all required draft artifacts", []],["the manifest draft", ["findings.json", "coverage.json"]],diff --git a/sdk/typescript/tests-ts/skeleton.test.ts b/sdk/typescript/tests-ts/skeleton.test.tsindex 505910734..195d1e388 100644--- a/sdk/typescript/tests-ts/skeleton.test.ts+++ b/sdk/typescript/tests-ts/skeleton.test.ts@@ -233,26 +233,34 @@ describe("TypeScript package skeleton", () => {...["3.10", "3.12", "3.14"].map((python) => ({os: "ubuntu-latest",python,- tests: "plugins/codex-security/tests",+ markers: "",})),{os: "macos-latest",python: "3.12",- tests: "plugins/codex-security/tests/test_workbench_scan_usage.py",+ markers: "cross_platform or native_macos",},{os: "windows-latest",python: "3.12",- tests: "plugins/codex-security/tests/test_windows_scan_local_files.py",+ markers: "cross_platform or native_windows",},]);const testStep = job.steps!.find(({ name }) => name === "Test Python source contracts",)!;- expect(testStep.env?.["PYTHON_TEST_PATH"]).toBe("${{ matrix.tests }}");- expect(testStep.run).toContain('python -m pytest "$PYTHON_TEST_PATH"');+ expect(testStep.env?.["PYTEST_MARKERS"]).toBe("${{ matrix.markers }}");+ expect(testStep.run).toContain(+ 'python -m pytest plugins/codex-security/tests -m "$PYTEST_MARKERS"',+ );expect(testStep).not.toHaveProperty("if");expect(testStep).not.toHaveProperty("continue-on-error");+ const nativeCoverageStep = job.steps!.find(+ ({ name }) => name === "Require native platform coverage",+ )!;+ expect(nativeCoverageStep.if).toBe("runner.os != 'Linux'");+ expect(nativeCoverageStep.run).toContain(".//testcase/skipped");+ expect(nativeCoverageStep).not.toHaveProperty("continue-on-error");for (const name of ["Install plugin dependencies","Build SDK and type-check eval tooling",diff --git a/sdk/typescript/tests-ts/support/python-probe.ts b/sdk/typescript/tests-ts/support/python-probe.tsindex a781fa8ff..79ad939af 100644--- a/sdk/typescript/tests-ts/support/python-probe.ts+++ b/sdk/typescript/tests-ts/support/python-probe.ts@@ -3,24 +3,6 @@ import {spawnSync,type SpawnSyncOptionsWithStringEncoding,} from "node:child_process";-import { join } from "node:path";-import { expect } from "bun:test";-import { PLUGIN_ROOT } from "../plugin-root.js";--export function runPythonJsonProbe(program: string, input: unknown): unknown {- const python = Bun.which("python3") ?? Bun.which("python") ?? Bun.which("py");- if (python === null) throw new Error("A Python interpreter is required.");-- const result = runPython(python, [- "-c",- program,- join(PLUGIN_ROOT, "scripts"),- JSON.stringify(input),- ]);-- expect(result.exitCode, new TextDecoder().decode(result.stderr)).toBe(0);- return JSON.parse(new TextDecoder().decode(result.stdout));-}export function runPython(python: string,diff --git a/sdk/typescript/tests-ts/workbench-patch.test.ts b/sdk/typescript/tests-ts/workbench-patch.test.tsdeleted file mode 100644index 2af089950..000000000--- a/sdk/typescript/tests-ts/workbench-patch.test.ts+++ /dev/null@@ -1,71 +0,0 @@-import { createHash } from "node:crypto";-import { writeFile } from "node:fs/promises";-import { join } from "node:path";-import { afterEach, describe, expect, test } from "bun:test";-import { PLUGIN_ROOT } from "./plugin-root.js";-import { runPython } from "./support/python-probe.js";-import { createTemporaryDirectories } from "./support/temporary-directories.js";--const temporaryDirectories = createTemporaryDirectories(true);--afterEach(temporaryDirectories.cleanup);--const patchProbe = [- "import json, sys",- "from pathlib import Path",- "sys.path.insert(0, sys.argv[1])",- "import workbench_db as workbench",- "scan_dir, digest = Path(sys.argv[2]), sys.argv[3]",- "scan = {'scan_dir': str(scan_dir)}",- "workbench.require_matching_patch_digest(scan, 'remediation.patch', digest)",- "preview, stats = workbench.patch_artifact_preview(scan_dir, 'remediation.patch', digest)",- "try:",- " workbench.require_matching_patch_digest(scan, 'remediation.patch', 'sha256:' + '0' * 64)",- "except SystemExit as error:",- " mismatch = str(error)",- "else:",- " mismatch = None",- "print(json.dumps({'preview': preview, 'stats': stats, 'mismatch': mismatch}))",-].join("\n");--describe("workbench remediation patches", () => {- test("streams patches larger than 2 MiB without weakening digest checks", async () => {- const directory = await temporaryDirectories.create(- "codex-security-large-patch-",- );- const patch = Buffer.concat([- Buffer.from("diff --git a/src.ts b/src.ts\n+"),- Buffer.alloc(2 * 1024 * 1024, 0x78),- Buffer.from("\n"),- ]);- await writeFile(join(directory, "remediation.patch"), patch);- const digest = `sha256:${createHash("sha256").update(patch).digest("hex")}`;- const python = Bun.which("python3") ?? Bun.which("python");- expect(python).not.toBeNull();-- const result = runPython(python!, [- "-c",- patchProbe,- join(PLUGIN_ROOT, "scripts"),- directory,- digest,- ]);- expect(new TextDecoder().decode(result.stderr)).toBe("");- expect(result.exitCode).toBe(0);- const output = JSON.parse(new TextDecoder().decode(result.stdout)) as {- preview: string;- stats: Record<string, number | boolean>;- mismatch: string;- };- expect(output.preview).toStartWith("diff --git a/src.ts b/src.ts\n+");- expect(output.preview).toEndWith("... patch preview truncated ...");- expect(output.stats).toMatchObject({- additions: 1,- fileCount: 1,- previewTruncated: true,- });- expect(output.mismatch).toBe(- "Patch digest does not match the scan-local patch file.",- );- });-});diff --git a/sdk/typescript/tests-ts/workbench-remediation-timestamp.test.ts b/sdk/typescript/tests-ts/workbench-remediation-timestamp.test.tsdeleted file mode 100644index 17829e72f..000000000--- a/sdk/typescript/tests-ts/workbench-remediation-timestamp.test.ts+++ /dev/null@@ -1,76 +0,0 @@-import { describe, expect, test } from "bun:test";-import { runPythonJsonProbe } from "./support/python-probe.js";--const remediationLeaseProbe = `-import json, sys-from datetime import datetime, timezone-sys.path.insert(0, sys.argv[1])-import workbench_remediation as remediation--class Python310DateTime(datetime):- @classmethod- def fromisoformat(cls, value):- if value.endswith(("Z", "z")):- raise ValueError("Python 3.10 rejects Z-suffixed timestamps")- return datetime.fromisoformat(value)-- @classmethod- def now(cls, tz=None):- return datetime(2026, 8, 15, 12, 0, tzinfo=timezone.utc)--remediation.datetime = Python310DateTime-case = json.loads(sys.argv[2])-print(json.dumps(remediation.remediation_claim_is_active({- "pending_action_claim_token": case.get("token"),- "pending_action_delivered_at": case.get("deliveredAt"),- "pending_action_claimed_at": case.get("claimedAt"),-})))-`;--interface RemediationClaim {- token: string | null;- claimedAt?: string;- deliveredAt?: string;-}--function isClaimActive(claim: RemediationClaim): boolean {- return runPythonJsonProbe(remediationLeaseProbe, claim) as boolean;-}--describe("workbench remediation timestamps on Python 3.10", () => {- test.each([- [- "expires at the claim deadline",- { claimedAt: "2026-08-15T11:58:00Z" },- false,- ],- ["accepts lowercase UTC", { claimedAt: "2026-08-15T11:58:00z" }, false],- [- "preserves explicit offsets",- { claimedAt: "2026-08-15T13:58:00+02:00" },- false,- ],- ["keeps a fresh claim", { claimedAt: "2026-08-15T11:58:01Z" }, true],- [- "expires at the delivery deadline",- {- claimedAt: "2026-08-15T11:30:00Z",- deliveredAt: "2026-08-15T11:45:00Z",- },- false,- ],- [- "keeps a fresh delivery after an older claim",- {- claimedAt: "2026-08-15T11:30:00Z",- deliveredAt: "2026-08-15T11:45:01Z",- },- true,- ],- ["has no claim without a token", { token: null }, false],- ["preserves an invalid timestamp", { claimedAt: "not-a-timestamp" }, true],- ["preserves a naive timestamp", { claimedAt: "2026-08-15T11:00:00" }, true],- ] as const)("%s", (_label, fields, active) => {- expect(isClaimActive({ token: "claim", ...fields })).toBe(active);- });-});