#!/usr/bin/env python3 """Per-tile zstd CLI comparison over the pristine L1 records from this round.""" from pathlib import Path import shutil import struct import subprocess import time import zlib REPO = Path.cwd().resolve() CACHE = REPO / "Saved/Linux/cache/l16-prototype" CAPTURE_LOG = REPO / "Saved/Linux/l16-cache-l1-q24-full-write.log" TEMP = CACHE / "codec-zstd" RESULT = REPO / "Saved/Linux/l16-zstd-codec.txt" assert CACHE.is_dir() and not CACHE.is_symlink() assert CACHE.resolve().parent == (REPO / "Saved/Linux/cache").resolve() assert CAPTURE_LOG.is_file() assert not TEMP.exists() cutoff_ns = CAPTURE_LOG.stat().st_mtime_ns records = [ path for world in CACHE.glob("world_*") for path in world.glob("*.vftile") if "_s0_d0000000000000000_" in path.name and path.stat().st_mtime_ns <= cutoff_ns ] records.sort() assert len(records) == 2553, f"expected 2553 L1 pristine records, found {len(records)}" codec = shutil.which("zstd") assert codec, "zstd CLI is not available" TEMP.mkdir() per_lod = {} try: for source in records: record = source.read_bytes() assert record[:8] == b"VFTILE16" raw_size, compressed_size = struct.unpack_from("