Repository navigation
feat(harbor): add openenv harbor build-images for OCI registries and Kaniko on HF Jobs - #1757
burtenshaw wants to merge 18 commits into
Conversation
…Kaniko on HF Jobs
|
The docs for this pull request are available at https://openenv.github.io/OpenEnv/pr-preview/pr-1757/ (commit 5acc7e7). The preview may take a minute to update and is removed when the pull request closes. |
…t-dir guard, and --verify-only --task
There was a problem hiding this comment.
Alignment Review Report
Automated Checks
- Lint: FAIL —
usort check src/ tests/flags import-sort order in all three new/changed files (src/openenv/harbor/images.py,src/openenv/cli/commands/harbor.py,tests/test_cli/test_harbor_build_images.py).ruff format --checkandruff checkare clean for this diff (the oneruff formathit,src/openenv/core/harness/README.md, and the two pre-existingusorthits intests/envs/test_grid_world.py/test_julia_env.py, are unrelated to this PR perAGENTS.md). - Debug code: CLEAN —
check-debug.shfinds noprint/breakpoint/TODO debug code in the new files (only docstring examples and a pre-existing unrelated TODO elsewhere). - Tests:
tests/test_cli/test_harbor_build_images.pypasses (11/11) against an in-memory fake OCI registry — no live network calls, good isolation.
Open RFCs Context
- RFC 008 (In Review) already defines digest-pinned
environment.docker_imagesemantics thatopenenv validateconsumes; this PR's output (<repo>@sha256:<digest>) matches that contract. - RFC 014 (In Review, "Environment Services") defines a broker pattern for agent-facing, episode-time HF Jobs usage (credentials never reach agent code,
run_uv_joboverhf jobs uv run, budgets, job handles). This PR'sKanikoHFJobsBuilderis a separate, operator-run, pre-rollout build tool — not reachable by any agent or episode — so RFC 014's broker/budget rules don't strictly apply, but it is a second independentHfApiJobs integration in the codebase (run_job+create_bucket/batch_bucket_files, following the existing pattern already used inharbor.py'spushcommand andui_data.py). Noting for awareness since RFC 014 is actively shaping HF Jobs conventions here.
Tier 1: Fixes Required
-
src/openenv/harbor/images.py:46— import order:usortwantsas_completed, ThreadPoolExecutor(alphabetical). -
src/openenv/cli/commands/harbor.py:507-512— import order inside the lazyfrom openenv.harbor.images import (...)block. -
tests/test_cli/test_harbor_build_images.py:18-32— import order (lowercase helper functions should sort before the capitalized classes perusort). -
docs/source/environments/harbor.md(## CLI referencesection, currently only documentsinfo/rollout/serve/pusharound lines 393-519) anddocs/source/reference/cli.md's command table (lines 468-471) — neither documents the newbuild-imagescommand. Worth a follow-up doc pass (/update-docs) since this introduces a new public, user-facing CLI command with ~20 flags.
All four are mechanical — running uv run usort format src/ tests/ fixes the first three.
Tier 2: Alignment Discussion
Principle Conflicts
None identified. This is a standalone, operator-invoked build/push/verify pipeline over the Harbor task's environment/ directory and task.toml; it never runs inside, nor is reachable from, an agent's rollout. It doesn't touch reset/step/state, the MCP boundary, reward computation, or client/server separation. The security hygiene is notably careful: audit_environment scans for embedded credentials/private keys, symlinks, path traversal and verifier/solution leakage before anything is built or pushed; manifest/blob/config digests are independently verified at every hop; registry auth headers are dropped on cross-origin redirects; and secrets passed into Kaniko jobs are written to a file inside the job, used once, and unset.
RFC Conflicts
None blocking. See the RFC 014 note above — flagged only as a design-consistency point for whoever is tracking HF Jobs integration conventions across the codebase (@rycerzes, RFC 014 author), not a conflict with anything this PR does.
Summary
- 3 mechanical lint fixes (import order) + 1 doc-completeness gap to fix
- 0 principle-conflict alignment points for human review
- 0 blocking RFC conflicts (1 non-blocking awareness note re: RFC 014 / HF Jobs conventions)
Sent by Cursor Automation: Pre-review
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed:
**COPY globs never fall back- Dockerfile classification now marks recursive
**COPY source globs as unsupported for OCI append so auto builder selection falls back to Kaniko or Buildx.
- Dockerfile classification now marks recursive
You can send follow-ups to the cloud agent here.
compute_environment_hash covered every file under environment/, so tasks with the same Dockerfile but different files the Dockerfile never reads (e.g. a source tree Harbor uploads at runtime) got different hashes and were each built and pushed again. On harness-hub/harness-adapters scale800_v1, 847 tasks share 14 Dockerfiles, none with COPY: 14 builds instead of hundreds. The hash now covers the Dockerfile and the files its COPY/ADD instructions read from the context. It falls back to the whole context when that cannot be told statically (RUN --mount, ARG-expanded or recursive '**' sources). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt hash Addresses the Bugbot review on #1758: - split instructions and COPY/ADD flags on any whitespace, like classify_dockerfile - hash .dockerignore with the copied files, since Kaniko and Buildx filter the context through it - fall back to the whole context for heredoc Dockerfiles, whose bodies are not instructions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g everything Addresses the follow-up Bugbot review on #1758: any `<<` (RUN heredocs, comments, --extra-dockerfile snippets) forced a full-context hash, bringing back the per-task rebuilds this change removes. Heredoc bodies are now skipped before parsing and COPY/ADD heredoc sources are ignored, since their payload lives in the already-hashed Dockerfile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ied-files fix(harbor): hash only what build-images copies into the image
Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
…ed stub Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 4 potential issues.
Bugbot Autofix prepared fixes for all 4 issues found in the latest run.
- ✅ Fixed: Registry auth sent to upload Location
- Registry credentials are now attached and negotiated only for URLs on the registry host, preventing cross-host upload locations from receiving authorization.
- ✅ Fixed: Resume ignores sibling env receipts
- Resume now searches every member of a deduplicated environment group for a valid resolved receipt.
- ✅ Fixed: ENV values skipped in path expansion
- Dockerfile path and metadata expansion now uses previously declared ENV values together with ARG values.
- ✅ Fixed: OCI append skips dockerignore rules
- OCI COPY layer construction now applies Docker ignore patterns, including exclusions, negations, and recursive matches.
You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 81a472e. Configure here.
… OCI append for unresolved vars and .dockerignore, resume from any dedup sibling Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
…of a hand-rolled ignore matcher Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>
Co-authored-by: burtenshaw <burtenshaw@users.noreply.github.com>



Summary
Adds
openenv harbor build-images(openenv.harbor.images) to turn Harbor task directories into HF-Sandbox-ready tasks with digest-pinned, publicly pullablelinux/amd64[environment].docker_imagereferences intask.toml— targeting standard OCI registries (GHCR, Docker Hub, etc.) with no Docker Spaces required.src/openenv/ ├── cli/commands/ │ └── harbor.py # + `openenv harbor build-images` (--plan, --verify-only, --builder kaniko|docker|oci-append, --per-task-receipts-dir, --task) └── harbor/ ├── __init__.py # documents images.py + └── images.py # OCI v2 client, Dockerfile classifier, audit, pure-Python OCI append, Kaniko HF Jobs & Docker Buildx builders tests/test_cli/ +└── test_harbor_build_images.py # 11 unit tests covering parsing, audit, OCI append, Kaniko Jobs, Buildx, task.toml rewrite, dedup & resumeEvidence
hf-sandboxfailed unless each task'stask.tomlmanually pinned a prebuilt publicdocker_image; per-task builds had to use ad-hoc VMs or 1-Docker-Space-per-task scripts.pytest tests/test_cli/test_harbor_build_images.py tests/test_line_endings.py(18 passed),ruff checkandruff formatclean.cpu-basic, no nested Docker):openenv harbor build-images <task> --builder kaniko --namespace burtenshaw --no-pushcompleted end-to-end on HF Job6b083edad91f621b930b384b(private staging bucket tarball upload → Kanikopip install+RUN→sha256:digest capture → bucket cleanup).apt-get,useradd/chown, and--custom-platform=linux/amd64on HF Jobs6b083c20d91f621b930b3190,6b083c57b6a90bbe998086ef, and6b083cd6b6a90bbe9980888a.registry:2: pulleddocker.io/library/python@sha256:5e2bdb..., appended aCOPYlayer +WORKDIR/ENV, stampedtask.toml, passed--verify-only --require-digest-pin, and ran the pushed digest indocker run --platform linux/amd64.--verify-only --require-digest-pinresolved a multi-archghcr.ioimage index tolinux/amd64anonymously.Merge Danger
Door: Two-way
Additive CLI subcommand (
openenv harbor build-images) and new module (openenv.harbor.images) using existing core dependencies (httpx,huggingface_hub,tomli/tomllib). No existing commands, schemas, or runtime dependencies change.Blast Radius: Isolated
Only affects callers invoking the new
openenv harbor build-imagessubcommand or importingopenenv.harbor.images.Made with Cursor