{"record":{"id":"e3b2fcf06f5c4179","repo":"nexu-io/open-design","slug":"job-job-id-source-image-hash-does-not-match-imag","errorCode":null,"errorMessage":"job {job_id} source image hash does not match imagegen-jobs.json","messagePattern":"job (.+?) source image hash does not match imagegen-jobs\\.json","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":73,"sourceCode":"        path = run_dir / path\n    return path.resolve()\n\n\ndef validate_hash(job: dict[str, object], *, source: Path, output: Path, job_id: str) -> None:\n    expected_hash = job.get(\"source_sha256\")\n    if not isinstance(expected_hash, str) or not expected_hash:\n        raise SystemExit(\n            f\"job {job_id} is missing source_sha256; ingest visual outputs with \"\n            \"record_imagegen_result.py instead of editing imagegen-jobs.json\"\n        )\n    if not source.is_file():\n        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        )","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L55-L91","documentation":"The source file exists but its sha256 differs from the recorded source_sha256, meaning the image was replaced or overwritten after ingest. finalize treats this as broken provenance rather than silently accepting the new bytes.","triggerScenarios":"The ig_*.png at the recorded path was overwritten by a later $imagegen run that reused the filename, or the file was edited on disk.","commonSituations":"Re-running imagegen into the same path; a filename collision in generated_images; manual image editing.","solutions":["Re-ingest with record_imagegen_result.py against the current source so source_sha256 matches the bytes on disk.","Or restore the original source whose hash matches the recorded source_sha256.","Re-run finalize_pet_run.py."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import hashlib, json\nfrom pathlib import Path\n\ndef sha256(p: Path) -> str:\n    h = hashlib.sha256()\n    with p.open(\"rb\") as f:\n        for chunk in iter(lambda: f.read(1 << 20), b\"\"):\n            h.update(chunk)\n    return h.hexdigest()\n\nrun_dir = Path(\"<run_dir>\")\nmanifest = json.loads((run_dir / \"imagegen-jobs.json\").read_text())\nfor job in manifest[\"jobs\"]:\n    if job.get(\"status\") != \"complete\":\n        continue\n    src = Path(job[\"source_path\"])\n    assert sha256(src) == job[\"source_sha256\"], f\"source hash mismatch for {job.get('id')}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never overwrite an ig_*.png in place; let imagegen write a new filename.","Re-ingest with record_imagegen_result.py whenever the source bytes change.","Treat a hash mismatch as corruption — investigate before re-ingesting."],"tags":["hatch-pet","integrity","hash","provenance"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}