protocol_p3 (cee2ff0) was the rerun of P2 on new realizations, not the
plan's phase P3 (F3 field). Renamed to P2r before any of realizations 8-15
was generated: protocol, D2 config, dev runner and summary script, output
dir outputs/p2/diag/p2rdev, tag protocol-p3 -> protocol-p2r. Protocol
content changes only names plus two notes in p2_outcome: the deviation from
protocol_p2's if_fail rule (pivot) and what the diagnosis did not test
(sigma_b, rock-physics stress). Re-locked: sha256 eb887311...
Docs: plan §12 item 12 and report section closing P2 (locked verdict kept,
diagnosis, decision, deviation, untested items, link to phase P3 / G-C).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
import yaml
|
|
|
|
from ml_porosity.paths import REPO_ROOT
|
|
|
|
CONFIGS = REPO_ROOT / "configs"
|
|
|
|
|
|
def test_d2_p2r_generator_matches_p2():
|
|
"""protocol_p2r uses the protocol_p2 D2 generator: only the regimes block may be added."""
|
|
p2 = yaml.safe_load((CONFIGS / "d2_synth.yaml").read_text())
|
|
p2r = yaml.safe_load((CONFIGS / "d2_synth_p2r.yaml").read_text())
|
|
regimes = p2r.pop("regimes")
|
|
assert p2r == p2
|
|
assert all(set(r) == {"snr_db", "anchor_density"} for r in regimes.values())
|
|
|
|
|
|
def test_p2r_regimes_and_realizations():
|
|
P = yaml.safe_load((CONFIGS / "protocol_p2r.yaml").read_text())
|
|
regimes = yaml.safe_load((REPO_ROOT / P["inputs"]["d2_config"]["path"]).read_text())["regimes"]
|
|
assert set(P["grid"]["regimes"]) <= set(regimes)
|
|
p2 = yaml.safe_load((CONFIGS / "protocol_p2.yaml").read_text())["grid"]
|
|
used = set(p2["realizations"]) | set(p2["dev_realizations"])
|
|
assert not used & set(P["grid"]["realizations"])
|
|
|
|
|
|
def test_locked_protocols_match_sha256():
|
|
"""Locked protocols must not change after locking (a change needs a new version)."""
|
|
import hashlib
|
|
|
|
for name in ["protocol_p2", "protocol_p2r"]:
|
|
sha, path = (CONFIGS / f"{name}.sha256").read_text().split()
|
|
assert hashlib.sha256((REPO_ROOT / path).read_bytes()).hexdigest() == sha
|
|
|
|
|
|
def test_p2r_inputs_match_sha256():
|
|
import hashlib
|
|
|
|
P = yaml.safe_load((CONFIGS / "protocol_p2r.yaml").read_text())
|
|
for key in ["d2_config", "budgets", "warp_prior", "wavelet"]:
|
|
f = REPO_ROOT / P["inputs"][key]["path"]
|
|
if not f.exists(): # outputs/ is not versioned
|
|
continue
|
|
assert hashlib.sha256(f.read_bytes()).hexdigest() == P["inputs"][key]["sha256"], key
|