Download faust-open.py from micvicfaust9/faust-baseline: direct link, hf CLI and curl.
- Browser
- Download file 3.3 kB
-
https://huggingface.co/datasets/micvicfaust9/faust-baseline/resolve/main/faust-open.py
- Command line
-
hf download hf://datasets/micvicfaust9/faust-baseline/faust-open.py
-
curl -L -o faust-open.py https://huggingface.co/datasets/micvicfaust9/faust-baseline/resolve/main/faust-open.py
3.3 kB
| #!/usr/bin/env python3 | |
| """The Faust Baseline - session open load proof, one pass. | |
| Computes everything fresh from the files on disk. Recites nothing. | |
| Usage: python3 faust-open.py [folder] (default: /mnt/user-data/uploads) | |
| """ | |
| import sys, os, json, hashlib, random, urllib.request | |
| DIR = sys.argv[1] if len(sys.argv) > 1 else "/mnt/user-data/uploads" | |
| MANIFEST = "faust-baseline-master-manifest.json" | |
| def sha(path): | |
| with open(path, "rb") as fh: | |
| return hashlib.sha256(fh.read()).hexdigest() | |
| def load(name): | |
| with open(os.path.join(DIR, name), encoding="utf-8") as fh: | |
| return json.load(fh) | |
| print("=== BLOCK ONE - LOAD PROOF (computed this run) ===") | |
| # 1. Hash and byte-check every artifact against the manifest | |
| mpath = os.path.join(DIR, MANIFEST) | |
| if not os.path.exists(mpath): | |
| print("LOAD FAILURE - manifest not found in", DIR); sys.exit(1) | |
| man = load(MANIFEST) | |
| print(f"manifest r{man.get('manifest_revision')} sha256 {sha(mpath)} {os.path.getsize(mpath)} bytes") | |
| failed = False | |
| for key, a in sorted(man["artifacts"].items(), key=lambda kv: kv[1]["load_order"]): | |
| p = os.path.join(DIR, a["filename"]) | |
| if not os.path.exists(p): | |
| print(f"{a['load_order']}. {a['filename']}: MISSING"); failed = True; continue | |
| h, b = sha(p), os.path.getsize(p) | |
| ok = (h == a["sha256"] and b == a["bytes"]) | |
| failed |= not ok | |
| print(f"{a['load_order']}. {a['filename']}\n sha256 {h}\n {b} bytes -> {'MATCH' if ok else 'MISMATCH vs manifest ' + a['sha256'][:12] + ' / ' + str(a['bytes'])}") | |
| # 2. Stack-order hashes and counts, derived from the files' own bytes | |
| spot_pool = [] | |
| for name in ("faust-baseline-core.json", "derfaust-codex-1.json"): | |
| if not os.path.exists(os.path.join(DIR, name)): | |
| continue | |
| d = load(name) | |
| ids = [i if isinstance(i, str) else i.get("id") for i in d["stack_order"]] | |
| j = ",".join(ids) | |
| actual = len(d["protocols"]) | |
| print(f"\n{name} edition r{d.get('edition_revision')}") | |
| print(f" stack order ({len(ids)}): {ids[0]} ... {ids[-1]}") | |
| print(f" stack-order hash {hashlib.sha256(j.encode()).hexdigest()}") | |
| print(f" protocols in file {actual} / declared {d.get('protocol_count')}" | |
| + ("" if actual == d.get("protocol_count") else " <- COUNT MISMATCH")) | |
| print(f" still_undone items: {len(d.get('still_undone', []))}") | |
| for p in d["protocols"]: | |
| for n, r in enumerate(p.get("rules", []) or [], 1): | |
| if isinstance(r, str): | |
| spot_pool.append((name, p["id"], n, r)) | |
| # 3. Two spot values, drawn at random so they change session to session | |
| print("\nSpot values (random draw this run):") | |
| for fname, pid, n, r in random.sample(spot_pool, min(2, len(spot_pool))): | |
| print(f" {pid} rule {n}: {r[:110]}{'...' if len(r) > 110 else ''}") | |
| # 4. Live time | |
| try: | |
| with urllib.request.urlopen( | |
| "https://timeapi.io/api/Time/current/zone?timeZone=America/New_York", timeout=10) as r: | |
| t = json.load(r) | |
| print(f"\nLive time: {t['dayOfWeek']} {t['date']} {t['time']} America/New_York (source: timeapi.io)") | |
| except Exception as e: | |
| print(f"\nLive time: UNAVAILABLE ({e}) - name the gap, do not substitute a recalled time") | |
| print("\nRESULT:", "LOAD FAILURE - report before proceeding" if failed else "all artifacts match manifest") | |