Buckets:
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import re | |
| from pathlib import Path | |
| from bind_verified_analysis import ANALYSIS_COPY, BROWSER_DATA, LOCK_FILE, EvidenceBindingError, verify_bound | |
| ROOT = Path(__file__).resolve().parent | |
| CLAIMS = ["A1", "A2", "A3", "A4", "A5", "A6"] | |
| REQUIRED = { | |
| "index.html", "styles.css", "app.js", BROWSER_DATA, "analysis-contract.json", | |
| "figure-contracts.json", "bind_verified_analysis.py", "DATA_BINDING_SPEC.md", | |
| "NARRATIVE_SPEC.md", "STORYBOARD.md", "design-tokens.json", "REVIEW_CHECKLIST.md", "README.md", | |
| } | |
| OPENING = ( | |
| "A forecast will never be exact. A robust optimizer decides which errors to prepare for. This paper teaches it which errors matter.", | |
| "Tomorrow's forecast will be wrong. Which errors should you pay to survive?", | |
| "If two errors are equally far from the forecast but cause different losses, should the optimizer defend them equally?", | |
| "Learn the meaning of distance from the decision's own loss.", | |
| ) | |
| def _browser_payload() -> dict[str, object]: | |
| raw = (ROOT / BROWSER_DATA).read_text(encoding="utf-8") | |
| prefix = "window.__DECISION_ATLAS_EVIDENCE__=Object.freeze(" | |
| suffix = ");\n" | |
| if not raw.startswith(prefix) or not raw.endswith(suffix): | |
| raise SystemExit("browser binding wrapper changed") | |
| value = json.loads(raw[len(prefix):-len(suffix)]) | |
| if not isinstance(value, dict): | |
| raise SystemExit("browser binding is not an object") | |
| return value | |
| def validate(*, require_ready: bool = False) -> str: | |
| missing = sorted(name for name in REQUIRED if not (ROOT / name).is_file()) | |
| if missing: | |
| raise SystemExit(f"missing presentation files: {missing}") | |
| html = (ROOT / "index.html").read_text(encoding="utf-8") | |
| css = (ROOT / "styles.css").read_text(encoding="utf-8") | |
| js = (ROOT / "app.js").read_text(encoding="utf-8") | |
| contract = json.loads((ROOT / "analysis-contract.json").read_text(encoding="utf-8")) | |
| figures = json.loads((ROOT / "figure-contracts.json").read_text(encoding="utf-8")) | |
| json.loads((ROOT / "design-tokens.json").read_text(encoding="utf-8")) | |
| offline = (html + css + js).replace("http://www.w3.org/2000/svg", "") | |
| if re.search(r"https?://|@import", offline, flags=re.I): | |
| raise SystemExit("remote dependency found in offline presentation") | |
| if "\u2014" in html + js: | |
| raise SystemExit("judge-facing copy contains an em dash") | |
| if any(phrase in (html + js).lower() for phrase in ("delve into", "unlock the power", "game-changing", "key takeaway", "journey")): | |
| raise SystemExit("generic promotional copy found") | |
| if any(mark in html + js for mark in ("Â", "Î", "Ã")): | |
| raise SystemExit("mojibake found in presentation") | |
| if any(copy not in html for copy in OPENING): | |
| raise SystemExit("Decision Atlas opening changed") | |
| required_ids = { | |
| "allocation-range", "starter-loss", "atlas-game", "stress-test", "budget-range", "training-svg", | |
| "loop-next", "evidence-gate", "matrix-state", "claim-results", "figure-results", "evidence-step", | |
| "evidence-chart", "censoring-result", "theorem-result", "provenance-results", | |
| } | |
| found = set(re.findall(r'id="([^"]+)"', html)) | |
| if not required_ids.issubset(found): | |
| raise SystemExit(f"missing interaction ids: {sorted(required_ids - found)}") | |
| if any(f'id="claim-{claim}"' not in html or f'data-claim-id="{claim}"' not in html for claim in CLAIMS): | |
| raise SystemExit("six ordered claim pages are incomplete") | |
| if [html.index(f'id="claim-{claim}"') for claim in CLAIMS] != sorted(html.index(f'id="claim-{claim}"') for claim in CLAIMS): | |
| raise SystemExit("claim pages are out of order") | |
| if "prefers-reduced-motion" not in css or "skip" not in html or "min-height: 44px" not in css: | |
| raise SystemExit("accessibility contract incomplete") | |
| if contract.get("schema_version") != 4 or contract.get("official_claim_ids") != CLAIMS: | |
| raise SystemExit("six-claim analysis contract changed") | |
| expected = {"A1": "partially_verified", "A2": "inconclusive", "A3": "inconclusive", "A4": "inconclusive", "A5": "inconclusive", "A6": "partially_verified"} | |
| if contract.get("conservative_verdicts") != expected: | |
| raise SystemExit("conservative verdict contract was strengthened") | |
| figure_map = {item["id"]: item["claim"] for item in figures.get("figures", [])} | |
| if figures.get("schema_version") != 4 or figure_map != contract.get("figure_claims") or figure_map != {"coverage-sweep": "A5", "regression-sweep": "A6"}: | |
| raise SystemExit("interactive figure contract changed") | |
| if any(token not in html for token in ("U<sub>ε</sub>(L)", "M = LL<sup>T</sup>", "∂x*/∂L", "Gelbrich / W2", "W1 ambiguity")): | |
| raise SystemExit("specialist mathematical layer incomplete") | |
| payload = _browser_payload() | |
| bound = {name for name in (ANALYSIS_COPY, LOCK_FILE) if (ROOT / name).exists()} | |
| if payload == {}: | |
| if bound: | |
| raise SystemExit("partial evidence binding found") | |
| if require_ready: | |
| raise SystemExit("REFUSED: sealed six-claim analysis is not bound") | |
| return "not_bound" | |
| if bound != {ANALYSIS_COPY, LOCK_FILE}: | |
| raise SystemExit("presentation is partially bound") | |
| try: | |
| verify_bound() | |
| except EvidenceBindingError as exc: | |
| raise SystemExit(f"REFUSED: {exc}") from exc | |
| if payload.get("schema_version") != 4 or list(payload.get("claims", {})) != CLAIMS: | |
| raise SystemExit("browser payload is not the six-claim receipt") | |
| return "verified" | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Validate the six-claim Decision Atlas") | |
| parser.add_argument("--require-ready", action="store_true") | |
| args = parser.parse_args() | |
| state = validate(require_ready=args.require_ready) | |
| print("PASS: Decision Atlas is offline, accessible, interactive, and evidence-bound") | |
| print("- official claim pages: 6 in anchored order") | |
| print("- interactive evidence traces: A5 coverage and A6 regression") | |
| print(f"- submission state: {state}") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 6.31 kB
- Xet hash:
- 7064d9d09480120646d3f6f6f1c5ce36dd0cd5f43eea13cbabd3a6162a93836d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.