{"record":{"id":"87daeb97d7d87644","repo":"nexu-io/open-design","slug":"running-right-must-be-complete-before-deriving-run","errorCode":null,"errorMessage":"running-right must be complete before deriving running-left","messagePattern":"running-right must be complete before deriving running-left","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/derive_running_left_from_running_right.py","lineNumber":88,"sourceCode":"        required=True,\n        help=\"Short note explaining why mirroring is acceptable for this pet.\",\n    )\n    parser.add_argument(\"--force\", action=\"store_true\")\n    args = parser.parse_args()\n\n    if not args.confirm_appropriate_mirror:\n        raise SystemExit(\"refusing to mirror without --confirm-appropriate-mirror\")\n    if not args.decision_note.strip():\n        raise SystemExit(\"--decision-note must explain why mirroring is appropriate\")\n\n    run_dir = Path(args.run_dir).expanduser().resolve()\n    manifest_path = run_dir / \"imagegen-jobs.json\"\n    manifest = load_manifest(run_dir)\n    right_job = find_job(manifest, \"running-right\")\n    left_job = find_job(manifest, \"running-left\")\n\n    if right_job.get(\"status\") != \"complete\":\n        raise SystemExit(\"running-right must be complete before deriving running-left\")\n    mirror_policy = left_job.get(\"mirror_policy\")\n    if not isinstance(mirror_policy, dict) or mirror_policy.get(\"may_derive_from\") != \"running-right\":\n        raise SystemExit(\"running-left is not configured for conditional mirroring\")\n\n    source = run_dir / \"decoded\" / \"running-right.png\"\n    output = run_dir / \"decoded\" / \"running-left.png\"\n    if not source.is_file():\n        raise SystemExit(f\"running-right decoded strip not found: {source}\")\n    if output.exists() and not args.force:\n        raise SystemExit(f\"{output} already exists; pass --force to replace it\")\n\n    output.parent.mkdir(parents=True, exist_ok=True)\n    with Image.open(source) as image:\n        mirrored = ImageOps.mirror(image.convert(\"RGBA\"))\n        mirrored.save(output)\n\n    left_job[\"status\"] = \"complete\"\n    left_job[\"source_path\"] = manifest_relative(source, run_dir)","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/derive_running_left_from_running_right.py#L70-L106","documentation":"The mirror script refuses to derive running-left until the running-right imagegen job is fully done. It loads imagegen-jobs.json, finds the running-right job, and requires job[\"status\"] == \"complete\". Mirroring an incomplete strip would bake an interim, blank, or failed image into the left sprite, which finalize_pet_run.py would later reject or, worse, ship.","triggerScenarios":"Running derive_running_left_from_running_right.py --run-dir <dir> while the running-right job's status is anything other than the literal \"complete\" (e.g. \"pending\", \"running\", \"failed\", \"queued\").","commonSituations":"Running the derive step out of order, before $imagegen finishes; a running-right job stuck in \"running\"; a job that errored but was never re-queued; reading a stale manifest copy.","solutions":["Inspect imagegen-jobs.json (or run pet_job_status.py --run-dir <dir>) and confirm the running-right job status reads \"complete\".","If running-right is still pending/running, let $imagegen finish (or re-run it) until the job completes.","If the image already exists on disk but the manifest is stale, run record_imagegen_result.py to record completion.","Re-run derive_running_left_from_running_right.py once status is complete."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\nrun_dir = Path(\"<run_dir>\")\nmanifest = json.loads((run_dir / \"imagegen-jobs.json\").read_text())\nright = next(j for j in manifest[\"jobs\"] if j.get(\"id\") == \"running-right\")\nif right.get(\"status\") != \"complete\":\n    raise RuntimeError(f\"running-right not complete: {right.get('status')!r}\")","typeGuard":"def right_job_ready(manifest: dict) -> bool:\n    job = next((j for j in manifest.get(\"jobs\", []) if j.get(\"id\") == \"running-right\"), None)\n    return isinstance(job, dict) and job.get(\"status\") == \"complete\"","tryCatchPattern":null,"preventionTips":["Run derive_running_left_from_running_right.py only after pet_job_status.py shows running-right complete.","Treat the imagegen → record → derive → finalize order as a hard pipeline; do not skip ahead.","If a job is stuck, re-queue it rather than editing status by hand."],"tags":["hatch-pet","workflow-ordering","manifest","imagegen"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}