Skip to content

build: trim agent images and move host tooling to Rust - #12598

Merged
cv merged 7 commits into
v1from
build/trim-images-and-scripts
Oct 3, 2026
Merged

cv merged 7 commits into
v1from
build/trim-images-and-scripts

Conversation

@cv

@cv cv commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Five changes, one commit each, following the review of #12392's failures and of how much Python NemoClaw ships:

  1. Onboarding test: each example journey is now its own test, so Windows CI no longer runs into the 300 s limit.
  2. pip: agent images no longer carry pip (−16 MB each).
  3. Node.js: only OpenClaw, Hermes and Pi include Node.js (−135 MB for the other seven).
  4. Ollama proxy: rewritten in Rust on an empty base image, 215 MB → 3.65 MB.
  5. Guard and image tooling: a test fails on any new Python or shell file, and cargo images replaces the three host Python scripts in CI / Images.

Commits

1. test(onboarding): run each example journey as its own test

  • One test walked all 30 single-sandbox examples in sequence; Windows took 210–240 s, close to nextest's 300 s limit.
  • A macro now generates one test per example, so they run in parallel with separate limits.
  • A guard test fails if an example with one sandbox has no test.
  • Linux ARM64: 98 s → 24 s; the slowest example takes 16 s.

2. build(images): leave pip out of the Fabric environment

  • Both venvs are created --without-pip; uv already installs everything at build time.
  • Hermes's editable install now uses uv, mounted only for that step.
  • The image test's requires-python check used pip's vendored packaging; it now uses a small parser that rejects any clause it doesn't understand.

3. build(images): add Node.js only to harnesses that run JavaScript

  • Node.js was copied into every image from the shared base stage.
  • Only OpenClaw's CLI, Hermes's TUI and the TypeScript Pi adapter use it. The other adapters have no Node.js references, and Claude's and Codex's bundled CLIs are native binaries.
  • An image test checks which images carry node.
Image (uncompressed, ARM64) Before After
claude 653 MB 501 MB
deepagents 452 MB 300 MB
pi 641 MB 625 MB
hermes 1039 MB 1023 MB
openclaw 3214 MB 3198 MB

4. feat(images): rewrite the Ollama proxy in Rust on an empty base

  • New crate: nemoclaw-ollama-proxy. It keeps the Python proxy's contract: the same specification, /data key rules (existing volumes keep their key), loopback and inventory checks, routes, status codes, limits and streaming, and it never forwards its credential.
  • Image: built statically against musl and FROM scratch; 215 MB → 3.65 MB. The SDK starts the binary directly.
  • Live SDK test fix: docker_provider_proxy failed at v1 with the old Python image too, because plans now read sandbox image metadata from the gateway engine. It now uses the shared image-engine fixture, and changes the key's mode through Docker's archive API because the image has no shell.

5. build: guard against new scripts and build images with cargo images

  • Guard: tests/scripts.rs lists every Python and shell file with its reason: inside an agent image (21), vLLM recipe code (9), or host tooling still to move to Rust (17). It fails on unlisted or stale entries.
  • cargo images build|qualify replaces build_fabric.py and qualify_contract.py, using the same Docker commands and labels. It builds without the SDK, so CI / Images needs no protoc.
  • Bake plan tests: moved from test_builds.py to a Rust test that skips without Docker Buildx.
  • AGENTS.md gains one rule: write tooling and tests in Rust; Python belongs only inside images whose workload runs on it.

Validation (Linux ARM64)

  • cargo ci: passes every step on the final commit: 1042 tests, then 90 lifecycle tests.
  • Images: claude, deepagents, pi, hermes and openclaw built from this branch pass the image tests, the command contract, and the OpenClaw, Hermes and Pi native checks.
  • cargo images: produced bridge and catalog labels byte-identical to the Python builder's for the dummy and OpenClaw images.
  • Proxy: its 13 tests pass, also inside the image's test stage; the live SDK proxy lifecycle passes against the Rust image.
  • Static checks: lint, unit and reference image tests, Dockerfile checks and the docs check pass.
  • Not run locally: AMD64, macOS and Windows; this PR's CI covers them.

