#!/usr/bin/env python3 """Create the isolated L132 owner snapshot with a native plan for existing FI strate 1.""" from __future__ import annotations import json from pathlib import Path ROOT = Path(__file__).resolve().parents[4] SOURCE = ROOT / "Standalone/data/owner_world.json" MANIFEST = ROOT / "Saved/Linux/l132/fixtures/owner-native-fi.world-assembly.json" LAYOUT = ROOT / "Saved/Linux/l132/fixtures/owner-native-fi.resolved-layout.json" OUTPUT = ROOT / "Saved/Linux/l132/fixtures/owner_world_native_fi.json" def main() -> int: owner = json.loads(SOURCE.read_text(encoding="utf-8")) manifest_text = MANIFEST.read_text(encoding="utf-8").strip() layout_text = LAYOUT.read_text(encoding="utf-8").strip() manifest = json.loads(manifest_text) layout = json.loads(layout_text) islands = manifest.get("floating_islands", []) native = [row for row in islands if row.get("strate_index") == 1] resolved = [row for row in layout.get("strates", []) if row.get("strate_index") == 1] if len(native) != 1 or len(resolved) != 1: raise SystemExit("native FI snapshot must contain exactly one strate-1 island plan/layout") if (resolved[0].get("generator_kind") != "FloatingIslands" or resolved[0].get("recipe_id") != "FloatingIslands.ClusterField" or resolved[0].get("recipe_version") != 8): raise SystemExit("resolved strate 1 is not FloatingIslands.ClusterField v8") owner["world_assembly"] = manifest owner["core_world_assembly_json"] = manifest_text owner["resolved_layout_json"] = layout_text OUTPUT.parent.mkdir(parents=True, exist_ok=True) OUTPUT.write_text(json.dumps(owner, separators=(",", ":")) + "\n", encoding="utf-8") print(f"[L132NativeFISnapshot] path={OUTPUT.relative_to(ROOT)} " f"islands={len(native[0].get('manifest', {}).get('plan', {}).get('islands', []))} " "strate=1 recipe=FloatingIslands.ClusterField/v8 status=PASS") return 0 if __name__ == "__main__": raise SystemExit(main())