fix: validate global frozen pools baseline_run_id + sha256 on load
This commit is contained in:
@@ -844,6 +844,28 @@ def build_or_load_pools(
|
||||
len(new_types),
|
||||
sorted(new_types),
|
||||
)
|
||||
else:
|
||||
# global:校验 baseline_run_id 与(若有)manifest 内容指纹,
|
||||
# 拒绝静默加载与 seed 错配 / 被篡改的冻结切分(P5 fail loud)。
|
||||
frozen_baseline = raw.get("baseline_run_id")
|
||||
if frozen_baseline != baseline_run_id:
|
||||
raise ValueError(
|
||||
f"冻结 pools.json 的 baseline_run_id={frozen_baseline!r} 与 seed "
|
||||
f"的 {baseline_run_id!r} 不一致,拒绝静默加载错配切分。"
|
||||
)
|
||||
manifest_path = config.workspace_dir / "split_manifest.json"
|
||||
if manifest_path.exists():
|
||||
import hashlib
|
||||
|
||||
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
||||
actual_sha = hashlib.sha256(
|
||||
pools_path.read_text(encoding="utf-8").encode("utf-8")
|
||||
).hexdigest()
|
||||
if manifest.get("pools_sha256") != actual_sha:
|
||||
raise ValueError(
|
||||
"pools.json 内容指纹与 split_manifest.pools_sha256 不符,"
|
||||
"冻结产物疑被篡改,拒绝加载。"
|
||||
)
|
||||
|
||||
return load_pools(pools_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user