Follow-ups

  • feat: add Kubernetes and OpenShift deployment profiles #12392 will fail the new guard: it adds 31 Python files, including SDK code that runs on users' machines. It needs a decision before it merges.
  • The 17 PendingRust entries are next: test fakes, the SSH capacity collector, the Brev scripts, and the docs publishing script.

cv added 5 commits October 3, 2026 01:51
Windows CI on #12392 stopped single_sandbox_examples_reach_review_through_sparse_journey
at nextest's 300s limit. One test walked every single-sandbox example in
sequence; recent v1 Windows runs already took 210-240s, so each new
example moved it closer to the limit.

Each example now has its own test, generated by a macro, so nextest runs
them in parallel and limits each separately. A guard test fails when an
example with one sandbox is added without a matching entry, so coverage
cannot silently shrink. Friendly-text failures now name the example.

Validation: the 30 example tests and the guard pass in 24s on Linux ARM64
(the old test took 98s); the slowest example takes 16s. Adding an
unlisted example made the guard fail and name the file.
Every agent image carried 12 MB of pip in /opt/fabric, which nothing uses
at run time: uv installs every package during the build. Only two things
needed pip: Hermes's editable install, and the image test's
requires-python check, which imported pip's vendored packaging module. A
new image test, that the environment carries no package installer,
failed against the existing images.

Both venvs (agent and dummy) are now created with --without-pip. Hermes
installs through uv, mounted only for that step, with the same offline,
no-deps, no-build-isolation options. The image test checks requires-python
with a small parser for the >=, < and == clauses Fabric's adapters use,
and rejects any other clause instead of accepting it.

Validation: claude and hermes images built for Linux ARM64 pass the image
tests (including the new one), the command contract, and the Hermes
native and security checks; each is 16 MB smaller. Lint, unit tests,
reference tests, Dockerfile checks and test_builds.py pass.
Every agent image copied 135 MB of Node.js from the shared base stage,
but only OpenClaw's CLI, Hermes's TUI and the TypeScript Pi adapter run
on it. The Python adapters for Deep Agents, Claude, Codex, mini-SWE-agent,
NOOA and the remote agent have no Node.js references, and Claude's and
Codex's bundled CLIs are native binaries. A new image test, that only
those three harnesses carry node, failed against the existing images.

The node stage now packs Node.js and the npm/npx links into one tree. The
OpenClaw and Hermes images (through the interactive stage), the Pi image,
and the Hermes and Pi build stages copy it in; the shared base no longer
does. docs/build.md says which images include Node.js and that the base
has no pip.

Validation: claude, deepagents, pi, hermes and openclaw images built for
Linux ARM64 pass the image tests and the command contract, and OpenClaw,
Hermes and Pi pass their native checks. claude is 152 MB (23%) smaller
and deepagents 152 MB (34%) smaller than yesterday's images, counting
pip; images that keep Node.js are only 16 MB smaller. Lint, unit and
reference tests, Dockerfile checks, test_builds.py, and the docs check
pass.
The Ollama proxy image was 215 MB: a full Python 3.14 base to run one
255-line script. It also needed Python inside the container, so the live
SDK test changed the key's mode with docker exec python3.

The new nemoclaw-ollama-proxy crate keeps the same contract: the
NEMOCLAW_OLLAMA_PROXY specification, the /data key and its
never-regenerate rule (existing volumes keep their key), the loopback
listener check, the inventory check before every request, the two routes
for the pinned model, the same status codes and limits, at most 32
connections, and a streamed response that never forwards the proxy
credential. The image builds it statically against musl and runs FROM
scratch with only the binary and its license. The SDK now starts the
binary directly.

The live proxy test failed at v1 with the old Python image too: plans
now read sandbox image metadata from the gateway engine, which the test
never provided. It now serves the shared image-engine fixture, and it
changes the key's mode through Docker's archive API because the image
has no shell.

