AkurAI Build
Menu

Public repository / ad059f006db84100173fad43334d14e1959c28b6

AkurAI-Platform / scripts/validate-page.py

Latest change ba5c7d4334c7f54a8cf85337ffeb626de1ef0fe3 - OLI-101: pricing page (pilot/run/retainer, contact for quote), public README, pricing contract check by Chief of Staff

#!/usr/bin/env python3
"""Validate the fields consumed by the static platform template."""
from __future__ import annotations

import json
import re
from pathlib import Path

page = json.loads((Path(__file__).parents[1] / "backend" / "page.json").read_text())
required = {
    "title",
    "brand",
    "year",
    "host",
    "vm_ip",
    "updated",
    "summary",
    "github",
    "proof",
    "trust",
    "cta",
    "methodology",
    "sources",
}
missing = sorted(required - page.keys())
if missing:
    raise SystemExit(f"missing page fields: {', '.join(missing)}")

for card in ("card1", "card2", "card3", "card4"):
    value = page["proof"].get(card)
    if not isinstance(value, dict) or not value.get("akur_memory") or not value.get("other_memory") or not value.get("source_url"):
        raise SystemExit(f"invalid proof.{card}")

if len(page["trust"]) != 4 or len(page["sources"]) != 3:
    raise SystemExit("unexpected trust/source collection size")

print("page contract: ok")

root = Path(__file__).parents[1]
routes = json.loads((root / "backend" / "routes.json").read_text())["routes"]
if not any(r["path"] == "/pricing" and r["template"] == "pricing" for r in routes):
    raise SystemExit("missing /pricing route")
if not (root / "frontend" / "pricing.html").exists():
    raise SystemExit("missing frontend/pricing.html")

locales = {
    lang: json.loads((root / "backend" / "locales" / f"{lang}.json").read_text())
    for lang in ("en", "is")
}
pricing_keys = {k for k in locales["en"] if k.startswith("pricing.")}
if not pricing_keys:
    raise SystemExit("no pricing.* locale keys")
for lang, strings in locales.items():
    absent = sorted(pricing_keys - {k for k in strings if k.startswith("pricing.")})
    if absent:
        raise SystemExit(f"{lang}: missing pricing keys: {', '.join(absent)}")
    for key in pricing_keys:
        if re.search(r"\d[\d.,]*\s*(ISK|kr)\b|\b(ISK|kr\.?)\s*\d", strings[key], re.I):
            raise SystemExit(f"{lang}: {key} contains a price figure")
template = (root / "frontend" / "pricing.html").read_text()
used = set(re.findall(r't "(pricing\.[a-z0-9_.]+)"', template))
if used - pricing_keys:
    raise SystemExit(f"template uses undefined keys: {sorted(used - pricing_keys)}")
print("pricing page: ok")