#!/usr/bin/env python3 """Compare generation_baseline JSONL snapshots by relative asset path.""" import argparse import json from pathlib import Path def read(path): rows = [json.loads(line) for line in Path(path).read_text().splitlines()] result = {row["path"]: row for row in rows} if len(rows) != len(result): raise ValueError(f"duplicate paths in {path}") return result def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("before") parser.add_argument("after") args = parser.parse_args() before, after = read(args.before), read(args.after) if before.keys() != after.keys(): raise ValueError("sample inventories differ; compare the same corpus root") report = { "samples": len(before), "truncated_before": sum(row["truncated"] for row in before.values()), "truncated_after": sum(row["truncated"] for row in after.values()), "remaining_truncated": [path for path, row in after.items() if row["truncated"]], "new_truncation": [path for path, row in after.items() if row["truncated"] and not before[path]["truncated"]], "geometry_changed": [path for path, row in after.items() if any(row[key] != before[path][key] for key in ("branch_lods", "leaf_lods", "frond_lods"))], "bounds_changed": [path for path, row in after.items() if row["bounds"] != before[path]["bounds"]], } print(json.dumps(report, indent=2, ensure_ascii=False)) if __name__ == "__main__": main()