fix(harness): 补充 train 模式 run_id 校验 + 拆分函数保持 radon Grade B
- _validate_mode_deps: 恢复 train 非 resume/fresh 时必须提供 run_id 校验 - 提取 _validate_train_run_id 用 early return 展平条件,避免 radon Grade C - 合并 promote run_id 检查到 diagnose/evolve/promote 统一检查 - 新增 4 个测试:train+run_id / train+resume / train+fresh / train+baseline - radon cc -n C 无输出(全部 Grade B 或更好) - 74 个单元测试全部通过 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -139,7 +139,7 @@ class TestModeValidation:
|
||||
def test_all_valid_modes_accepted(self, valid_mode: str) -> None:
|
||||
"""全部合法 mode 应通过校验(diagnose/evolve 需 run_id)。"""
|
||||
overrides: dict = {"mode": valid_mode}
|
||||
if valid_mode in ("diagnose", "evolve"):
|
||||
if valid_mode in ("diagnose", "evolve", "train"):
|
||||
overrides["run_id"] = "run-001"
|
||||
if valid_mode in ("eval", "promote"):
|
||||
overrides["version"] = "v1"
|
||||
@@ -172,6 +172,27 @@ class TestModeValidation:
|
||||
with pytest.raises(ValueError, match="run.id"):
|
||||
_validate(cfg)
|
||||
|
||||
def test_train_mode_requires_run_id_without_resume_fresh(self) -> None:
|
||||
"""train 模式非 resume/fresh 时必须提供 run_id。"""
|
||||
cfg = _make_config(mode="train", run_id="", resume=False, fresh=False)
|
||||
with pytest.raises(ValueError, match="run_id"):
|
||||
_validate(cfg)
|
||||
|
||||
def test_train_mode_resume_without_run_id_accepted(self) -> None:
|
||||
"""train 模式 resume=True 时不需要 run_id。"""
|
||||
cfg = _make_config(mode="train", run_id="", resume=True)
|
||||
_validate(cfg)
|
||||
|
||||
def test_train_mode_fresh_without_run_id_accepted(self) -> None:
|
||||
"""train 模式 fresh=True 时不需要 run_id。"""
|
||||
cfg = _make_config(mode="train", run_id="", fresh=True)
|
||||
_validate(cfg)
|
||||
|
||||
def test_train_mode_with_run_id_accepted(self) -> None:
|
||||
"""train 模式提供 run_id 时应通过(旧式基线 run)。"""
|
||||
cfg = _make_config(mode="train", run_id="baseline-001")
|
||||
_validate(cfg)
|
||||
|
||||
def test_concurrency_positive(self) -> None:
|
||||
"""concurrency <= 0 应报错。"""
|
||||
cfg = _make_config(concurrency=0)
|
||||
|
||||
Reference in New Issue
Block a user