diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-master-prompt.txt b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-master-prompt.txt new file mode 100644 index 00000000..f6e611fe --- /dev/null +++ b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-master-prompt.txt @@ -0,0 +1,22 @@ +Use case: precise-object-edit +Asset type: production static coordinate master for a landscape Godot game UI +Input image: the approved PTY-001 Party Line master; this is the edit target and the visual authority + +Primary request: Create a clean static master from the input while preserving the exact 16:9 composition, camera, painted guild training-yard environment, Japanese hand-drawn fantasy style, outer frame, top status rail, top-right parchment panel frame, lower relationship parchment frames, bottom command rail, command button frames, fixed resource/action icons, foreground desk, lantern, crates, banners and all architectural scenery. + +Remove only runtime-owned or state-owned content: +- all four party characters and every character shadow; +- the horizontal formation cord, its knots and diamond joints; +- all four colored position platforms, position shields and numbers 3, 2, 1 and 0; +- every colored relationship dot, arrow, shield placeholder and fake value inside the parchment relationship panels; +- the five circular placeholder values beside the weight icon in the top rail; +- the red/white dashed selected movement path and its destination ring; +- the selected glow/ring under the front character; +- the gold selected glow around the Save command button. + +Restore the painted yard, ground, wall, props and ambient shadows naturally behind removed elements. Leave the parchment panel interiors clean and empty, retaining their illustrated paper grain and frames. Keep all fixed command icons and their button frames, but make every command button neutral and unselected. Keep all blank top-rail text plates and blank bottom label plates empty. + +Invariants: do not move, resize, redesign, relight, recrop or replace any retained object. Do not change the palette, line weight, perspective, architecture, rail geometry, frame geometry, fixed icon geometry or foreground props. Preserve full image coverage edge to edge. + +Text policy: no letters, words, pseudo-writing, fake glyphs, numerals or baked values anywhere. +Avoid: new characters, new props, new UI, pixel art, nearest-neighbor effects, low-resolution texture, blur, smearing, warped frames, watermark, logo changes or decorative replacement content. diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-static-master.png b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-static-master.png new file mode 100644 index 00000000..bcbf2b8a Binary files /dev/null and b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-static-master.png differ diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/dynamic-regions.json b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/dynamic-regions.json new file mode 100644 index 00000000..5b8ea7ba --- /dev/null +++ b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/dynamic-regions.json @@ -0,0 +1,37 @@ +{ + "schema_version": 1, + "page_id": "PTY-001", + "version": "v001-clean-static-master", + "design_size": [2048, 1152], + "coordinate_space": "approved master pixels", + "policy": "Regions are runtime/state-owned and must not survive in the static master. The arrow between the two lower parchment frames is a fixed direction ornament, not a runtime value.", + "regions": [ + { + "id": "pressure_placeholders", + "shape": "circles", + "treatment": "approved_inpaint", + "bounds": [810, 54, 1076, 111], + "circles": [[865, 80, 16], [909, 80, 16], [952, 80, 16], [994, 80, 16], [1037, 80, 16]] + }, + {"id": "top_relation_content", "shape": "rect", "treatment": "generated_patch", "bounds": [1584, 198, 1964, 326]}, + {"id": "party_actor_3", "shape": "rect", "treatment": "generated_patch", "bounds": [414, 371, 590, 726]}, + {"id": "party_actor_2", "shape": "rect", "treatment": "generated_patch", "bounds": [674, 360, 910, 727]}, + {"id": "party_actor_1", "shape": "rect", "treatment": "generated_patch", "bounds": [932, 397, 1164, 729]}, + {"id": "party_actor_0", "shape": "rect", "treatment": "generated_patch", "bounds": [1180, 350, 1423, 734]}, + {"id": "formation_cord", "shape": "rect", "treatment": "generated_patch", "bounds": [211, 603, 1768, 655]}, + {"id": "position_markers", "shape": "rect", "treatment": "generated_patch", "bounds": [444, 611, 1384, 733]}, + {"id": "selection_path", "shape": "rect", "treatment": "generated_patch", "bounds": [1239, 617, 1594, 817]}, + {"id": "lower_relation_content", "shape": "rect", "treatment": "generated_patch", "bounds": [785, 767, 1239, 878]}, + {"id": "save_selected_glow", "shape": "rect", "treatment": "generated_patch", "bounds": [1010, 917, 1264, 1128]} + ], + "static_protected_regions": [ + {"id": "outer_top_frame", "bounds": [0, 0, 2048, 36]}, + {"id": "top_rail_left", "bounds": [0, 36, 790, 139]}, + {"id": "top_rail_center", "bounds": [1088, 36, 1590, 139]}, + {"id": "top_rail_right", "bounds": [1964, 36, 2048, 139]}, + {"id": "left_environment", "bounds": [0, 150, 405, 930]}, + {"id": "right_environment", "bounds": [1780, 342, 2048, 930]}, + {"id": "bottom_rail_left", "bounds": [0, 940, 470, 1152]}, + {"id": "bottom_rail_right", "bounds": [1520, 940, 2048, 1152]} + ] +} diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/generation-report.json b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/generation-report.json new file mode 100644 index 00000000..9e7aa3e8 --- /dev/null +++ b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/generation-report.json @@ -0,0 +1,14 @@ +{ + "schema_version": 1, + "provider": "API Mart", + "model": "gpt-image-2", + "task_id": "task_01M0H2FTQE6XCE4Q665H35149G", + "status": "completed", + "cost_usd": 0.014, + "credits_cost": 0.14, + "created": 1787279436, + "completed": 1787279634, + "actual_time_seconds": 198, + "bytes": 3774938, + "output": "docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/clean-static-master.png" +} diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/party-line-static-master.png b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/party-line-static-master.png new file mode 100644 index 00000000..96a08745 Binary files /dev/null and b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/party-line-static-master.png differ diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/static-master-report.md b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/static-master-report.md new file mode 100644 index 00000000..16446b4b --- /dev/null +++ b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/static-master-report.md @@ -0,0 +1,80 @@ +# PTY-001 Clean Static Master + +## Result + +`party-line-static-master.png` is the runtime-ready static coordinate master for +the approved PTY-001 composition. It keeps the approved 2048x1152 Japanese 2D +hand-drawn training yard, field-attached parchment HUD and command chrome while +removing content that belongs to runtime data or interaction state. + +The clean master is a derived production asset. It does not replace +`approved/v001/master.png`, which remains the Owner-approved visual authority. + +## Static content retained + +- complete training-yard environment, foreground desk, banners, castle, props; +- outer frame, crest, complete top rail and blank engine-text plates; +- fixed top-rail category icons and fixed relation clipboard icon; +- blank top-right and lower relationship parchment frames; +- bottom command rail, four command frames, fixed command icons and blank label plates; +- fixed arrow between the two lower parchment frames as the direction ornament. + +## Runtime-owned content removed + +- four Recruit figures and their shadows; +- formation cord, joints, platforms, position shields and values 3, 2, 1, 0; +- relationship dots, arrows, shield placeholders and values; +- top-rail pressure placeholders; +- selected-member ring, destination ring and dashed selection path; +- selected Save-command glow; +- all visible labels, copy, values, pseudo-writing and fake glyphs. + +## Runtime integration boundary + +Render the static master once inside the contained 16:9 Party canvas. Godot +must render all localization, values and dynamic state above it. + +- Actor layers: bind four Company Recruit textures at the approved focal + positions and preserve complete silhouettes. Do not leave portraits hidden. +- Formation layer: render position markers and values, cord and selection path + from the formation snapshot. Do not bake these into another bitmap. +- Relation layer: render first target/protection/reach/coverage values inside + the existing blank parchment slots. +- Command layer: use the four existing illustrated frames/icons as the visual + controls. Overlay transparent stable hit areas plus engine labels in the blank + plates. Do not add another `EntryChrome`, icon texture or colored button frame. +- State effects: hover/focus/selected/disabled feedback may tint or outline the + existing frame but must not move it or introduce a replacement card/button. +- Responsive layer: keep the complete static master on the centered contained + 16:9 canvas. Every overlay uses the same normalized coordinate space. + +## Root cause of the previous fidelity failure + +The earlier implementation used a layered rebuild over a different Guild world +and a different reusable HUD system. Its local components were valid, but it +re-authored the composition instead of restoring it. The subsequent raw-master +shortcut preserved composition but also preserved state-owned characters, +values and effects, forcing invisible portraits and duplicate visual ownership. + +The corrective rule is: approve one coordinate master, clean its dynamic slots +before coding, freeze normalized bounds, then let runtime code own only the +declared overlays. A screenshot comparison must happen after the first static +canvas render and again after each overlay group, not only after the complete +page is assembled. + +## Reproducibility and evidence + +- Edit prompt: `clean-master-prompt.txt` +- Dynamic/static boundary: `dynamic-regions.json` +- Paid task trace: `generation-report.json` +- Generated cleanup source: `clean-static-master.png` +- Deterministic compositor: `tools/prepare_pty001_clean_master.py` +- Automated verifier: `tools/verify_pty001_clean_master.py` +- Side-by-side review: `static-master-review.png` +- Region overlay: `verification-overlay.png` +- Verification report: `verification.json` + +Generation used one API Mart GPT-Image-2 2K edit task, +`task_01M0H2FTQE6XCE4Q665H35149G`, at recorded cost USD 0.014. The final +production master is regenerated deterministically from the immutable approved +master plus the traceable generated cleanup source. diff --git a/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/verification.json b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/verification.json new file mode 100644 index 00000000..ece7a2d0 --- /dev/null +++ b/docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/verification.json @@ -0,0 +1,223 @@ +{ + "schema_version": 1, + "page_id": "PTY-001", + "candidate": "docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/party-line-static-master.png", + "approved": "docs/design-authority/pages/PTY-001-party-line/approved/v001/master.png", + "candidate_sha256": "da0f0db28e8d0749cf18e0cc5f43e8c176415305fc7c11f92ba2abd97d7d843b", + "approved_sha256": "07322f418fc67fbb23d9727631cfa7762dc1c00b3ad6edbe934c135fcd21dd22", + "dimensions": [ + 2048, + 1152 + ], + "mode": "RGB", + "protected_static_regions": [ + { + "id": "outer_top_frame", + "bounds": [ + 0, + 0, + 2048, + 36 + ], + "mae": 0.0 + }, + { + "id": "top_rail_left", + "bounds": [ + 0, + 36, + 790, + 139 + ], + "mae": 0.0 + }, + { + "id": "top_rail_center", + "bounds": [ + 1088, + 36, + 1590, + 139 + ], + "mae": 0.0 + }, + { + "id": "top_rail_right", + "bounds": [ + 1964, + 36, + 2048, + 139 + ], + "mae": 0.0 + }, + { + "id": "left_environment", + "bounds": [ + 0, + 150, + 405, + 930 + ], + "mae": 11.9569 + }, + { + "id": "right_environment", + "bounds": [ + 1780, + 342, + 2048, + 930 + ], + "mae": 11.8155 + }, + { + "id": "bottom_rail_left", + "bounds": [ + 0, + 940, + 470, + 1152 + ], + "mae": 5.5924 + }, + { + "id": "bottom_rail_right", + "bounds": [ + 1520, + 940, + 2048, + 1152 + ], + "mae": 6.0199 + } + ], + "dynamic_regions": [ + { + "id": "pressure_placeholders", + "bounds": [ + 810, + 54, + 1076, + 111 + ], + "change_mae": 8.2054 + }, + { + "id": "top_relation_content", + "bounds": [ + 1584, + 198, + 1964, + 326 + ], + "change_mae": 19.009 + }, + { + "id": "party_actor_3", + "bounds": [ + 414, + 371, + 590, + 726 + ], + "change_mae": 43.6486 + }, + { + "id": "party_actor_2", + "bounds": [ + 674, + 360, + 910, + 727 + ], + "change_mae": 40.417 + }, + { + "id": "party_actor_1", + "bounds": [ + 932, + 397, + 1164, + 729 + ], + "change_mae": 46.7102 + }, + { + "id": "party_actor_0", + "bounds": [ + 1180, + 350, + 1423, + 734 + ], + "change_mae": 44.7725 + }, + { + "id": "formation_cord", + "bounds": [ + 211, + 603, + 1768, + 655 + ], + "change_mae": 46.4007 + }, + { + "id": "position_markers", + "bounds": [ + 444, + 611, + 1384, + 733 + ], + "change_mae": 36.7716 + }, + { + "id": "selection_path", + "bounds": [ + 1239, + 617, + 1594, + 817 + ], + "change_mae": 26.1211 + }, + { + "id": "lower_relation_content", + "bounds": [ + 785, + 767, + 1239, + 878 + ], + "change_mae": 18.0 + }, + { + "id": "save_selected_glow", + "bounds": [ + 1010, + 917, + 1264, + 1128 + ], + "change_mae": 49.2609 + } + ], + "thresholds": { + "max_static_mae": 24.0, + "min_dynamic_change_mae": 4.0 + }, + "summary": { + "ok": true, + "max_static_mae": 11.9569, + "changed_dynamic_regions": 11, + "dynamic_region_count": 11 + }, + "manual_review_required": [ + "no characters, cord, position values, relation placeholders or selected-state effects remain", + "painted ground and walls are coherent behind removed content", + "HUD frames and fixed icons retain the approved line weight and geometry", + "all writable plates and parchment interiors contain no text or pseudo-writing" + ] +} diff --git a/tools/fetch_apimart_image_task.py b/tools/fetch_apimart_image_task.py new file mode 100644 index 00000000..b4f3f464 --- /dev/null +++ b/tools/fetch_apimart_image_task.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +"""Resume one known API Mart image task and archive its traceable output.""" + +from __future__ import annotations + +import argparse +import json +import subprocess +import urllib.request +from pathlib import Path + + +DEFAULT_WRAPPER = Path.home() / ".agents/skills/image-gen/scripts/apimart_curl.zsh" + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--task-id", required=True) + parser.add_argument("--output", required=True, type=Path) + parser.add_argument("--report", required=True, type=Path) + parser.add_argument("--wrapper", type=Path, default=DEFAULT_WRAPPER) + args = parser.parse_args() + + response = subprocess.run( + [str(args.wrapper), f"https://api.apimart.ai/v1/tasks/{args.task_id}"], + check=True, + capture_output=True, + text=True, + ) + payload = json.loads(response.stdout) + data = payload.get("data", {}) + status = str(data.get("status", "")).lower() + if status != "completed": + raise SystemExit(f"task {args.task_id} is {status or 'unknown'}, not completed") + images = data.get("result", {}).get("images", []) + urls = images[0].get("url", []) if images else [] + if not urls: + raise SystemExit(f"task {args.task_id} has no output URL") + + args.output.parent.mkdir(parents=True, exist_ok=True) + with urllib.request.urlopen(str(urls[0]), timeout=120) as source: + args.output.write_bytes(source.read()) + report = { + "schema_version": 1, + "provider": "API Mart", + "model": "gpt-image-2", + "task_id": args.task_id, + "status": status, + "cost_usd": data.get("cost"), + "credits_cost": data.get("credits_cost"), + "created": data.get("created"), + "completed": data.get("completed"), + "actual_time_seconds": data.get("actual_time"), + "bytes": args.output.stat().st_size, + "output": str(args.output), + } + args.report.parent.mkdir(parents=True, exist_ok=True) + args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + print(f"ABG_APIMART_IMAGE_TASK_OK task={args.task_id} output={args.output}") + + +if __name__ == "__main__": + main() diff --git a/tools/prepare_pty001_clean_master.py b/tools/prepare_pty001_clean_master.py new file mode 100644 index 00000000..840c17ad --- /dev/null +++ b/tools/prepare_pty001_clean_master.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +"""Build a clean PTY-001 master and restore critical approved HUD geometry.""" + +from __future__ import annotations + +import argparse +import json +from pathlib import Path + +import cv2 +import numpy as np +from PIL import Image, ImageDraw, ImageFont + + +ROOT = Path(__file__).resolve().parents[1] +PAGE = ROOT / "docs/design-authority/pages/PTY-001-party-line" + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--approved", type=Path, default=PAGE / "approved/v001/master.png") + parser.add_argument("--generated", type=Path, default=PAGE / "reconstruction/v001/static-master/clean-static-master.png") + parser.add_argument("--regions", type=Path, default=PAGE / "reconstruction/v001/static-master/dynamic-regions.json") + parser.add_argument("--output", type=Path, default=PAGE / "reconstruction/v001/static-master/party-line-static-master.png") + parser.add_argument("--review", type=Path, default=PAGE / "reconstruction/v001/static-master/static-master-review.png") + args = parser.parse_args() + + authority = json.loads(args.regions.read_text(encoding="utf-8")) + expected = tuple(authority["design_size"]) + approved = cv2.imread(str(args.approved), cv2.IMREAD_COLOR) + generated = cv2.imread(str(args.generated), cv2.IMREAD_COLOR) + if approved is None or generated is None: + raise SystemExit("approved or generated master could not be read") + if (approved.shape[1], approved.shape[0]) != expected or (generated.shape[1], generated.shape[0]) != expected: + raise SystemExit("master dimensions do not match dynamic-regions authority") + + # Use the clean edit as the complete painted base. It reconstructs the yard + # behind actors and the cord coherently, avoiding rectangular patch seams. + result = generated.copy() + # Restore critical approved geometry that the cleanup edit simplified: + # the complete top status rail and the fixed relation clipboard icon. + result[0:142, 0:2048] = approved[0:142, 0:2048] + result[169:287, 1470:1588] = approved[169:287, 1470:1588] + + # Pressure dots are state values. Inpaint only their circular interiors so + # the exact approved weight icon and outlined status slot remain untouched. + pressure_mask = np.zeros(approved.shape[:2], dtype=np.uint8) + for region in authority["regions"]: + if region.get("treatment") != "approved_inpaint": + continue + for x, y, radius in region.get("circles", []): + cv2.circle(pressure_mask, (x, y), radius + 2, 255, thickness=-1) + result = cv2.inpaint(result, pressure_mask, 5, cv2.INPAINT_TELEA) + + args.output.parent.mkdir(parents=True, exist_ok=True) + cv2.imwrite(str(args.output), result, [cv2.IMWRITE_PNG_COMPRESSION, 7]) + + approved_preview = Image.open(args.approved).convert("RGB").resize((1024, 576), Image.Resampling.LANCZOS) + clean_preview = Image.open(args.output).convert("RGB").resize((1024, 576), Image.Resampling.LANCZOS) + review = Image.new("RGB", (2048, 636), "#17252c") + review.paste(approved_preview, (0, 60)) + review.paste(clean_preview, (1024, 60)) + draw = ImageDraw.Draw(review) + font = ImageFont.truetype("/System/Library/Fonts/Supplemental/Arial.ttf", 24) + draw.text((28, 17), "APPROVED COMPOSITION (dynamic state baked in)", fill="#f3d991", font=font) + draw.text((1052, 17), "CLEAN STATIC MASTER (runtime overlay ready)", fill="#9ed7aa", font=font) + args.review.parent.mkdir(parents=True, exist_ok=True) + review.save(args.review, optimize=True) + print(f"ABG_PTY001_STATIC_MASTER_PREPARED output={args.output} review={args.review}") + + +if __name__ == "__main__": + main() diff --git a/tools/verify_pty001_clean_master.py b/tools/verify_pty001_clean_master.py new file mode 100644 index 00000000..e5c2af25 --- /dev/null +++ b/tools/verify_pty001_clean_master.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +"""Verify and document the PTY-001 clean static coordinate master.""" + +from __future__ import annotations + +import argparse +import hashlib +import json +from pathlib import Path + +import numpy as np +from PIL import Image, ImageDraw + + +ROOT = Path(__file__).resolve().parents[1] +DEFAULT_APPROVED = ROOT / "docs/design-authority/pages/PTY-001-party-line/approved/v001/master.png" +DEFAULT_REGIONS = ROOT / "docs/design-authority/pages/PTY-001-party-line/reconstruction/v001/static-master/dynamic-regions.json" + + +def sha256(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def rect_crop(array: np.ndarray, bounds: list[int]) -> np.ndarray: + left, top, right, bottom = bounds + return array[top:bottom, left:right] + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--candidate", required=True, type=Path) + parser.add_argument("--approved", type=Path, default=DEFAULT_APPROVED) + parser.add_argument("--regions", type=Path, default=DEFAULT_REGIONS) + parser.add_argument("--report", required=True, type=Path) + parser.add_argument("--preview", type=Path) + parser.add_argument("--max-static-mae", type=float, default=24.0) + args = parser.parse_args() + + authority = json.loads(args.regions.read_text(encoding="utf-8")) + expected_size = tuple(authority["design_size"]) + approved_image = Image.open(args.approved).convert("RGB") + candidate_image = Image.open(args.candidate).convert("RGB") + if approved_image.size != expected_size: + raise SystemExit(f"approved size {approved_image.size} != {expected_size}") + if candidate_image.size != expected_size: + raise SystemExit(f"candidate size {candidate_image.size} != {expected_size}") + + approved = np.asarray(approved_image, dtype=np.float32) + candidate = np.asarray(candidate_image, dtype=np.float32) + protected = [] + for region in authority["static_protected_regions"]: + source = rect_crop(approved, region["bounds"]) + edited = rect_crop(candidate, region["bounds"]) + mae = float(np.abs(source - edited).mean()) + protected.append({"id": region["id"], "bounds": region["bounds"], "mae": round(mae, 4)}) + + dynamic = [] + for region in authority["regions"]: + source = rect_crop(approved, region["bounds"]) + edited = rect_crop(candidate, region["bounds"]) + change_mae = float(np.abs(source - edited).mean()) + dynamic.append({"id": region["id"], "bounds": region["bounds"], "change_mae": round(change_mae, 4)}) + + max_static = max(item["mae"] for item in protected) + changed_dynamic = sum(item["change_mae"] >= 4.0 for item in dynamic) + ok = max_static <= args.max_static_mae and changed_dynamic == len(dynamic) + report = { + "schema_version": 1, + "page_id": "PTY-001", + "candidate": args.candidate.relative_to(ROOT).as_posix() if args.candidate.is_relative_to(ROOT) else str(args.candidate), + "approved": args.approved.relative_to(ROOT).as_posix() if args.approved.is_relative_to(ROOT) else str(args.approved), + "candidate_sha256": sha256(args.candidate), + "approved_sha256": sha256(args.approved), + "dimensions": list(candidate_image.size), + "mode": Image.open(args.candidate).mode, + "protected_static_regions": protected, + "dynamic_regions": dynamic, + "thresholds": {"max_static_mae": args.max_static_mae, "min_dynamic_change_mae": 4.0}, + "summary": { + "ok": ok, + "max_static_mae": round(max_static, 4), + "changed_dynamic_regions": changed_dynamic, + "dynamic_region_count": len(dynamic), + }, + "manual_review_required": [ + "no characters, cord, position values, relation placeholders or selected-state effects remain", + "painted ground and walls are coherent behind removed content", + "HUD frames and fixed icons retain the approved line weight and geometry", + "all writable plates and parchment interiors contain no text or pseudo-writing", + ], + } + args.report.parent.mkdir(parents=True, exist_ok=True) + args.report.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8") + + if args.preview: + preview = candidate_image.copy() + draw = ImageDraw.Draw(preview, "RGBA") + for region in authority["regions"]: + draw.rectangle(region["bounds"], outline=(225, 79, 62, 230), width=4) + for region in authority["static_protected_regions"]: + draw.rectangle(region["bounds"], outline=(52, 172, 126, 220), width=3) + args.preview.parent.mkdir(parents=True, exist_ok=True) + preview.save(args.preview, optimize=True) + + marker = "ABG_PTY001_CLEAN_MASTER_OK" if ok else "ABG_PTY001_CLEAN_MASTER_FAILED" + print(f"{marker} static_max_mae={max_static:.4f} dynamic={changed_dynamic}/{len(dynamic)} report={args.report}") + if not ok: + raise SystemExit(1) + + +if __name__ == "__main__": + main()