From 96069a278e419cc887421fdd4ac517771147e087 Mon Sep 17 00:00:00 2001 From: Bharath Vemula <12749607+BharathVemula@users.noreply.github.com> Date: Sun, 11 Oct 2026 11:29:21 -0700 Subject: [PATCH] fix(cli): honor explicit deep mode on resume --- strix/interface/cli_args.py | 6 ++++-- tests/test_cli_resume_picker.py | 36 ++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/strix/interface/cli_args.py b/strix/interface/cli_args.py index c9b6951b..652643e9 100644 --- a/strix/interface/cli_args.py +++ b/strix/interface/cli_args.py @@ -211,7 +211,7 @@ Strix Cloud: "--scan-mode", type=str, choices=["quick", "standard", "deep"], - default="deep", + default=None, help=( "Scan mode: " "'quick' for fast CI/CD checks, " @@ -314,6 +314,8 @@ Strix Cloud: ) args = parser.parse_args() + args.scan_mode_explicit = args.scan_mode is not None + args.scan_mode = args.scan_mode or "deep" # Startup-resolved state lives alongside the parsed flags. The full schema # is established here so downstream code reads attributes directly. args.needs_setup = False @@ -530,7 +532,7 @@ def load_resume_state(args: argparse.Namespace) -> None: if state.get("diff_scope"): args.diff_scope = state.get("diff_scope") persisted_scan_mode = state.get("scan_mode") - if persisted_scan_mode and args.scan_mode == "deep": + if persisted_scan_mode and not getattr(args, "scan_mode_explicit", False): args.scan_mode = persisted_scan_mode agents_path = runtime_state_dir(run_dir) / "agents.json" if not agents_path.exists(): diff --git a/tests/test_cli_resume_picker.py b/tests/test_cli_resume_picker.py index 4d00380f..86980034 100644 --- a/tests/test_cli_resume_picker.py +++ b/tests/test_cli_resume_picker.py @@ -17,7 +17,7 @@ if TYPE_CHECKING: cli_main: Any = importlib.import_module("strix.interface.main") -def _write_run(base: Path, name: str, *, state: bool = True) -> None: +def _write_run(base: Path, name: str, *, state: bool = True, scan_mode: str = "deep") -> None: run_dir = base / name (run_dir / ".state").mkdir(parents=True) (run_dir / "run.json").write_text( @@ -26,6 +26,7 @@ def _write_run(base: Path, name: str, *, state: bool = True) -> None: "run_name": name, "status": "completed", "start_time": "2026-10-04T10:00:00+00:00", + "scan_mode": scan_mode, "targets_info": [ { "type": "web_application", @@ -124,3 +125,36 @@ def test_named_resume_without_agent_state_is_an_error( cli_main.parse_arguments() assert "never reached its first agent snapshot" in capsys.readouterr().err + + +@pytest.mark.parametrize("persisted_mode", ["quick", "standard"]) +def test_named_resume_honors_explicit_deep_scan_mode( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, persisted_mode: str +) -> None: + monkeypatch.chdir(tmp_path) + _write_run( + tmp_path / "strix_runs", + "example-com_1111", + scan_mode=persisted_mode, + ) + monkeypatch.setattr( + sys, + "argv", + ["strix", "--resume", "example-com_1111", "--scan-mode", "deep"], + ) + + args = cli_main.parse_arguments() + + assert args.scan_mode == "deep" + + +def test_named_resume_restores_scan_mode_when_flag_is_omitted( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + monkeypatch.chdir(tmp_path) + _write_run(tmp_path / "strix_runs", "example-com_1111", scan_mode="quick") + monkeypatch.setattr(sys, "argv", ["strix", "--resume", "example-com_1111"]) + + args = cli_main.parse_arguments() + + assert args.scan_mode == "quick"