Skip to content

feat(config)!: reshape the configuration schema as v1alpha2 - #13121

Closed
gaveezy wants to merge 12 commits into
v1from
feat/13080-portable-schema
Closed

gaveezy wants to merge 12 commits into
v1from
feat/13080-portable-schema

Conversation

@gaveezy

@gaveezy gaveezy commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the five accepted shape changes from #13080, with the decisions cv's review asked for, and versions the result as nemoclaw.nvidia.com/v1alpha2.
A document now selects its backend with one spec.gateway.target key, names sandboxes and inference providers by map key, and no longer carries the SDK's gateway image digest.
Compiled resources and provider attributes for equivalent documents are unchanged; only a discovery postcondition message now names spec.gateway.target.
A v1alpha1 document, or state written for v1alpha1, fails without touching resources and points to docs/migration.md; there is no conversion.

Why

The v1alpha1 schema assumed a local Docker engine.
Kubernetes and OpenShift worked by switching Docker fields off through root-level conditionals, so a document could not be re-authored for another backend without edits at several unrelated locations, editors offered Docker's socket on a Kubernetes gateway, and every OpenShell update invalidated documents that contained the gateway digest.
Once deployments exist, changing this shape strands their retained intent, so the shape changes land together now.

Changes

Before (v1alpha1):

spec:
  gateway:
    management: managed
    runtime:
      provider: docker
    endpoint: http://127.0.0.1:17671
    image: ghcr.io/nvidia/openshell/gateway@sha256:ea14…
    networkCIDR: 172.20.0.0/24
  inferenceProviders:
    - name: local
      provider: openai
      endpoint: http://172.20.0.1:11434/v1
  sandboxes:
    - name: assistant
      …

After (v1alpha2):

spec:
  gateway:
    management: managed
    target:
      docker:
        endpoint: http://127.0.0.1:17671
        networkCidr: 172.20.0.0/24
  inferenceProviders:
    local:
      provider: openai
      endpoint: http://172.20.0.1:11434/v1
  sandboxes:
    assistant:
      …
  1. Diagnostics first (fix(config)). An x-nemoclaw-error message now comes from the nearest annotated ancestor of the failing rule, and a oneOf of single-key objects selects the variant the input names. Before this, the root Kubernetes message was never shown, and the managed Kubernetes, Podman engine, and Kubernetes environment messages appeared only for a missing endpoint, a missing engine, or a duplicate name; a tagged target would have reported every error as "must match one allowed object shape". Partial-document assessment and editor field lookup select variants the same way. Generic messages for item, entry, and name bounds and for scalar oneOf choices are also clearer.
  2. SecretRef and FileRef. The gateway, inference provider, and web-search credentials are SecretRef; TLS files, the kubeconfig, and image metadata are FileRef. YAML stays {env: NAME}.
  3. One tagged target. Managed: docker (endpoint, engine, imagePullPolicy IfNotPresent or Never, networkCidr), podman (the same, engine required, imagePullPolicy also Always), or kubernetes (distribution, required HTTPS loopback endpoint, and the existing cluster fields). External: endpoint, credential, and tls stay on the gateway; target is docker or podman with an optional image-inspection engine, or kubernetes: {}. Omitting target selects Docker. gateway.runtime.provider and gateway.image are removed, networkCIDR is spelled networkCidr, and a field at its earlier location reports where it moved.
  4. Keyed sandboxes and inferenceProviders at deployment and sandbox scope. The key replaces name and keeps its pattern; a deployment holds 1 to 32 sandboxes. Inline route providers keep name, because they have no key and their name feeds the provider registration.
  5. v1alpha2. One constant names the API, schemas/nemoclaw-v1alpha2.schema.json, and its $id. Retained intent is format version 8.
  6. Retargeting test (Proposal: Make the v1alpha1 configuration schema portable and scalable across Docker, Podman, Kubernetes, and OpenShift #13080 "Done When"). Every example is re-authored for managed and external Docker, Podman, and Kubernetes targets and for managed OpenShift; the edits each needs must match the table in docs/usage.md#choose-the-gateway-target.

Decisions on the review

cv's point Decision in this PR
1. Moving between backends vs. bound identity The target key and every setting under a managed target except imagePullPolicy stay bound identity. The guarantee is re-authoring a document for another backend as a separate deployment, not migrating a live one; docs/usage.md#choose-the-gateway-target says so, and the retargeting test checks authoring only.
2. Backend fields outside target No such fields are added here. Service placement variants stay with #12732; sandboxes.<name>.kubernetes and resources still need an owning issue (#12036 was closed as not planned). Each owner must choose between per-sandbox overrides under target and documented Rust-only checks.
3. Two backend selectors Unchanged: a Kubernetes target still rejects spec.services, and a Podman gateway can still consume a Docker model service over SSH with explicit placement. Whether a Kubernetes gateway may use an SSH-placed service is left to #12732.
4. Defaults table changes shape Not implemented here. #13058, merged into v1 before this branch, added ServiceContainer.memoryLimitGiB and service updatePolicy; this PR does not move them. spec.policies/spec.images, sandbox templates, and the sandbox updatePolicy row stay open.
5. Ports per command vs. authored ports The managed endpoint moved into its target: Docker and Podman keep an optional HTTP loopback endpoint with a default; Kubernetes requires https://127.0.0.1:PORT. An external gateway keeps endpoint at the gateway level. A per-command port-forward is not implemented.
6. Values chosen at apply time Not implemented; defaults are unchanged (172.30.N.0/24 from the UID, port 17681). Bounding service limits by observed GPU memory is not implemented either; it needs its own decision because validation would then depend on the host.
7. Same apiVersion vs. bump Bumped to v1alpha2. A v1alpha1 document fails before schema validation, and v7 state or a v1alpha1 intent fails before typed parsing, both without touching resources or bytes. There is no conversion; docs/migration.md#re-author-a-v1alpha1-document gives the export-and-re-author procedure and a field map. For #12645, the contributor guide states the bump rule: a revision that rejects or reinterprets a previously accepted document changes the API version; adding optional fields does not.
gateway.runtime.provider Removed; the target key replaces it.
What distribution: openshift changes Only on a managed kubernetes target: the SDK reads the namespace's SCC UID range (waiting up to 30 s) and supplemental groups, records that identity, passes it as Helm security-context values, and binds the compute driver as openshift. The document, not a cluster observation, selects this behavior, so plan output does not depend on what a cluster reports (point 6).
External gateways with a target The key is checked against the driver the gateway reports, as before; a mismatch stops plan and apply without changes. External kubernetes takes no distribution, because OpenShift gateways report the kubernetes driver and nothing could check it.
SecretRef.file and kubernetesSecret Left out. Both types take only env, so adding a form later is additive.
Keying sandboxes The key replaces name with the same pattern. Nothing is ordinal: export, apply health, and diagnostics now use name order instead of authored order (compile, discovery, and the digest already did). Onboarding addresses the sole sandbox by key and asks no sandbox-name question; a seed without exactly one validly keyed sandbox now stops onboarding before the first question. The 32-sandbox limit and the refusal to remove or rename an applied sandbox are unchanged; recording why the limit is 32 stays open.
gateway.image override The authored field is removed and the SDK resolves its pin internally, so documents and exports survive OpenShell updates. The resolved image stays bound in provider state: a pin change still needs the original bundle or a separate deployment, and plan stops with bound storage specification differs from retained intent instead of failing to load intent. Repository overrides for the gateway, chart, and component images are additive and left to a follow-up.
networkCIDR vs. networkCidr networkCidr. Internal provider attributes keep network_cidr.
Pullable default agent image A release decision (#12638); not changed here.
Error messages before oneOf The first commit; tests cover each annotation that was unreachable before.
Pattern anchoring, metadata.uid case, other defects Not in this PR; they need their own issues. The migration guide generates a lowercase UID.

Compatibility

This is breaking for every v1 document and deployment:

  • A v1alpha1 document fails with configuration uses nemoclaw.nvidia.com/v1alpha1; this NemoClaw reads nemoclaw.nvidia.com/v1alpha2; re-author it as described in docs/migration.md.
  • Existing state fails with deployment state was written by an earlier NemoClaw for nemoclaw.nvidia.com/v1alpha1; …. Nothing is adopted, replaced, or deleted.
  • Public SDK changes: Runtime, Credential, Gateway::runtime()/runtime_mut(), the flat ManagedGateway fields, ExternalGateway.runtime/engine, Sandbox.name, and InferenceProvider.name are removed. ManagedTarget/ExternalTarget under target, Gateway::compute_driver(), SecretRef, and FileRef replace them. Spec.sandboxes and both inference_providers collections are name-keyed BTreeMaps, route providers are InlineInferenceProvider, managed::Spec.gateway is managed::GatewaySettings, and sandbox lookups such as Document::sandbox_harness take the sandbox name. Document::parse rejects duplicate keys; a Document deserialized directly keeps the last one.

Internal provider specifications keep their serialized layout, so provider state attributes, spec labels, and reference.json are unchanged.

Validation

  • cargo ci on fe83ba3bd (linux_arm64, Rust 1.98.1 container): every default step passed. test: 1,525 passed, 184 skipped, within the 45 s budget. lifecycle: 136 passed. On this shared host, the lifecycle step ran as one partition and reported budget overruns (442.8 s wall against 300 s per partition; nemoclaw-provider::contract 117.5 s against 110 s; openshell-provider::contract 196.7 s against 190 s); those budgets apply on CI runners.
  • Test-first: each behavior change has a test that failed before its implementation, including unreachable x-nemoclaw-error messages, target shapes and defaults, moved-field hints, keyed-map diagnostics, the v1alpha1 document and state errors, and the provider-name panic found in review.
  • Identity: keyed_sandboxes_and_providers_keep_the_resource_identities_of_named_entries pins addresses, registration keys, and Fabric numbering recorded from the list form. The bound-gateway tests refuse another target key, distribution, network, context, namespace, or endpoint, and accept a pull-policy change. Uncommitted review probes also compiled all 44 examples, the fixtures, and stress documents in both shapes: compiled targets, typed state rows, service specifications, spec labels, Helm targets, and registration keys matched; only export and health order and diagnostic paths differed.
  • Retargeting: 44 examples × 7 targets, each needing exactly the documented edits.
  • Not run: the live Docker and kind steps, and no deployment was applied. CI selects the live jobs for changes under examples/ and schemas/.

Review Guide

  • Commits: diagnostics (fbc7f08a6), credential split, target, keyed maps, v1alpha2, the merge of v1, the retargeting test, and review fixes. Each refactor(config)! commit converts examples, tests, and docs together and regenerates the schema and reference. 533c6e2ed has no net diff; v1 carries the same fix.
  • crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json and tavily-web-search.tf.json change because the fixture generator now binds each sandbox's runtime in name order, as compile already did; on v1 it used authored order and swapped two adapters' bindings.

Implements the shape-change part of #13080, which stays open: the additive fields, defaults, and defects still need owning issues.

🤖 Generated with Claude Code

gaveezy and others added 9 commits October 13, 2026 17:19
#13056 made ObservationError a non-Copy enum, and #13081 then passed the
same value to assert_observation twice, so the SDK's integration test
binary stopped compiling on Unix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
An x-nemoclaw-error message appeared only when the failing keyword sat
directly on the annotated node. Rules built from nested properties,
items, allOf, or then steps therefore reported a bare keyword such as
`not`, `minLength`, or a raw pattern: the managed Kubernetes endpoint
and local-field rule, the Podman engine rule, the Kubernetes environment
naming rule, and the root Kubernetes services rule never showed their
messages. A oneOf of single-key objects would also have reported every
error as "must match one allowed object shape".

- Diagnostics use the nearest annotated ancestor, bounded by the
  definition root and the selected variant, and a missing field uses its
  own annotation.
- A union variant is selected by its kind or management constant, by the
  one key of a closed single-key object, or by a hardware profile. When
  no key selects a variant, the error lists the declared keys and never
  the input's.
- Partial-document assessment and editor field lookup select variants
  the same way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
…eRef

One Credential type held both bearer values and local file paths: the
env value of `tls.*`, `kubeconfig`, and `image.metadata` is a file path,
while the gateway, inference provider, and web-search credentials hold
the secret itself. The schema and reference could not say which.

- SecretRef: external gateway credential, inference provider credential,
  and web-search integration credential.
- FileRef: TLS CA, certificate, and key; managed Kubernetes kubeconfig;
  sandbox image metadata.

Authored YAML stays `{env: NAME}`. Each reference keeps the reserved-name
rules and now reports a message naming its kind. The `file` and
`kubernetesSecret` forms from #13080 are left out: reading secrets from
files changes the credential model, and OpenShell cannot bind a Secret
by reference yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
Three inputs had to agree to select a backend: `runtime.provider`,
whether `gateway.kubernetes` was present, and the flat `engine`,
`image`, `imagePullPolicy`, and `networkCIDR` fields. Root-level
conditionals enforced their pairing, editors offered Docker's socket on
a Kubernetes gateway, and moving a document between backends failed at
several unrelated locations.

`spec.gateway.target` now holds exactly one key:

- Managed `docker`: `endpoint`, `engine`, `imagePullPolicy`
  (IfNotPresent or Never), and `networkCidr`, each defaulted as before.
- Managed `podman`: the same fields; `engine` is required and
  `imagePullPolicy` also accepts Always.
- Managed `kubernetes`: `distribution` (kubernetes or openshift),
  a required HTTPS loopback `endpoint`, and the existing cluster fields.
  The openshift distribution reads the namespace's SCC UID range,
  records that identity, passes it as Helm security-context values, and
  binds the compute driver as openshift.
- External `docker` or `podman` take an optional image-inspection
  `engine`; external `kubernetes` takes no settings, because the gateway
  reports only the kubernetes driver. Plan still checks the key against
  the reported driver.

`gateway.runtime.provider` is removed, the managed `endpoint` moves into
its target, and `networkCIDR` is spelled `networkCidr` like
`ServicePlacement`. `gateway.image` leaves the authored contract: its
only valid value was the SDK's digest, so defaulted and exported
documents broke after each OpenShell update. The SDK now resolves the
pinned image internally; the resolved image stays bound in provider
state, so a pin change still needs the original bundle or a separate
deployment.

Compiled output is unchanged: the internal gateway settings keep their
serialized layout, so typed state rows, service specifications, spec
labels, Helm targets, and digests of equivalent documents match the
earlier shape byte for byte across every example. Fields at their
earlier locations report where they moved. Onboarding asks for the
target key where it asked for the runtime, with the same choices first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
`spec.sandboxes` and both `inferenceProviders` collections were arrays,
unlike `harnesses`, `inferences`, `integrations`, and `services`. Rust
had to enforce name uniqueness, onboarding addressed the sandbox as
`/spec/sandboxes/0`, overlays would patch by index, and authored order
leaked into export and status output while identity ignored it.

- `spec.sandboxes`, `spec.inferenceProviders`, and
  `spec.sandboxes.<name>.inferenceProviders` are maps. The key replaces
  `name` and keeps its pattern; a deployment holds 1 to 32 sandboxes.
- Inline route providers keep a required `name`, because they have no
  key and their name feeds the provider registration.
- Keys order nothing: export, apply health, and diagnostics list
  sandboxes and providers by name. Schema diagnostics show a key only
  when it is a valid name and point at the rejected key's own line.
- Onboarding addresses the sole sandbox and its providers by key, asks
  no sandbox-name question, rejects a template whose sandbox key is not
  a name, and never prints such a key.

OpenTofu addresses, provider registration keys, Fabric data-source
numbering, and every other compiled identity match the list form for
the same names across all examples. Document digests change. The
OpenShell contract fixtures for multiple-sandboxes and tavily-web-search
are regenerated: the fixture check numbered sandboxes in authored order
while compile numbers them by name, so two checked-in fixtures carried
swapped adapter bindings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
The schema's apiVersion and $id stayed the same across revisions whose
rules differed, so a document or retained state from an earlier v1
revision failed at its first moved field, or loaded as "corrupt", with
no sign that the whole document had to be re-authored.

- `nemoclaw.nvidia.com/v1alpha2` names the configuration API, the schema
  file `schemas/nemoclaw-v1alpha2.schema.json`, and its `$id`, all from
  one constant. `schema --check` fails while another versioned schema
  file remains.
- `Document::parse` rejects a v1alpha1 document before schema validation
  and points to the migration guide.
- Retained intent is format version 8. A record from an earlier version
  or holding a v1alpha1 document fails before typed parsing with a
  message to retain it and use the earlier NemoClaw to destroy it, or to
  deploy separately. Its bytes stay untouched.
- The contributor guide states the rule: a revision that rejects or
  reinterprets a document the previous revision accepted changes the
  API version; adding optional fields does not.
- The migration guide describes keeping or exporting the earlier
  document, a field map from v1alpha1, and deploying the re-authored
  document separately. There is no conversion or adoption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
Adapt the managed-model context advisory added upstream to keyed
sandboxes, and keep the v1alpha2 release note ahead of the updatePolicy
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
#13080 asks for a test that retargets every example to every backend and
compares the required edits with a documented list. The test rewrites
the gateway of all 44 examples for managed and external Docker, Podman,
and Kubernetes targets, applies the documented edit for each schema or
parser violation until the document parses, and requires the applied
edits to match a rule table derived from the example's features.

The documented edits are: for Kubernetes, an explicit sandbox image
reference and image metadata, and external endpoints instead of managed
services; for Docker or Podman, no image metadata; and explicit
placement for managed services unless the gateway is managed Docker.
docs/usage.md lists them. The test checks authoring portability only: a
live deployment cannot change its target.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
- Reject provider keys and inline provider names outside the name
  pattern again, and truncate registration-key prefixes by character, so
  a Rust-built document with a non-ASCII provider name returns an error
  instead of panicking.
- Report an intent record without an integer version as corrupt, and
  point the earlier-state message to the migration guide.
- Test that a bound managed gateway refuses another target key,
  distribution, network, context, namespace, or endpoint, and accepts a
  pull-policy change.
- Retarget examples to managed OpenShift as well, and require an
  explicit engine, not placement, for an Ollama proxy.
- Share one rule for which map keys are names between schema
  diagnostics and onboarding, and one masking and JSON-pointer helper
  set in authoring.
- Carry removed-field hints as ordered pairs, and correct the release
  notes, migration example, and troubleshooting paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv enabled auto-merge (squash) October 14, 2026 02:44
gaveezy and others added 2 commits October 14, 2026 07:10
The retargeting test looked up `examples/managed-ollama.yaml` by string,
but Windows renders the relative path with `\`, so the lookup failed and
the Windows test job stopped. Compare paths instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
Bring in cv's update of the branch from v1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hai Nguyen <haingu@nvidia.com>
@gaveezy gaveezy closed this Oct 14, 2026
auto-merge was automatically disabled October 14, 2026 16:08

Pull request was closed

@wscurran wscurran added area: architecture Architecture, design debt, major refactors, or maintainability area: security Security controls, permissions, secrets, or hardening refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch labels Oct 22, 2026
@cv
cv deleted the feat/13080-portable-schema branch November 21, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: architecture Architecture, design debt, major refactors, or maintainability area: security Security controls, permissions, secrets, or hardening refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants