migrate: repair pr_diff tasks baked before the #145 oracle-isolation fix - #157
KNambiarDJsc wants to merge 2 commits into
Conversation
…-isolation fix huggingface#145 stopped baking the oracle/verifier/instruction into pr_diff's agent image, but already-published tasks (e.g. AdithyaSK/repo2rlenv-pr-diff, 181 tasks) keep the pre-fix Dockerfile until re-emitted — huggingface#155. repo2rlenv migrate pr-diff <dir> [--apply] detects the baked-oracle marker and rewrites environment/Dockerfile + tests/{test.sh,verifier.py, oracle.patch,instruction.md} via the SAME builder functions fresh generate calls today, so a migrated task is byte-identical to one emitted now, not a hand-maintained parallel implementation. instruction.md and solution/patch.diff (the oracle itself) are never touched, so a migrated task keeps its original content_hash. repo_url/base_commit are recovered from the existing Dockerfile's remote set-url line and task.toml's metadata.repo2env.ref, not re-derived or guessed. Refuses to touch a task whose instruction.md/solution/patch.diff don't hash to the content_hash task.toml already claims, rather than silently rewriting an inconsistent bundle. Defaults to a dry-run report; --apply writes.
|
Thanks, this tooling is needed for #155. A few fixes before merging:
Please add those regressions. Rebuilds and publication remain maintainer work; #155 stays open until those are verified. |
…repair, symlink refusal - Recover repo_url from the plain 'git clone' layout of the earliest published datasets (e.g. BurntSushi__ripgrep-3166), not only from 'remote set-url'. - Read and write task files as bytes. A universal-newline read turned the instruction's embedded CRLF into LF, so the content_hash check reported a false mismatch on a healthy task; writes would also have corrupted the verifier copy on Windows. When a mismatch is real, say whether the recorded hash matches the instruction baked into the Dockerfile. The hash check is kept. - Stage the whole repair and swap the Dockerfile in last, so a failed write leaves the task unrepaired. A safe Dockerfile only counts as already_safe when every grading asset is present; missing ones are rebuilt. - Refuse symlinked or non-regular paths before any read or write. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Pushed 44e1e6f addressing all three points. 1. Historical layout + hash mismatch. URL recovery now handles the plain On the hash: at that revision the recorded hash matches the visible 2. Partial write. The whole repair is built first, staged to temp files, then swapped in with the Dockerfile last, so a failed write leaves the task unrepaired and retryable. 3. Symlinks. Any symlink on a path we read or write, a path resolving outside the task, or a non-regular file (e.g. a FIFO Regressions added for each: plain-clone layout, CRLF byte-exactness, baked-vs-visible mismatch message, failed write + retry, missing assets behind a safe Dockerfile, symlinked Still maintainer work per your note: image rebuilds, no-op/oracle and agent-phase isolation checks, publication. |
Summary
Closes the tooling gap #145 explicitly left open: "Existing published datasets... need re-emission to pick up the fix. A migration/re-bake tool could be a follow-up." — this is that follow-up, for #155.
repo2rlenv migrate pr-diff <dir> [--apply]walks a dataset directory, detects the pre-#145 baked-oracle Dockerfile (base64 -d > /verifier/oracle.patch), and repairs it:environment/Dockerfile,tests/test.sh, and addstests/{verifier.py,oracle.patch,instruction.md}using the exact same builder functionsgenerateuses today (build_pr_diff_environment_dockerfile,build_pr_diff_eval_script,_pr_diff_aux_files) — a migrated task is byte-identical to one freshly emitted, not a hand-maintained parallel implementation that could drift from the real fix.instruction.mdandsolution/patch.diff(the oracle itself) are never touched, socontent_hash(which only ever covers those two files —emitter/harbor.py:_content_hash) is unchanged; a migrated task keeps its original identity.repo_url/base_commitare recovered from the existing Dockerfile'sremote set-url originline andtask.toml'smetadata.repo2env.ref— both untouched by the leak fix, so nothing is guessed.instruction.md/solution/patch.diffdon't hash to thecontent_hashitstask.tomlalready claims, rather than silently rewriting something inconsistent — surfaced asaction: "error".--applywrites. Idempotent — a task already on the fixed shape reportsalready_safeand is untouched.Scope note
Per #155's checklist, this PR covers detection + file repair only:
AdithyaSK/repo2rlenv-pr-diff. Those are exactly the steps this tool's output is meant to feed into.generateproduces today, whose end-to-end absence-of-oracle was already verified in pr_diff: ship oracle + verifier via tests/, not baked in image #145's own test plan, but I haven't independently re-verified it against a migrated (as opposed to freshly generated) task.pr_diffdatasets and found onlyAdithyaSK/repo2rlenv-pr-diff(181 tasks). If there are other copies/forks on the Hub, I don't have visibility into that from the repo alone.Test plan
uv run --all-extras pytest tests/test_pipeline_pr_diff.py -q— 36 passed (9 new: detects+repairs, preservescontent_hash, idempotent re-run, dry-run writes nothing, skips non-pr_diff tasks, already-safe task is a no-op, flagscontent_hashmismatch instead of rewriting, missing-task.tomlerror)uv run --all-extras pytest -q(full suite) — 2003 passed, 0 failed, 6 skipped (all live-network/Docker-gated)ruff check ./ruff format --check .— cleanmigrate pr-diffdry-run → apply → re-apply (idempotent) →validate --deepon the result, all as expected