From 52ecf67ef7129ea6d96d37333eda2a6f45355276 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Tue, 20 Oct 2026 13:09:21 +0200 Subject: [PATCH] Fix #3187: calibrate checks the report folder before the sweep, not after it --- strata_control/calibration.py | 4 +++- tests/terminal/test_calibration.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/strata_control/calibration.py b/strata_control/calibration.py index a020f2f7..b158f741 100644 --- a/strata_control/calibration.py +++ b/strata_control/calibration.py @@ -290,8 +290,10 @@ def _measure_locked(ref: str, path: Path, profile: dict | None, revision: str | _exclusive_preflight(cfg, profile) if output.exists() or output.is_symlink(): raise ProfileError("calibration report path already exists", 2) + if not output.parent.is_dir(): # before the 19 minute sweep, not after it (#3187) + raise ProfileError("report output directory does not exist", 5) identity = _identity(path, cfg, profile, revision) - cal = _full_folder("tools.calibrate") + cal =_full_folder("tools.calibrate") execute = runner or cal.run runner_cfg = _runtime_cfg(cfg, profile) runner_cfg["exe"] = str(_resolved(cfg["exe"], cfg, path)) diff --git a/tests/terminal/test_calibration.py b/tests/terminal/test_calibration.py index 127463d9..5ebc74ac 100644 --- a/tests/terminal/test_calibration.py +++ b/tests/terminal/test_calibration.py @@ -326,6 +326,13 @@ class CalibrationFlowTests(unittest.TestCase): ["engine.calibrate.rollback", "engine.calibrate.apply", "engine.calibrate.measure"]) + def test_missing_report_folder_is_refused_before_the_sweep(self): + # #3187: the sweep takes ~19 minutes; the folder check must not wait until after it + for output in (self.root / "no-such-dir" / "report.json", self.config / "report.json"): + with self.assertRaisesRegex(profiles.ProfileError, "report output directory does not exist"): + calibration.measure("local", output, exclusive_ack=True, + runner=lambda *_a, **_k: self.fail("the sweep must not start")) + def test_calibration_rechecks_reviewed_digests_inside_operation_lock(self): report_path = self.root / "pinned-calibration.json" with self.assertRaisesRegex(profiles.ProfileError, "source changed after review"):