fix: fail loud on diag model fingerprint drift vs .env SEARCH_LLM_MODEL
Codex CHANGES_REQUESTED 复审: - Critical:diag_fingerprint 用 config.diag.model,但 Phase 1 诊断 LLM 从 .env SEARCH_LLM_MODEL 构建,两者不一致会让信号以错误模型指纹落库,破坏可复现/ resume/隔离。build_diagnosis_deps 新增 expected_model 参数,Phase 1 执行前 fail loud 校验 config.model == settings.search_llm_model(附两值)。 - Minor:config/video_split.yaml diag.model 注释由 JUDGE_LLM_MODEL 更正为 SEARCH_LLM_MODEL,与实现对齐。 - 补两个单测:模型不一致 fail loud + 缺凭证 fail loud。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -161,6 +161,42 @@ def test_dry_run_computes_fingerprint_without_llm(monkeypatch, tmp_path, capsys)
|
||||
assert not (tmp_path / "_dry_run_signals.db").exists()
|
||||
|
||||
|
||||
def test_build_diagnosis_deps_model_mismatch_fails_loud(monkeypatch, tmp_path):
|
||||
"""config.diag.model 与 .env SEARCH_LLM_MODEL 不一致 → fail loud(指纹漂移防护)。"""
|
||||
|
||||
class _FakeSettings:
|
||||
search_llm_model = "actual-model-in-env"
|
||||
search_llm_base_url = "https://api.example"
|
||||
search_llm_api_key = "sk-xxx"
|
||||
|
||||
monkeypatch.setattr(cli, "_DiagLLMSettings", lambda: _FakeSettings())
|
||||
with pytest.raises(SystemExit) as exc:
|
||||
cli.build_diagnosis_deps(
|
||||
harness_db=tmp_path / "h.db",
|
||||
concurrency=2,
|
||||
expected_model="deepseek-v4-pro", # 与 env 不一致
|
||||
)
|
||||
# 报错须同时暴露两个值,便于人对齐
|
||||
msg = str(exc.value)
|
||||
assert "deepseek-v4-pro" in msg
|
||||
assert "actual-model-in-env" in msg
|
||||
|
||||
|
||||
def test_build_diagnosis_deps_missing_credentials_fails_loud(monkeypatch, tmp_path):
|
||||
""".env 缺 search LLM 凭证 → fail loud(先于模型一致性校验)。"""
|
||||
|
||||
class _EmptySettings:
|
||||
search_llm_model = ""
|
||||
search_llm_base_url = ""
|
||||
search_llm_api_key = ""
|
||||
|
||||
monkeypatch.setattr(cli, "_DiagLLMSettings", lambda: _EmptySettings())
|
||||
with pytest.raises(SystemExit):
|
||||
cli.build_diagnosis_deps(
|
||||
harness_db=tmp_path / "h.db", concurrency=2, expected_model="deepseek-v4-pro"
|
||||
)
|
||||
|
||||
|
||||
def test_git_short_sha_nonempty():
|
||||
"""仓库内 git_short_sha 返回非空短 SHA。"""
|
||||
sha = cli.git_short_sha()
|
||||
|
||||
Reference in New Issue
Block a user