#!/usr/bin/env python3
"""blind_check.py — was the calibration blind? Computed from the hook's log, never typed.
Passes when observations.md exists in the calibration run and no read of a prior path was allowed before it.
The seal hook blocks those reads and logs each attempt; a logged block is fine, an unlogged read cannot happen
while the seal is on. Fails when the seal was off (prior_policy != sealed) or observations.md is missing."""
import json, os, sys
cfg = json.load(open(".discover/run.json"))
obs = os.path.join(cfg["run_dir"], "observations.md")
if cfg.get("prior_policy") != "sealed":
    print("FAIL: the prior corpora were not sealed for this run"); sys.exit(1)
if not os.path.exists(obs):
    print("FAIL: observations.md not written yet"); sys.exit(1)
blocked = sum(1 for l in open(".discover/telemetry.jsonl") if '"hook.seal"' in l) if os.path.exists(".discover/telemetry.jsonl") else 0
print(f"blind: sealed run, observations written, {blocked} sealed read attempt(s) blocked"); sys.exit(0)
