{"record":{"id":"a0ee3d34fc83a53d","repo":"nexu-io/open-design","slug":"running-left-mirror-job-must-derive-from-running-r","errorCode":null,"errorMessage":"running-left mirror job must derive from running-right","messagePattern":"running-left mirror job must derive from running-right","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":85,"sourceCode":"        raise SystemExit(f\"job {job_id} source image no longer exists: {source}\")\n    if not output.is_file():\n        raise SystemExit(f\"job {job_id} decoded output is missing: {output}\")\n    source_hash = file_sha256(source)\n    output_hash = file_sha256(output)\n    if source_hash != expected_hash:\n        raise SystemExit(f\"job {job_id} source image hash does not match imagegen-jobs.json\")\n    if output_hash != expected_hash:\n        raise SystemExit(\n            f\"job {job_id} decoded output does not match its recorded source image; \"\n            \"do not rewrite decoded visual outputs locally\"\n        )\n\n\ndef validate_mirror_hash(job: dict[str, object], *, source: Path, output: Path, job_id: str) -> None:\n    if job_id != \"running-left\":\n        raise SystemExit(f\"job {job_id} may not use deterministic mirror provenance\")\n    if job.get(\"derived_from\") != \"running-right\":\n        raise SystemExit(\"running-left mirror job must derive from running-right\")\n    decision = job.get(\"mirror_decision\")\n    if not isinstance(decision, dict) or decision.get(\"approved\") is not True:\n        raise SystemExit(\n            \"running-left mirror job is missing an approved mirror_decision; \"\n            \"use derive_running_left_from_running_right.py after visual review\"\n        )\n\n    expected_source_hash = job.get(\"source_sha256\")\n    expected_output_hash = job.get(\"output_sha256\")\n    if not isinstance(expected_source_hash, str) or not expected_source_hash:\n        raise SystemExit(\"running-left mirror job is missing source_sha256\")\n    if not isinstance(expected_output_hash, str) or not expected_output_hash:\n        raise SystemExit(\"running-left mirror job is missing output_sha256\")\n    if not source.is_file():\n        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\":","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L67-L103","documentation":"For a deterministic-mirror running-left job, derived_from must equal the literal \"running-right\". Any other value (or a missing derived_from) means the mirror lineage is broken and finalize will not trust the output.","triggerScenarios":"running-left has source_provenance deterministic-mirror but derived_from is missing, null, or set to something other than \"running-right\".","commonSituations":"Hand-editing the manifest; an interrupted or older derive script that failed to set derived_from; a botched merge.","solutions":["Re-run derive_running_left_from_running_right.py, which sets derived_from = \"running-right\" along with the hashes and mirror_decision.","If editing manually, set \"derived_from\": \"running-right\" on the running-left job.","Re-run finalize_pet_run.py."],"exampleFix":"// before\n{ \"id\": \"running-left\", \"source_provenance\": \"deterministic-mirror\" }\n// after\n{ \"id\": \"running-left\", \"source_provenance\": \"deterministic-mirror\", \"derived_from\": \"running-right\" }","handlingStrategy":"type-guard","validationCode":"import json\nfrom pathlib import Path\n\nmanifest = json.loads(Path(\"<run_dir>/imagegen-jobs.json\").read_text())\nleft = next(j for j in manifest[\"jobs\"] if j.get(\"id\") == \"running-left\")\nif left.get(\"source_provenance\") == \"deterministic-mirror\":\n    assert left.get(\"derived_from\") == \"running-right\", \"running-left derived_from must be 'running-right'\"","typeGuard":"def mirror_lineage_ok(left_job: dict) -> bool:\n    if left_job.get(\"source_provenance\") != \"deterministic-mirror\":\n        return True\n    return left_job.get(\"derived_from\") == \"running-right\"","tryCatchPattern":null,"preventionTips":["Always derive running-left via the derive script so derived_from is set correctly.","Do not hand-edit derived_from.","After any manual manifest change, re-check derived_from on the mirror job."],"tags":["hatch-pet","provenance","mirror","manifest"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}