{"record":{"id":"a067fc1baf371b0a","repo":"nexu-io/open-design","slug":"job-job-id-is-missing-source-sha256-ingest-visu","errorCode":null,"errorMessage":"job {job_id} is missing source_sha256; ingest visual outputs with record_imagegen_result.py instead of editing imagegen-jobs.json","messagePattern":"job (.+?) is missing source_sha256; ingest visual outputs with record_imagegen_result\\.py instead of editing imagegen-jobs\\.json","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":62,"sourceCode":"\n\ndef default_codex_home() -> Path:\n    return Path(os.environ.get(\"CODEX_HOME\") or \"~/.codex\").expanduser().resolve()\n\n\ndef manifest_path(raw: object, *, run_dir: Path, field: str, job_id: str) -> Path:\n    if not isinstance(raw, str) or not raw:\n        raise SystemExit(f\"job {job_id} has no {field}\")\n    path = Path(raw).expanduser()\n    if not path.is_absolute():\n        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","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L44-L80","documentation":"validate_hash requires a source_sha256 on each job; that hash anchors every later integrity check (source vs. output, mirror lineage). The message deliberately points to record_imagegen_result.py because hand-writing a hash bypasses the provenance contract.","triggerScenarios":"A job marked complete whose source_sha256 is missing, empty, or not a string — typically because the manifest was edited by hand rather than produced by the ingest script.","commonSituations":"Bypassing record_imagegen_result.py; a manifest from before hashes were required; a botched find-replace that blanked the field.","solutions":["Run record_imagegen_result.py against the original ig_*.png to record source_sha256 (and output_path) correctly.","Do not hand-write source_sha256 — it must match the actual file bytes.","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())\nfor job in manifest[\"jobs\"]:\n    if job.get(\"status\") == \"complete\":\n        assert isinstance(job.get(\"source_sha256\"), str) and job[\"source_sha256\"], \\\n            f\"job {job.get('id')} missing source_sha256 — run record_imagegen_result.py\"","typeGuard":"def job_has_source_hash(job: dict) -> bool:\n    return isinstance(job.get(\"source_sha256\"), str) and bool(job[\"source_sha256\"])","tryCatchPattern":null,"preventionTips":["Never hand-write source_sha256; it must equal the source file bytes.","Use record_imagegen_result.py as the only path to populate hashes.","Validate hashes across all complete jobs before invoking finalize."],"tags":["hatch-pet","manifest","provenance","hash","integrity"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}