{"record":{"id":"736cafb4392cfd21","repo":"nexu-io/open-design","slug":"job-job-id-source-image-is-inside-the-pet-run-di","errorCode":null,"errorMessage":"job {job_id} source image is inside the pet run directory; do not use locally generated row artifacts as visual sources","messagePattern":"job (.+?) source image is inside the pet run directory; do not use locally generated row artifacts as visual sources","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/finalize_pet_run.py","lineNumber":168,"sourceCode":"        return\n\n    if job.get(\"secondary_fallback\"):\n        if job.get(\"source_provenance\") != \"secondary-fallback-image-api\":\n            raise SystemExit(f\"job {job_id} has invalid secondary fallback provenance\")\n        validate_hash(job, source=source, output=output, job_id=job_id)\n        return\n\n    if job.get(\"source_provenance\") == \"deterministic-mirror\":\n        validate_mirror_hash(job, source=source, output=output, job_id=job_id)\n        return\n\n    if job.get(\"source_provenance\") != \"built-in-imagegen\":\n        raise SystemExit(\n            f\"job {job_id} was not recorded as a built-in $imagegen output; \"\n            \"use record_imagegen_result.py with the selected $CODEX_HOME/generated_images/.../ig_*.png file\"\n        )\n    if is_relative_to(source, run_dir):\n        raise SystemExit(\n            f\"job {job_id} source image is inside the pet run directory; \"\n            \"do not use locally generated row artifacts as visual sources\"\n        )\n    generated_root = default_generated_images_root()\n    if not is_relative_to(source, generated_root) or not source.name.startswith(\"ig_\"):\n        raise SystemExit(\n            f\"job {job_id} source image is not a built-in $imagegen output under \"\n            f\"{generated_root}/.../ig_*.png\"\n        )\n    validate_hash(job, source=source, output=output, job_id=job_id)\n\n\ndef require_complete_jobs(run_dir: Path, *, allow_synthetic_test_sources: bool) -> None:\n    manifest_path = run_dir / \"imagegen-jobs.json\"\n    manifest = load_json(manifest_path)\n    jobs = manifest.get(\"jobs\")\n    if not isinstance(jobs, list):\n        raise SystemExit(\"invalid imagegen-jobs.json: jobs must be a list\")","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/finalize_pet_run.py#L150-L186","documentation":"Raised by validate_completed_job_source when a built-in-imagegen job's source_path resolves inside the pet run directory itself. Locally generated row artifacts under run_dir must not be used as visual sources; finalize enforces that the source lives outside the run (specifically under the Codex generated_images root).","triggerScenarios":"is_relative_to(source, run_dir) is true for a job whose source_provenance == 'built-in-imagegen'. Caused by pointing source_path at run_dir/raw/... or run_dir/decoded/... instead of the real ig_*.png.","commonSituations":"Copying a generated image into the run directory and recording that path; using an intermediate decoded artifact as the recorded source.","solutions":["Record the original $CODEX_HOME/generated_images/.../ig_*.png path as source_path via record_imagegen_result.py.","Remove any copied source files from run_dir so the path cannot resolve inside it.","Re-run finalize_pet_run.py once source_path points outside run_dir."],"exampleFix":"// before (imagegen-jobs.json)\n\"source_path\": \"raw/base.png\"\n// after\n\"source_path\": \"~/.codex/generated_images/2026-01-01/ig_abc123.png\"","handlingStrategy":"validation","validationCode":"def is_relative_to(p, root):\n    try: p.relative_to(root); return True\n    except ValueError: return False\nif is_relative_to(source, run_dir):\n    raise RuntimeError(f'source_path must point outside run_dir: {source}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always record the original $CODEX_HOME/generated_images/.../ig_*.png path as source_path.","Never copy generated sources into run_dir before recording.","Lint source_path to ensure it escapes the run directory."],"tags":["path-validation","provenance","sandbox","pet-pipeline"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}