Validation: 13 crate tests (the Python suite's cases plus framing,
redirect, startup and connection-limit cases) pass, also inside the
image's test stage. The image is 3.65 MB. The live SDK proxy lifecycle
passes against it on Linux ARM64. cargo ci passes every step (1030
tests, then 90 lifecycle tests); test_builds.py, Dockerfile checks and the
docs check pass.
Nothing stopped new Python or shell tooling from landing; #12392 alone
would add 31 such files. CI / Images also needed host Python for three
scripts that only drive Docker: the image builder, the command-contract
qualifier, and the Bake plan tests.

A new test lists every tracked Python and shell file with its reason:
it runs inside an agent image, which already has Python for its Fabric
adapters (21 files), or is vLLM recipe code (9), or is host tooling
still to move to Rust (17). It fails on any unlisted script and on
listed files that no longer exist; it failed with an empty list.
AGENTS.md now states the rule.

cargo images build and cargo images qualify replace build_fabric.py
and qualify_contract.py with the same Docker commands and labels; they
build without the SDK, so the image job needs no protoc. The Bake plan
tests moved to nemoclaw-build's bake test, which skips without Docker
Buildx. The workflow, docs and image notice use the new commands.

Validation: the guard passes and fails for a new script. cargo images
built the dummy and OpenClaw images with bridge and catalog labels
byte-identical to the Python builder's, and both pass qualification.
The bake and label tests pass with and without protoc. cargo ci passes
every step (1042 tests, then 90 lifecycle tests), and the docs check
passes.
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The Windows CI runner has Docker without Buildx, so all seven Bake plan tests failed on 'unknown flag: --print'. The old check skipped only on 'unknown command', which this Docker doesn't print.

The tests now ask 'docker buildx version' first and skip when it fails, and otherwise expect Docker to run.

Validation: the bake tests pass with Buildx on Linux ARM64 and skip, passing, with a stub docker that rejects Buildx the way the Windows runner does.
cv added a commit that referenced this pull request Oct 3, 2026
## Summary

Removes compatibility code that v1 doesn't owe: `docs/design/scope.md`
says earlier schemas, SDK APIs and state formats needn't be supported.
Three commits, separate from #12598.

### 1. `refactor(images): drop the bridge input_sources flag`
- Images advertised `input_sources: ["file", "stdin"]` so the SDK could
fall back to staged files for images without stdin support. The provider
stopped staging files in `952a00bbc2`, so the flag only rejected images
built before `28c6edf4b6`.
- Nothing has been published, so interface version 1 changes in place.
`BridgeCapabilities` rejects unknown fields again, which makes version 1
one exact shape.
- **Effect:** images built before this commit fail at plan time and must
be rebuilt.

### 2. `refactor(build): require the nextest and platform pins`
- The build tool accepted `versions.json` without these pins, for older
pin files. Only a test fixture lacked them; it now includes nextest.

### 3. `refactor: remove code and tests for earlier formats`
- **Production code removed:**
- the provider routed `inference_service`, `ollama_service` and
`ollama_proxy` (now owned by the Docker provider) to a specific error;
  - the proxy backend did the same for its container kind;
  - model snapshots checked for an old `.nemoclaw-complete.json` marker.
- **Tests removed:** about a dozen that only checked old shapes fail:
agents lists, agent-level harness selection, the `type` field, inline
installers, gateway `management` values, old profile annotations,
completion files, and v0 exports. Tests that also cover current rules
keep those parts.
- **Kept:** checks of the current format: the state version, the runtime
spec label, and gateway processes requiring layout 2. Old inputs still
fail, as ordinary unknown fields, kinds or incomplete state.
- **Docs:** `docs/provider.md` and `docs/inference.md` drop notes about
legacy bindings and former images; `REFERENCE.md` describes the current
layouts.
- No test failed first, since this removes behaviour rather than adding
it.

**Net:** 18 files in commit 3, +17/−211; the PR overall is mostly
deletions.

