Skip to content

SWE-bench baked sandbox image: Dockerfile emitter + OCP BuildConfig (Plan B Task 3) - #124

Merged
pdettori merged 8 commits into
rossoctl:mainfrom
pdettori:feat/swebench-image
Jul 15, 2026
Merged

pdettori merged 8 commits into
rossoctl:mainfrom
pdettori:feat/swebench-image

Conversation

@pdettori

Copy link
Copy Markdown
Member

Summary

Plan B Task 3 — the baked SWE-bench sandbox image tooling. Additive, off-by-default; no runtime harness behavior changes. Builds on #117 (deck + bake-list).

Because SWE-bench Verified publishes only per-instance eval images (no per-env images — see docs/notes/swebench-image-facts.md), the image is composed by pulling one representative per-instance image per env-key group and cloning its conda env into the assembled image.

What's included

  • deploy/knative/build-swebench-sandbox.sh — a bake-list-driven emitter that prints a multi-stage Dockerfile for an N-env-key slice (--emit --limit N; --print-tag derives the slice tag). Each env stage does conda create --clone testbed -n <env_dir>; the assembled stage COPYs each env to the identical /opt/miniconda3/envs/<env_dir> path (no relocation), mirror-clones each unique repo to /repos/<repo>.git, sets git safe.directory, labels the image with the deck hash + slice, and runs as USER 65532.
  • deploy/knative/swebench-sandbox-buildconfig.yaml — OpenShift ImageStream + Docker-strategy BuildConfig (Binary source) → internal registry. The driver patches the output tag per build via --print-tag.
  • experiments/test/swebench-sandbox-build.test.ts — hermetic structural test (11/11): pins the clone command, same-path COPY, per-env instance_image_key, deterministic slice selection, labels/user, and a regression guard rejecting the abandoned conda-pack machinery.

Live-validated on OCP 4.20 (native amd64)

The emitted Dockerfile was built via the BuildConfig and pushed to the internal registry, and a pod from the image was verified:

  • 3-key proof slice (swebench-sandbox:ff962cb83fe5c624-3of15, ~4 GB): all 3 envs import numpy (django/matplotlib/scikit-learn), all repo mirrors bare, git+ripgrep present, runs as 65532.
  • 15-key full committed slice: build in progress at time of PR.

Why the conda-pack → conda-clone pivot

The live gate showed conda-pack (even with --ignore-editable-packages --ignore-missing-files) produces a corrupt numpy in SWE-bench's mixed conda+pip envs (verified: the original images import numpy fine; the packed relocation didn't). Switching to conda create --clone + same-path COPY preserves all files faithfully and fixed all three envs. The 5 fix commits document that journey; squash on merge if preferred.

Follow-ups (non-blocking)

  • Plan C should activate envs via the env's bin/python by absolute path (the assembled image has no base conda; imports are validated that way).

Assisted-By: Claude Code

pdettori added 8 commits July 15, 2026 09:53
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Swap pip install conda-pack for the conda install path verified end-to-end in docs/notes/swebench-image-facts.md; add a test guard asserting the conda recipe and rejecting the pip form.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
SWE-bench installs the repo editable (pip install -e /testbed) inside the testbed conda env; conda pack refuses editable packages by default, which failed the OCP build at the matplotlib env stage. Pass --ignore-editable-packages to drop the dangling /testbed link (the repo is reprovided at runtime via the worktree, Task 5 / Plan C). Test asserts the flag is present in every env stage.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
SWE-bench testbed envs are mixed conda+pip; pip installs clobber conda-managed files (numpy-base, packaging, pillow, ...), so conda pack's consistency check fails at build time (matplotlib env stage). Add --ignore-missing-files alongside --ignore-editable-packages — the standard combo for a best-effort pack of a dirty conda+pip env. Test asserts both flags in every env stage.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
conda-pack writes bin/conda-unpack with a shebang pointing at the original prefix (/opt/miniconda3/envs/testbed/bin/python), absent in the ubuntu assembled base, so invoking it directly exits 127 (bad interpreter) at the first env unpack. Call the relocated env's own python explicitly before conda-unpack so it resolves sys.prefix from the new location. Test asserts the env-python invocation for each of the 3 env dirs.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
conda-pack --ignore-missing-files shipped a corrupt numpy for mixed conda+pip envs (matplotlib/sklearn numpy import failed in the Task-3b verify gate; django was fine). Pivot to 'conda create --clone testbed -n <env_dir>' per env stage, then COPY each cloned env to the same /opt/miniconda3/envs/<env_dir> path in the assembled stage (no pack/unpack/tar, no relocation — clone writes self-consistent prefixes). Add git config --system safe.directory '*' since repos are cloned as root but the pod runs UID 65532. Test asserts the clone command, same-path COPYs, safe.directory, and a regression guard rejecting all conda-pack machinery.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
The BuildConfig output tag was hardcoded 3of15 and would masquerade if built at a different --limit (review M1). Add a --print-tag mode that prints <deckHash>-<N>of<total> from a single source (slice_tag, N = actual selected count capped at total) so the build driver can patch the output tag per build; note this in the manifest (committed value stays a valid default). Test asserts --print-tag --limit 3 and --limit 15 against the bake-list's deckHash + envs.length.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
… builds

Single-shot 15-env builds get evicted (15 base eval images can't coexist in buildah). Support building the full image in sequential batches of 5, each FROM the prior pushed image: --offset M slices envs[M:M+N]; --base IMG sets the assembled FROM (default ubuntu:22.04); base tooling (apt + git safe.directory) auto-emits only on the default ubuntu base and is skipped when --base is set (--base-tools/--no-base-tools override). Repo clones are now idempotent (test -d || git clone) since repos recur across batches. deck-slice label + --print-tag are cumulative (offset+selected), so batches tag 5of15/10of15/15of15 and the final image reads 15of15. Default --emit --limit 3 behavior preserved (ubuntu base, tools present, offset 0).

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori force-pushed the feat/swebench-image branch from 8fc2b21 to 1730247 Compare July 15, 2026 13:53
@pdettori

Copy link
Copy Markdown
Member Author

Full 15-env slice built + validated on OCP 4.20

The complete committed-deck image is built and verified (updating the "build in progress" note in the PR body):

  • Image: swebench-sandbox:ff962cb83fe5c624-15of15 (sha256:87a12ad…), 6.72 GB, in the cluster-internal registry.
  • 15/15 conda envs healthy — each relocated env's python runs and its baked dependencies import (11 envs import numpy; the 4 numpy-less repos — sphinx/pytest/pylint/sympy — import their deps docutils/pluggy/astroid/mpmath). The repo package itself is intentionally absent (installed editable→/testbed); it's provided per-leaf at runtime via the worktree + pip install -e.
  • 8 bare repo mirrors present (git safe.directory set), git+ripgrep present, runs as USER 65532.

Build shape: the 15-env image can't be built single-shot on the default 128 GB-ephemeral worker nodes (all 15 base eval images can't coexist in buildah storage → pod eviction). It was built via iterative accumulation — 5 sequential batches of 3, each FROM the previous pushed image (3of15→6of15→…→15of15) — which the --offset/--base emitter modes support. A 50 Gi ephemeral-storage request on the BuildConfig keeps each batch scheduled with headroom.

Assisted-By: Claude Code

@pdettori
pdettori merged commit 91dd9cf into rossoctl:main Jul 15, 2026
10 checks passed
@pdettori
pdettori deleted the feat/swebench-image branch July 15, 2026 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant