Skip to content

refactor: label agent images in the Bake build - #13514

Merged
cv merged 2 commits into
v1from
refactor/agent-catalog-label-in-bake
Oct 20, 2026
Merged

cv merged 2 commits into
v1from
refactor/agent-catalog-label-in-bake

Conversation

@cv

@cv cv commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Failure

cargo images build built each agent image twice. It baked the image under a temporary tag, ran catalog.py --installed in a container to read the installed Fabric catalog, then ran a second docker build FROM the temporary image to add the io.nemoclaw.fabric.catalog label that plan reads. So the image Bake built was never the image deployments used, and docker buildx bake --push would publish unlabeled images, which blocks publishing images from Bake to a registry.

The label exists because plan reads the catalog from the image configuration: locally through Docker, and on Kubernetes from the exported metadata bundle, without pulling layers. Derived images inherit it through FROM. A Dockerfile can't set a label from something its own build computes, hence the relabel.

Decision

Compute the label inside the same Dockerfile and pass it between two cached Bake builds.

  • image/fabric/Dockerfile gains two stages, built on the harness stage that a global STAGE argument selects:

    • catalog runs catalog.py --installed offline and exports /catalog.json;
    • labeled takes it as the CATALOG build argument, sets the label, and fails the build unless CATALOG matches the installed catalog. A missing or wrong catalog fails with "CATALOG must be this image's installed catalog; build with cargo images build".
  • docker-bake.hcl passes STAGE for each agent and for the reference image.

  • cargo images build:

    • bakes <name> with target=catalog to .build/catalog/<name>;
    • applies its existing label checks (only the reference image lists the reference adapter);
    • bakes <name> with target=labeled and the catalog.

    The temporary tag, the metadata container, the relabel build, and read_metadata are gone. Tags come from Bake as for every other image.

  • Unchanged: a plain docker buildx bake <agent> still builds the unlabeled harness stage, so the Brev candidate build is unaffected.

  • Also fixed: an unused-function warning in the CI runner build, left by refactor: build runtime images with Bake under image/ #13507. target is used only by the bundle, so it is gated on the sdk feature.

Validation

  • Prototype, on a DGX Spark (linux/arm64):
    • the catalog and labeled builds of the reference image each took about 1 s from cache, and the label equaled the exported catalog;
    • a wrong or missing CATALOG failed the build with the message above;
    • a plain bake build stayed unlabeled.
  • Real builds: cargo images build --platform linux/arm64 agents built all ten images with labels in 227 s.
  • Qualification: CI's loop passed for every image (cargo images qualify, with the OpenClaw, Hermes and Pi lifecycles, plus image/test_image.py against each label), and cargo images qualify nc-fabric:dummy --lifecycle dummy passed.
  • Checks:
    • docker buildx bake --check dummy agents ollama-proxy and docker buildx bake check passed;
    • cargo ci passed, including the bundle and lifecycle steps;
    • cargo ci live-docker passed (9 tests), building its Pi and reference images through this path and deploying them.
  • Tests: the live image test now expects each agent's catalog bake and labeled bake. The Docker fake writes the exported catalog.

cargo images build baked each agent image under a temporary tag, read its installed catalog in a container, then relabeled it with a second docker build, so the image Bake built was never the image deployments used. The agent Dockerfile now has a catalog stage that exports the installed catalog and a labeled stage that takes it as a build argument and fails unless it matches what the image installs. cargo images build bakes one, then the other; both reuse the same cache.
@cv
cv enabled auto-merge (squash) October 20, 2026 05:49
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 03d3133 into v1 Oct 20, 2026
@cv
cv deleted the refactor/agent-catalog-label-in-bake branch October 20, 2026 06:02
cv added a commit that referenced this pull request Oct 21, 2026
…3569)

## Failure

NemoClaw's image checks were Python scripts mounted into each image:
`image/test_image.py` for every agent image, and
`image/test_agent_contract.py` for the reference image's lifecycle.
Several checks tested other components or repeated what the build
already enforces:

- **Other components' behavior:** whether Hermes can reach MCP servers
(Hermes internals), and how Fabric's TypeScript Pi adapter is packaged.
- **Harness names:** a hard-coded list of the three harnesses that carry
Node.js.
- **Already enforced by the build:**
- the catalog label matching the image's declarations (the `labeled`
stage refuses a mismatch since #13514);
- installed packages following Fabric's lock, and Python satisfying each
adapter's range (the locked install enforces both).

Also, `AGENTS.md` keeps tooling and tests in Rust and Python only inside
images whose workload runs on it. `image/vllm/test_auth.py` was a manual
script nothing ran.

## Decision

`cargo images qualify IMAGE...` checks NemoClaw's promises about its
images, in Rust:

- **Every image,** from its label and a shell command that reports facts
about the image, run offline as the image's own user:
  - the runtime command is `fabric-agent-ctl`, and it is executable;
  - the retained sources match the image's provenance;
- the image runs as 10001:10001, `/sandbox` and `TMPDIR` belong to
10001, and everything in `/sandbox` is readable by others, as OpenShell
needs on Kubernetes and OpenShift;
  - no package installer and no build toolchain.
- **The reference image** also starts, invokes, and stops one runtime
with NemoClaw's test adapter, through `fabric-agent-ctl serve` in an
offline, read-only container with only `/sandbox` writable.

The image workflow qualifies every agent image this way, and the three
Python files are removed. The Python the images run (`catalog.py` and
its helpers, the reference test adapter, and their tests) stays until
image building moves to the Fabric repository.

## Validation

- New tests for the fact checker (an image that meets the contract, and
each problem named) and for the lifecycle container's arguments. They
failed to compile before the change.
- On a DGX Spark, `cargo images qualify` passed for all eleven local
images, the reference image in 4 s with its lifecycle and each
production image in about 1 s. The first run caught a bug in my facts
script: it listed retained sources with a glob that missed dotfiles and
nested files.
- `docker buildx bake check`, `actionlint` and `cargo ci` (bundle and
lifecycle included) passed, and `fern check` reported 0 errors.
@wscurran wscurran added area: packaging Packages, images, registries, installers, or distribution chore Build, CI, dependency, or tooling maintenance platform: container Affects Docker, containerd, Podman, or images v1 NemoClaw v1 branch labels Oct 23, 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: packaging Packages, images, registries, installers, or distribution chore Build, CI, dependency, or tooling maintenance platform: container Affects Docker, containerd, Podman, or images v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants