{"record":{"id":"297cc5fdeddf1426","repo":"nexu-io/open-design","slug":"running-left-mirror-job-is-missing-source-sha256","errorCode":null,"errorMessage":"running-left mirror job is missing source_sha256","messagePattern":"running-left mirror job is missing source_sha256","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":96,"sourceCode":"        )\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\":\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:","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L78-L114","documentation":"The mirror job must record source_sha256 (the hash of decoded/running-right.png) so finalize can re-verify the mirror's lineage. A missing source_sha256 means the derive step did not complete its bookkeeping.","triggerScenarios":"running-left has source_provenance deterministic-mirror but source_sha256 is missing or not a string — e.g. the derive script was killed mid-write before it recorded the hash.","commonSituations":"Interrupted derive run; hand-editing that dropped the field; a manifest from a partial run.","solutions":["Re-run derive_running_left_from_running_right.py (it writes source_sha256, output_sha256, and mirror_decision together).","Do not hand-write the hash; it must match running-right.png on disk.","Re-run finalize_pet_run.py."],"exampleFix":null,"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 isinstance(left.get(\"source_sha256\"), str) and left[\"source_sha256\"], \\\n        \"running-left mirror missing source_sha256 — re-run derive_running_left_from_running_right.py\"","typeGuard":"def mirror_source_hash_ok(left_job: dict) -> bool:\n    if left_job.get(\"source_provenance\") != \"deterministic-mirror\":\n        return True\n    return isinstance(left_job.get(\"source_sha256\"), str) and bool(left_job[\"source_sha256\"])","tryCatchPattern":null,"preventionTips":["Let the derive script write source_sha256; do not interrupt it mid-run.","Do not hand-edit hash fields.","If a derive run was interrupted, re-run it to completion before finalizing."],"tags":["hatch-pet","mirror","hash","provenance","manifest"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}