{"record":{"id":"b8b3024c9b78f052","repo":"nexu-io/open-design","slug":"source-image-is-inside-the-pet-run-directory-reco","errorCode":null,"errorMessage":"source image is inside the pet run directory; record the original $imagegen output from $CODEX_HOME/generated_images/.../ig_*.png instead","messagePattern":"source image is inside the pet run directory; record the original \\$imagegen output from \\$CODEX_HOME/generated_images/\\.\\.\\./ig_\\*\\.png instead","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/hatch-pet/scripts/record_imagegen_result.py","lineNumber":93,"sourceCode":"        return False\n    return True\n\n\ndef default_generated_images_root() -> Path:\n    codex_home = Path(os.environ.get(\"CODEX_HOME\") or \"~/.codex\").expanduser().resolve()\n    return codex_home / \"generated_images\"\n\n\ndef validate_source_path(\n    *,\n    source: Path,\n    run_dir: Path,\n    allow_synthetic_test_source: bool,\n) -> str:\n    if allow_synthetic_test_source:\n        return \"synthetic-test\"\n    if is_relative_to(source, run_dir):\n        raise SystemExit(\n            \"source image is inside the pet run directory; record the original \"\n            \"$imagegen output from $CODEX_HOME/generated_images/.../ig_*.png instead\"\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            \"source image does not look like a built-in $imagegen output; expected \"\n            f\"{generated_root}/.../ig_*.png. Do not ingest locally drawn or \"\n            \"post-processed row strips as visual job outputs.\"\n        )\n    return \"built-in-imagegen\"\n\n\ndef validate_required_grounding(job: dict[str, object], run_dir: Path) -> None:\n    if job.get(\"allow_prompt_only_generation\") is not False:\n        return\n    inputs = job.get(\"input_images\")\n    if not isinstance(inputs, list) or not inputs:","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/skills/hatch-pet/scripts/record_imagegen_result.py#L75-L111","documentation":"Raised by validate_source_path() in record_imagegen_result.py when the --source image resolves inside the pet run_dir. The skill forbids re-ingesting copied/derived row strips and requires the original $imagegen output to be recorded instead, so provenance (sha256, source_path) stays truthful. This branch fires before the generated-images check.","triggerScenarios":"Pointing --source at run_dir/references/... or run_dir/decoded/...; re-recording an already-copied output; passing an output path that was previously written by this same script.","commonSituations":"User 'tidies up' by copying the chosen imagegen output into the run_dir first, then records the copy; confusion about which file is canonical.","solutions":["Point --source at the original file under $CODEX_HOME/generated_images/.../ig_*.png.","If you genuinely want to record a synthetic fixture, use the hidden --allow-synthetic-test-source flag (test-only).","Remove any copies you made into run_dir and re-resolve the original imagegen path.","Check $CODEX_HOME (default ~/.codex) to locate the generated_images tree."],"exampleFix":"# before\n--source /tmp/fenrir/decoded/idle.png   # inside run_dir\n# after\n--source \"$CODEX_HOME/generated_images/2026-01-01/ig_001.png\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\nrun_dir = run_dir.resolve()\nsource = source.resolve()\nif Path(*source.parts[:len(run_dir.parts)]) == run_dir:\n    raise SystemExit(\"source is inside run_dir; pass the original $imagegen ig_*.png\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always record from $CODEX_HOME/generated_images, never from copies inside run_dir.","Document the canonical source path in your run notes so re-records use the same file.","If you must record a fixture, gate it behind --allow-synthetic-test-source in tests only."],"tags":["filesystem","cli","hatch-pet","provenance"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}