## Validation (Linux ARM64)
- **`cargo ci`:** passes every step: 983 tests, then 90 lifecycle tests.
- **Image stages:** lint, unit and reference stages pass. A rebuilt
dummy image advertises only the three bridge fields and passes the
command contract.
- **Docs check:** passes.

## Interaction with #12598
- Both PRs touch `crates/nemoclaw-build`, but `git merge-tree` merges
them without conflicts in either order.
@cv
cv enabled auto-merge (squash) October 3, 2026 20:59
@cv
cv merged commit 853a592 into v1 Oct 3, 2026
14 checks passed
@cv
cv deleted the build/trim-images-and-scripts branch October 3, 2026 21:28
cv added a commit that referenced this pull request Oct 5, 2026
…-content tests (#12602)

## Summary

Two fixes found while looking into why #12598's CI took 20–28 minutes
instead of 13–19.

### 1. `ci: restore the dependency cache after workspace manifest
changes`
- **Cause:** every `CI / Native` job on #12598 restored no Rust
dependency cache and recompiled about 860 crates.
- `.github/actions/setup-rust` added `hashFiles('Cargo.toml')` to the
cache key, in the part `Swatinem/rust-cache` also uses to restore older
caches.
- Any root manifest change (#12598 added a workspace member) therefore
left nothing to restore. PR runs don't save caches, so every push
started cold.
- **Why the hash was there:** rust-cache didn't see the dev profiles in
the root manifest (`f639c20ed2`).
- **Fix:**
- the profiles move to `.cargo/config.toml`, which rust-cache hashes
itself;
  - the extra key is now just the platform.
- **Effect:**
- manifest and lockfile changes restore the platform's previous cache
and rebuild only what changed;
  - changing a profile still selects a fresh cache.
- No test covers this: the only possible test would check the action's
text, and commit 3 removes tests like that.

### 2. `test(e2e): give standalone readiness checks room on slow
runners`
- **Failure:** macOS failed
`standalone_proxy_readiness_rechecks_identity_and_credentials_without_sdk_or_gateway`
on the `v1` push of `7da9a23d6c`, with "service readiness check timed
out" on an apply that should succeed.
- **Cause:** both standalone readiness tests waited at most 1 s, and
each check makes several round trips through the SSH fixture. Delaying
each fixture call by 0.4 s reproduced the failure locally.
- **Fix:**
- the proxy test waits up to 30 s; its expected failures return
immediately, so this costs nothing when the fixture is fast;
- the managed test waits 3 s, because its loading phase fails only when
the wait expires.

### 3. `test: remove tests that check file contents instead of behavior`
- These tests checked what a file says, not what the code does, so they
broke on any edit and passed whether or not the behaviour worked.
- **Removed:**
- CI files: the cache key and profile location (added in commit 1), the
workflow step list, the setup action's text, and the URL format of the
nextest, protoc and Docker provider pins;
  - the proxy Dockerfile's text;
- version agreement between `versions.json`, `Cargo.toml` dependency
revisions and docs links (the build reads image defaults from
`versions.json`, so that test compared a file with itself);
  - lists of resource kinds and TLS modes that must not exist;
- hashes of the hosted v0 fixtures, plus the two `v0.yaml` manifests
that existed only to be hashed. The parity tests still compare the v0
exports with the v1 documents.
- **Kept:** the OpenShell telemetry test (renamed `telemetry.rs`), and
tests that read data files as inputs to the code under test.
- 16 files, +35/−422.

## Validation (Linux ARM64)
- **`cargo ci`:** passes every step on the final commit: 1028 tests,
then 90 lifecycle tests.
- **Profiles after the move:** a clean build still compiles workspace
crates with `debuginfo=1` and `sha2` with `opt-level=3`. The existing
target directory needed no rebuild.
- **Readiness tests:** with a 0.4 s fixture delay both pass (the managed
one also at 0.6 s). Without a delay they passed three runs in a row:
proxy about 9 s as before, managed about 8 s instead of 6 s.

## What to expect in this PR's CI
- **First run:** this PR's own run still restores no cache, because the
key format changed and no cache exists for it yet. Expect cold timings.
- **After merge:** the next `v1` run saves caches under the new key, and
later PRs restore them even when they change `Cargo.toml`.
- **Cache storage:** the repository holds about 10.7 GB of caches, above
GitHub's default 10 GB limit, so GitHub evicts old ones; old-key caches
will age out.
bowenzhu21 added a commit to bowenzhu21/NemoClaw that referenced this pull request Oct 5, 2026
NVIDIA#12598 fixed docker_provider_proxy with the same image-engine fixture and
moved the key-mode change to Docker's archive API for the new shell-less
proxy image. Take v1's version of that test; this branch keeps the CPU
runtime fixture, Ollama cache, cache provider, and lifecycle test fixes.

Validation on 853a592 with these changes, Linux ARM64 (Colima), bundle
built from this tree, proxy images built with `docker buildx bake
ollama-proxy`: nextest ci profile 1038 passed, lifecycle profile 90
passed, doc tests, cargo fmt --check, and Clippy -D warnings pass.
docker_provider_proxy 2/2, CPU runtime 5/5 (fails on 853a592 alone),
ollama_cache 5/5, cache_provider 12/12, lifecycle test 15/15. macOS
ARM64: Clippy for the changed crates passes.

Signed-off-by: Bowen Zhu <[email protected]>
@wscurran wscurran added area: providers Inference provider integrations and provider behavior area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance integration: hermes Hermes integration behavior integration: openclaw OpenClaw integration behavior platform: container Affects Docker, containerd, Podman, or images provider: ollama Ollama local model provider behavior labels Oct 6, 2026
cv added a commit that referenced this pull request Oct 7, 2026
v1 moved image tooling to Rust (#12598), so qualify_contract.py is gone.
Its new options are now cargo images qualify --lifecycle PROFILE and
--require-ready, which mount qualify_native.py, set HOME, the work
directory and the native test key, and allow 480 s. The workflow and
docs use the Rust commands with those options.

Invocation input stays a JSON object. Instead of widening it to strings,
the bridge passes the string from {"text": "..."} to an adapter that
takes only text, today Hermes in service mode, and refuses any other
object for it with text_input_required before anything is sent. Other
adapters receive the object unchanged. The Hermes lifecycle profile
sends {"text": "Say hello."}.

Validation: new bridge tests cover the unwrapped string, unchanged
objects for other adapters and Hermes sdk mode, refused objects, and
refused string input; two fail before the bridge change. New tests
cover the qualification container's arguments. The dummy, OpenClaw,
Hermes and Pi images built from this branch pass the contract with
their lifecycle profiles on Linux ARM64. The image unit tests, lint,
clippy with and without the sdk feature, all 1241 deterministic
workspace tests and fern check pass.
cv added a commit that referenced this pull request Oct 7, 2026
v1 replaced image/build_fabric.py with cargo images (#12598), so this
branch's --output and --metadata-file options for the Brev OCI export
move there: cargo images build --output OUTPUT [--metadata-file PATH]
TARGET rebuilds the one target from cache with its bridge and catalog
labels and writes it to the Buildx output, so the archive's digest
covers the installed discovery metadata. The Brev workflow uses it. The
Python test that ran the deleted builder is replaced by a Rust test of
the export arguments.

The export writes inside the checkout because Buildx bake grants
filesystem writes only there, which matches the Brev workflow's
candidate-image directory.

Validation: an OpenClaw image exported this way on Linux ARM64 carries
both labels, and its catalog agrees with its bridge. fmt, clippy with
and without the sdk feature, all 1243 deterministic workspace tests and
the tools/ci tests pass.
@cv cv added the v1 NemoClaw v1 branch label Oct 12, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: providers Inference provider integrations and provider behavior area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance integration: hermes Hermes integration behavior integration: openclaw OpenClaw integration behavior platform: container Affects Docker, containerd, Podman, or images provider: ollama Ollama local model provider behavior v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants