Skip to content

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

fix: clear Deep Scan consolidation progress when a scan stops (#2433)

Michael D'Angelo977e65971380
diff --git a/plugins/codex-security/scripts/deep_scan_workbench.py b/plugins/codex-security/scripts/deep_scan_workbench.py
index a206d6621..f2da154ae 100644
--- a/plugins/codex-security/scripts/deep_scan_workbench.py
+++ b/plugins/codex-security/scripts/deep_scan_workbench.py
@@ -395,7 +395,7 @@ def deep_scan_state(connection: sqlite3.Connection, scan_id: str) -> dict[str, A
def independent_review_progress(
- connection: sqlite3.Connection, scan_id: str
+ connection: sqlite3.Connection, scan_id: str, *, parent_running: bool
) -> dict[str, int | str] | None:
"""Return completed and allowed review counts and the consolidation state, or None for a missing run."""
run = connection.execute(
@@ -417,11 +417,12 @@ def independent_review_progress(
""",
(scan_id,),
).fetchone()
+ consolidating = run["phase"] in {"reducing", "terminal"} or (active == 0 and buffered > 0)
return {
"active": int(active),
"completed": int(run["completion_sequence"]),
"maximum": int(run["max_discovery_runs"]),
- "consolidating": run["phase"] in {"reducing", "terminal"} or (active == 0 and buffered > 0),
+ "consolidating": parent_running and consolidating,
"updatedAt": str(run["updated_at"]),
}
diff --git a/plugins/codex-security/scripts/workbench_db.py b/plugins/codex-security/scripts/workbench_db.py
index 88ac47f22..1ee0159bd 100644
--- a/plugins/codex-security/scripts/workbench_db.py
+++ b/plugins/codex-security/scripts/workbench_db.py
@@ -2595,7 +2595,9 @@ def scan_progress_result(
connection: sqlite3.Connection, scan: sqlite3.Row
) -> tuple[dict[str, Any], str]:
independent_reviews = (
- deep_scan.independent_review_progress(connection, scan["id"])
+ deep_scan.independent_review_progress(
+ connection, scan["id"], parent_running=scan["status"] == "running"
+ )
if scan["mode"] == "deep"
else None
)
diff --git a/plugins/codex-security/tests/test_workbench_deep_scan.py b/plugins/codex-security/tests/test_workbench_deep_scan.py
index 76c959597..59f6377da 100644
--- a/plugins/codex-security/tests/test_workbench_deep_scan.py
+++ b/plugins/codex-security/tests/test_workbench_deep_scan.py
@@ -1723,6 +1723,8 @@ def test_sealed_target_result_replays_only_the_pending_request(tmp_path: Path) -
scan_dir, scan_id, target, relative_path="source.py", coverage_mode="deep_repository"
)
assert scan_command(state_dir, "complete-scan", scan_id)["scan"]["reportAvailable"]
+ progress = get_scan(state_dir, scan_id, "--progress-only")["scan"]["progress"]
+ assert progress["independentReviews"]["consolidating"] is False
project.unlink()
# A probe neither reopens the selected file nor consumes the result.
@@ -3108,6 +3110,7 @@ def test_cancel_scan_overrides_succeeded_deep_run_during_parent_tail(
assert canceled["manifestPath"] == (str(manifest) if with_manifest else None)
scan = get_scan(state_dir, scan_id, environment=deep_environment(codex_home))["scan"]
assert scan["progress"]["status"] == "canceled"
+ assert scan["progress"]["independentReviews"]["consolidating"] is False
@pytest.mark.parametrize("deep_status", ["failed", "interrupted"])
@@ -3145,6 +3148,7 @@ def test_saturated_run_without_manifest_can_be_marked_failed_or_interrupted(
assert terminal["error"] == message
scan = get_scan(state_dir, scan_id, environment=deep_environment(codex_home))["scan"]
assert scan["progress"]["status"] == "failed"
+ assert scan["progress"]["independentReviews"]["consolidating"] is False
assert scan["failureMessage"] == terminal["error"]
diff --git a/sdk/typescript/README.md b/sdk/typescript/README.md
index 953447221..dca03b8ef 100644
--- a/sdk/typescript/README.md
+++ b/sdk/typescript/README.md
@@ -417,8 +417,9 @@ For retired progress hooks, see [older progress integrations](#older-progress-in
contain source code or credentials. Deep scans additionally expose durable
independent-review counts through `onDeepProgress`: `completed`, `active`, and
`maximum`. The maximum is a configured cap, not a percentage denominator. The
-optional `consolidating` flag reports when results are being combined or the
-coordinator has finished.
+optional `consolidating` flag is true while the running scan combines results or
+waits for finalization after its coordinator finishes. It is false once the scan
+completes, fails, or is canceled.
`ScanOptions` lists all callbacks.
Costs estimate API-equivalent model usage, not your bill or ChatGPT subscription