{"record":{"id":"0a6ef53e1c5dda7d","repo":"nexu-io/open-design","slug":"running-left-mirrored-output-is-not-an-exact-horiz","errorCode":null,"errorMessage":"running-left mirrored output is not an exact horizontal mirror of running-right","messagePattern":"running-left mirrored output is not an exact horizontal mirror of running-right","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":118,"sourceCode":"        raise SystemExit(f\"running-left mirror source image no longer exists: {source}\")\n    if not output.is_file():\n        raise SystemExit(f\"running-left mirrored output is missing: {output}\")\n    if source.name != \"running-right.png\" or source.parent.name != \"decoded\":\n        raise SystemExit(\"running-left mirror source must be decoded/running-right.png\")\n    if output.name != \"running-left.png\" or output.parent.name != \"decoded\":\n        raise SystemExit(\"running-left mirror output must be decoded/running-left.png\")\n    if file_sha256(source) != expected_source_hash:\n        raise SystemExit(\"running-left mirror source hash does not match imagegen-jobs.json\")\n    if file_sha256(output) != expected_output_hash:\n        raise SystemExit(\n            \"running-left mirrored output hash does not match imagegen-jobs.json; \"\n            \"rerun derive_running_left_from_running_right.py\"\n        )\n    with Image.open(source) as source_image, Image.open(output) as output_image:\n        expected = ImageOps.mirror(source_image.convert(\"RGBA\"))\n        actual = output_image.convert(\"RGBA\")\n        if expected.size != actual.size or expected.tobytes() != actual.tobytes():\n            raise SystemExit(\n                \"running-left mirrored output is not an exact horizontal mirror of running-right\"\n            )\n\n\ndef validate_completed_job_source(\n    job: dict[str, object],\n    *,\n    run_dir: Path,\n    allow_synthetic_test_sources: bool,\n) -> None:\n    job_id = str(job.get(\"id\") or \"\")\n    source = manifest_path(job.get(\"source_path\"), run_dir=run_dir, field=\"source_path\", job_id=job_id)\n    output = manifest_path(job.get(\"output_path\"), run_dir=run_dir, field=\"output_path\", job_id=job_id)\n\n    blocked_flags = [\n        flag\n        for flag in (\"deterministic_pet_row\", \"cute_raster_row\", \"local_raster_row\")\n        if job.get(flag)","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L100-L136","documentation":"Raised by validate_mirror_hash after PIL loads both images: it computes expected = ImageOps.mirror(source.convert('RGBA')) and compares raw bytes/size against the output. If they differ by even one pixel, the deterministic-mirror contract is violated and finalize aborts.","triggerScenarios":"The on-disk decoded/running-left.png is not a pixel-exact horizontal flip of decoded/running-right.png, even though both SHA-256 fields happen to match their files (e.g. someone replaced running-left.png with a hand-drawn or AI-generated left-facing frame and updated output_sha256 to match).","commonSituations":"Using an AI image edit to 'improve' the left-facing frame instead of the deterministic flip; saving with a different RGBA alpha handling that shifts bytes; an editor that premultiplies alpha on save.","solutions":["Regenerate decoded/running-left.png exclusively via derive_running_left_from_running_right.py, which uses ImageOps.mirror and is byte-identical by construction.","If a custom left frame is genuinely desired, do not use source_provenance='deterministic-mirror'; instead generate it with $imagegen and record built-in-imagegen provenance.","Verify the source running-right.png is RGBA-clean (no embedded color profile altering decode) before deriving."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from PIL import Image, ImageOps\nwith Image.open(source) as s, Image.open(output) as o:\n    expected = ImageOps.mirror(s.convert('RGBA'))\n    actual = o.convert('RGBA')\n    assert expected.size == actual.size and expected.tobytes() == actual.tobytes(), 'not an exact mirror'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use derive_running_left_from_running_right.py (ImageOps.mirror) to produce running-left.png.","Never substitute an AI-generated left-facing frame under deterministic-mirror provenance.","Save PNGs without alpha premultiplication or color-profile embedding to keep bytes stable."],"tags":["integrity","mirror","pixel-exact","pillow","pet-pipeline"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}