fix(factor): 终审 m6——monthly_batch manifest 缺路径守卫(存在才比对,缺则 stderr 告警跳过),缺口件 fail-soft 契约补全 [vps]
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -109,8 +109,13 @@ def main(argv: list[str] | None = None) -> int:
|
||||
if plan["skipped_unregistered"]:
|
||||
print(f"[monthly_batch] ⚠️ 剔除库中不可解析名(血统漂移,须对齐): "
|
||||
f"{plan['skipped_unregistered']}", file=sys.stderr)
|
||||
gaps = dgc.check_gaps(dgc.collect_requirements(registry),
|
||||
dgc.load_manifest(args.manifest))
|
||||
if os.path.exists(args.manifest):
|
||||
gaps = dgc.check_gaps(dgc.collect_requirements(registry),
|
||||
dgc.load_manifest(args.manifest))
|
||||
else:
|
||||
gaps = {}
|
||||
print(f"[monthly_batch] ⚠️ manifest 不存在,跳过缺口比对: {args.manifest}",
|
||||
file=sys.stderr)
|
||||
if gaps:
|
||||
print(f"[monthly_batch] ⚠️ 数据缺口(决议 M,批照跑): "
|
||||
+ "; ".join(f"{f}→{','.join(s)}" for f, s in sorted(gaps.items())),
|
||||
|
||||
@@ -212,3 +212,29 @@ def test_main_reports_gaps_and_opens_issue(tmp_path, capsys, monkeypatch):
|
||||
err = capsys.readouterr().err
|
||||
assert "数据缺口" in err and "fa_probe" in err
|
||||
assert opened and "fa_probe" in opened[0]
|
||||
|
||||
|
||||
def test_main_missing_manifest_failsoft(tmp_path, capsys, monkeypatch):
|
||||
# m6: --manifest 指向不存在路径 → stderr 告警+跳过缺口比对,批照跑 rc=0
|
||||
import sanguo_factor.monthly_batch as mb
|
||||
|
||||
reg = tmp_path / "reg.yaml"
|
||||
reg.write_text(
|
||||
"factors:\n"
|
||||
" fa_probe:\n"
|
||||
" name: fa_probe\n hypothesis: x\n status: assessable\n"
|
||||
" versions:\n - v: 1\n commit: c0ffee\n"
|
||||
" params: {source: s_not_wired}\n", encoding="utf-8")
|
||||
|
||||
def fake_resolve(name):
|
||||
return True
|
||||
monkeypatch.setattr(mb, "resolve_with_yaml", lambda r: fake_resolve)
|
||||
monkeypatch.setattr(mb, "run_batch_eval",
|
||||
lambda *a, **k: {"run_id": "r", "factors_total": 1,
|
||||
"factors_done": 1})
|
||||
rc = mb.main(["--registry", str(reg), "--as-of", "2026-10-04",
|
||||
"--eval-db", str(tmp_path / "e.db"),
|
||||
"--manifest", str(tmp_path / "nope.yaml"),
|
||||
"--report-dir", str(tmp_path)])
|
||||
assert rc == 0
|
||||
assert "manifest" in capsys.readouterr().err
|
||||
|
||||
Reference in New Issue
Block a user