nexu-io/open-design · error · SystemExit

job {job_id} source image hash does not match imagegen-jobs.

Error message

job {job_id} source image hash does not match imagegen-jobs.json

What it means

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.

Source

Thrown at skills/hatch-pet/scripts/finalize_pet_run.py:73

        path = run_dir / path
    return path.resolve()


def validate_hash(job: dict[str, object], *, source: Path, output: Path, job_id: str) -> None:
    expected_hash = job.get("source_sha256")
    if not isinstance(expected_hash, str) or not expected_hash:
        raise SystemExit(
            f"job {job_id} is missing source_sha256; ingest visual outputs with "
            "record_imagegen_result.py instead of editing imagegen-jobs.json"
        )
    if not source.is_file():
        raise SystemExit(f"job {job_id} source image no longer exists: {source}")
    if not output.is_file():
        raise SystemExit(f"job {job_id} decoded output is missing: {output}")
    source_hash = file_sha256(source)
    output_hash = file_sha256(output)
    if source_hash != expected_hash:
        raise SystemExit(f"job {job_id} source image hash does not match imagegen-jobs.json")
    if output_hash != expected_hash:
        raise SystemExit(
            f"job {job_id} decoded output does not match its recorded source image; "
            "do not rewrite decoded visual outputs locally"
        )


def validate_mirror_hash(job: dict[str, object], *, source: Path, output: Path, job_id: str) -> None:
    if job_id != "running-left":
        raise SystemExit(f"job {job_id} may not use deterministic mirror provenance")
    if job.get("derived_from") != "running-right":
        raise SystemExit("running-left mirror job must derive from running-right")
    decision = job.get("mirror_decision")
    if not isinstance(decision, dict) or decision.get("approved") is not True:
        raise SystemExit(
            "running-left mirror job is missing an approved mirror_decision; "
            "use derive_running_left_from_running_right.py after visual review"
        )

View on GitHub (pinned to 5be4028344)

Solutions

  1. Re-ingest with record_imagegen_result.py against the current source so source_sha256 matches the bytes on disk.
  2. Or restore the original source whose hash matches the recorded source_sha256.
  3. Re-run finalize_pet_run.py.
Defensive patterns

Strategy: validation

Validate before calling

import hashlib, json
from pathlib import Path

def sha256(p: Path) -> str:
    h = hashlib.sha256()
    with p.open("rb") as f:
        for chunk in iter(lambda: f.read(1 << 20), b""):
            h.update(chunk)
    return h.hexdigest()

run_dir = Path("<run_dir>")
manifest = json.loads((run_dir / "imagegen-jobs.json").read_text())
for job in manifest["jobs"]:
    if job.get("status") != "complete":
        continue
    src = Path(job["source_path"])
    assert sha256(src) == job["source_sha256"], f"source hash mismatch for {job.get('id')}"

Prevention

When it happens

Trigger: 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.

Common situations: Re-running imagegen into the same path; a filename collision in generated_images; manual image editing.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/e3b2fcf06f5c4179. Report an issue: GitHub.