Skip to content

feat(sdk): route sandboxes on Kubernetes gateways to in-cluster model servers - #13063

Merged
cv merged 84 commits into
v1from
split/8-cluster-sandbox-routing
Oct 18, 2026
Merged

cv merged 84 commits into
v1from
split/8-cluster-sandbox-routing

Conversation

@gaveezy

@gaveezy gaveezy commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Sandboxes on a Kubernetes or OpenShift gateway can now use a model server that the user runs in the same cluster, addressed by its Service name: http://<service>.<namespace>.svc.cluster.local:<port>/v1, optionally with a key. NemoClaw places nothing on the cluster. This is the "Placing servers" model of #13131: the platform owns placement, readiness and the key.

The PR also fixes a v1 bug that the key needs: on a managed Kubernetes gateway, any provider with a credential failed at apply with "observation authentication failed".

Supersedes the earlier stacked version of this PR; #13061 and #13062 are parked.

Why

Before this PR, YAML that names an in-cluster Service failed in two places (both seen by compiling examples/kubernetes/managed-development.yaml with the endpoint changed):

  • Without credential: plan and compile failed with "inference discovery inputs are invalid". The control-host model-catalog read accepts plain HTTP only to a literal loopback or private address (nemoclaw-backend validate_endpoint), and the machine running NemoClaw usually cannot resolve cluster DNS anyway.
  • With credential: the schema rejected the document, because config/schema/validation.rs forbade credential on every http: endpoint.

A YAML user could reach an in-cluster server only by a literal ClusterIP and without a key, and that address changes when the Service is recreated. HCL users can already do this with a literal openshell_inference server (docs/inference.md, "Supply the Key on Other Platforms").

The first live run of the keyed form on kind then failed at apply in v1 itself, before OpenShell received the provider (fix in commit 4 below).

What changes

Six commits and three merges of v1. The first merge took v1's tree unchanged (parents 46eea8340 and ef3115d4e). The second, 2fa69d20a, merges v1 at 7d7772eda (#13411), and the third, c9136276a, merges v1 at 64c384eff (#13413); their conflicts and test adaptations are listed after the commits.

  1. Route without a catalog read (feat(sdk): route Kubernetes sandboxes to in-cluster Services)
    • inference_discovery::is_cluster_service_endpoint accepts exactly http://<service>.<namespace>.svc.cluster.local:<port> with an optional path: a DNS-1035 service label, a DNS-1123 namespace label, and an explicit, nonzero, unpadded port. Nothing else matches.
    • EndpointRequest::for_provider skips the catalog read for that form when gateway.runtime.provider is kubernetes or openshift. Plan (endpoint_requests) and onboarding (inference_request_for_document) both use it, so they ask the same questions.
    • Docker and Podman gateways, and every other endpoint, keep their reads; the Service form still fails planning on Docker and Podman.
    • Compile needed no change. The graph registers the literal openshell_inference server with that endpoint, gives the sandbox an FQDN rule without allowed_ips or cluster_grants, and passes the endpoint to Fabric as base_url.
  2. Optional key (feat(sdk): accept a key for in-cluster Service endpoints), a separate commit so it can be dropped (Q1 below)
    • credential is allowed on the Service form only when the gateway runtime is kubernetes or openshift. The provider definition still forbids a key on every other http: endpoint, and a document-level rule forbids it on the Service form with Docker or Podman, in all five places a provider can be declared.
    • Both rejections name the rule instead of a bare not.
  3. Docs and examples (docs(kubernetes): use a model server that runs in the cluster)
    • docs/kubernetes.md, "Use a Model Server in the Cluster": the endpoint form and its limits, then a procedure that runs NemoClaw's vLLM runtime from vllm_runtime's spec, launch and requirements: a Secret for the key, a ConfigMap for the spec, a PVC, a Recreate Deployment with /health startup and readiness probes, a ClusterIP Service, an ingress NetworkPolicy that admits only OpenShell supervisor Pods, and waiting for the rollout, because apply does not check the server.
    • examples/kubernetes/in-cluster-vllm.yaml (endpoint and credential) and in-cluster-ollama.yaml (endpoint only).
    • docs/inference.md (service-mode row, the HTTPS exception, link from "Supply the Key on Other Platforms"), docs/limits.md (the Qualify more platforms, placements, models, and integrations #12641 row now covers only services NemoClaw places) and docs/security.md (who can read the key; the plain-HTTP exception).
    • schemas/nemoclaw-v1alpha1.schema.json and docs/reference/configuration.md are regenerated.
  4. Provider fix (fix(openshell-provider): resolve credential variables on managed Kubernetes gateways)
    • Why it is here: the key from commit 2 cannot reach OpenShell on a managed Kubernetes gateway without it. It also fixes every other provider with a credential on such a gateway, HTTPS included.
    • Failure: since feat(openshell-provider): connect to managed Kubernetes gateways #13264, the provider reaches a managed Kubernetes gateway through a port-forward and resolved every secret reference through ForwardSecrets. That map holds only the forward's bearer token and TLS file paths, named token, ca, certificate and key. A provider's credential_env, such as QWEN_INFERENCE_KEY, missed it, so apply failed with "observation authentication failed" and the gateway received no CreateProvider. A credential_env named token resolved, and sent the gateway's bearer token to OpenShell as the provider's credential.
    • Change: the forward's secrets authenticate only the connection. Objects resolve their references from the environment, as on a direct connection, so no reference reaches the forward's values, whatever its name. OpenShell::connect_with_credentials (crate-private) takes the two resolvers separately; connect_with_services passes the same one for both, so direct connections are unchanged. A missing or empty variable still fails with Authentication.
    • The first live run used a scratch fix that fell back to the environment for names the forward lacks. This commit does not do that: under that approach token still resolved to the gateway's token, which the second new test catches. The second live run used this commit.
  5. Docs corrections from review and the first live run (docs(kubernetes): correct the in-cluster model server steps)
    • Step 1 sets memory { gpu_memory_gib = 20, kv_cache_gib = 6 }. Without it, Qwen3-4B's 7.5 GiB of weights, the default 8 GiB KV cache and 2 GiB exceed the default 16 GiB budget, and the server crash-loops with "model weights exceed the declared GPU memory budget". docs/provider.md's vllm_runtime example gets the same block.
    • Step 1 sets tool_parser = "hermes" and reasoning_parser = "qwen3"; without a tool parser, vLLM answers OpenClaw with HTTP 400.
    • A "Run Ollama Instead" subsection replaces the one-line Ollama instruction: ollama_runtime on port 11434, the Ollama runtime image, the names ollama, no key, probes on GET /api/version (Ollama has no /health), and the example's sandbox namespace.
    • runtimeClassName where the node's default container runtime is not NVIDIA's.
    • The NetworkPolicy paragraph says that anyone who can create a Pod in the sandbox namespace can carry the supervisor labels and reach the server, and that the policy is a keyless server's only access control.
    • The ports OpenShell refuses for declared hosts: 2379, 2380, 6443, 10250 and 10255 (BLOCKED_CONTROL_PLANE_PORTS, OpenShell 5a7728c).
    • Changing the key: a new variable name, because apply does not notice a new value behind the same name; replace the Secret, restart the server, then apply, which updates OpenShell's registration in place. Requests fail in between.
    • A docs/limits.md row for what has been tried and what is untested.
  6. Docs from the second live run (docs(kubernetes): finish the in-cluster server steps from the live run)
    • Both examples set maxTokens: 2048 on the route, with a comment. Without it, OpenClaw asked vLLM for max_completion_tokens=166699, and vLLM, with a 32768-token context, answered 400; 8192 also failed, because OpenClaw's prompt is about 22-28k tokens. v1's OpenClaw examples all set maxTokens, and examples/managed-ollama-gpu.yaml uses 2048 for the same Ollama model.
    • "Run Ollama Instead" names every change: the ollama provider and the data.ollama_runtime.ollama.spec output in step 1, the ConfigMap ollama-runtime in step 2, and configMapKeyRef.name ollama-runtime and claimName ollama-data in step 3. It replaces the copied probe comment "GET /health needs no key".
    • For Ollama, rollout status finishes as soon as Ollama listens, before the runtime has loaded the model, so step 4 also waits for the runtime's log line "ready: managed service readiness confirmed".
    • "You need" states the node memory that both runtimes check at start: host_reserve_gib (default 32) plus 20 GiB of the node's available memory for a GPU with its own memory, or the GPU budget plus 20 GiB on dgx-spark and rtx-spark (vllm::hardware_capacity::check_memory, ollama::hardware_capacity::check_memory).
    • After a key change, readers remove the old key from their secret manager and unset its variable.
    • One sentence says that OpenClaw, which both examples use, cannot start in OpenShell sandboxes with the pinned Fabric (OpenClaw does not start in OpenShell sandboxes with Fabric v0.5.0 #13372).
    • The docs/limits.md row now says the vLLM and Ollama runtimes were tried on one kind cluster; OpenShift and other network plugins are untested.

The second v1 merge:

  • deployment_journey counts 40 single-sandbox examples: v1 added eight and this branch adds two.
  • The configuration reference keeps v1's api description and this branch's credential and endpoint descriptions; schema --check reports both generated files current.
  • feat(openshell-provider)!: make sandbox policy grants an unlabeled list #13384 made policy.managed an unlabeled list, so two tests from this branch now find the inference grant by its name.

The third v1 merge (#13390, #13388, #13409, #13413):

git diff --stat upstream/v1 HEAD:

 Cargo.lock                                         |   1 +
 crates/nemoclaw-authoring/src/discovery_queries.rs |   4 +-
 .../nemoclaw-authoring/tests/deployment_journey.rs |   2 +-
 .../nemoclaw-authoring/tests/discovery_queries.rs  |  39 +++
 crates/nemoclaw-sdk/src/config/constraints.rs      |   3 +
 .../nemoclaw-sdk/src/config/schema/validation.rs   |  32 +-
 crates/nemoclaw-sdk/src/config/types.rs            |   4 +-
 crates/nemoclaw-sdk/src/inference_discovery.rs     |  56 ++-
 crates/nemoclaw-sdk/tests/kubernetes_inference.rs  | 390 +++++++++++++++++++++
 crates/nemoclaw-sdk/tests/main.rs                  |   2 +
 crates/openshell-provider/Cargo.toml               |   2 +
 crates/openshell-provider/src/client.rs            |  18 +-
 crates/openshell-provider/src/connected.rs         |   1 +
 .../openshell-provider/src/fake_gateway_tests.rs   | 235 +++++++++++++
 crates/openshell-provider/src/transport.rs         |  21 +-
 docs/inference.md                                  |   3 +
 docs/kubernetes.md                                 | 304 +++++++++++++++-
 docs/limits.md                                     |   3 +-
 docs/provider.md                                   |   5 +
 docs/reference/configuration.md                    |   4 +-
 docs/security.md                                   |   3 +-
 examples/kubernetes/in-cluster-ollama.yaml         |  53 +++
 examples/kubernetes/in-cluster-vllm.yaml           |  55 +++
 schemas/nemoclaw-v1alpha1.schema.json              | 224 +++++++++++-
 24 files changed, 1442 insertions(+), 22 deletions(-)

Production code is about 125 lines; the schema grows because the document-level key rule repeats for each provider location. rcgen is a new dev-dependency of openshell-provider, for the fake gateway's certificates; the lock file already held it.

Breaking or user-visible changes

  • Accepted now: with a Kubernetes or OpenShift gateway, a provider endpoint of the Service form plans and compiles, and may carry credential. Plan and onboarding read no model catalog for it, so a successful plan does not show that the server runs or serves the route's model.
  • Fixed: on a managed Kubernetes gateway, a provider's credential variable resolves from the environment where nemoclaw runs, as on every other gateway, instead of failing apply. A variable named token, ca, certificate or key no longer resolves to the forward's own credentials.
  • Unchanged: Docker and Podman gateways still reject the Service form, with or without a key. Every other http: endpoint still takes no key.
  • Key transport: a key for the Service form crosses the cluster network over plain HTTP unless the network plugin or a service mesh encrypts Pod traffic. The docs say so.
  • Error text: a key on a plain-HTTP endpoint now fails with "credential requires an HTTPS endpoint, or an http://SERVICE.NAMESPACE.svc.cluster.local:PORT endpoint with a Kubernetes or OpenShift gateway" instead of "...: not". A key on the Service form with Docker or Podman fails with "credential on an http://SERVICE.NAMESPACE.svc.cluster.local endpoint requires a Kubernetes or OpenShift gateway".
  • Examples: two new single-sandbox examples, both with OpenClaw. The authoring example check now covers 40, and onboarding generates two more example journeys. With the pinned Fabric v0.5.0, OpenClaw does not start in OpenShell sandboxes (OpenClaw does not start in OpenShell sandboxes with Fabric v0.5.0 #13372), as for every OpenClaw example on v1.
  • Rust API (publish = false crates): new nemoclaw_sdk::inference_discovery::is_cluster_service_endpoint and EndpointRequest::for_provider. nemoclaw_authoring::inference_request_for_document returns None for such a route, as it does for a managed-service route.
  • No change to compiled graphs, state, or provider schemas.

Test proof

cargo ci --full (linux_arm64, final head)

It ran on head eda1e3fbe, tree 27f526e77, with upstream/v1 at 64c384eff.

ok tools in 0s
ok fmt in 1s
ok clippy in 27s
ok build in 48s
     Summary [  20.436s] 1568 tests run: 1568 passed, 204 skipped
ok test in 26s
ok schema in 0s
ok bundle in 66s
     Summary [ 116.878s] 153 tests run: 153 passed, 51 skipped
ok lifecycle in 122s
All selected CI steps passed in 292s
cargo-ci-exit=0 elapsed=295s
  • The test step's 4 doctests passed. It ran 1568 tests, 4 more than at 59545ebf4: the third merge's v1 commits add 4 tests to this step. This PR's 14 new names are its 12 tests and the 2 generated onboarding journeys (tui::tests::example_journeys::kubernetes_in_cluster_{vllm,ollama}).
  • Lifecycle ran 153 tests, as before the third merge; this PR adds none.
  • Timing budgets, reported only on this host: every step and every budgeted binary is within budget (openshell-provider::contract 99.3 s of 105 s).

New tests: red without the production change, green with it

Twelve new tests, plus two onboarding example journeys that the build generates from the new examples. Red runs reverted only production sources in the working tree, or ran before they existed; the final cargo ci --full ran on the committed tree.

Test Red: before its production change Green
kubernetes_inference::a_cluster_service_endpoint_is_an_http_service_dns_name_with_an_explicit_port (7 accepted and 38 rejected endpoints) the function does not exist; the red run used a panicking stand-in, which fails passes
kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service (Kubernetes and OpenShift, external and managed) endpoint_requests fails: "HTTP requires a literal loopback address or private inference address" no catalog read
kubernetes_inference::a_cluster_service_compiles_to_a_literal_server_and_an_fqdn_sandbox_rule compile fails: "inference discovery inputs are invalid" literal server, FQDN rule without allowed_ips or cluster_grants, Fabric base_url
discovery_queries::a_cluster_service_route_has_no_control_host_catalog_to_read (authoring) inference_request_for_document returns Some(EndpointRequest { endpoint: "http://qwen.models.svc.cluster.local:8000/v1", .. }) None; neither plan nor onboarding reads a catalog
kubernetes_inference::a_cluster_service_endpoint_takes_a_key_only_with_a_cluster_gateway (5 provider locations; compiled credential_env) the input schema rejects the key on Kubernetes accepted on Kubernetes and OpenShift, rejected on Docker and Podman with the named error
kubernetes_inference::a_constructed_document_cannot_send_a_key_to_a_service_from_a_local_gateway the Kubernetes document with a key does not parse ("violates schema … : not") validate rejects the document after its gateway moves to Docker
kubernetes_inference::only_the_service_form_takes_a_key_over_plain_http the Service form with a key does not parse (left: false, right: true) an http: endpoint with a key parses exactly when is_cluster_service_endpoint accepts it
openshell-provider fake_gateway_tests::a_managed_kubernetes_gateway_resolves_provider_credentials_from_the_environment provider: Some(Authentication), the live failure the fake gateway stores the provider with this process's PATH as its credential
openshell-provider fake_gateway_tests::a_providers_credential_variable_never_resolves_to_the_forwards_credentials token registers with the forward's bearer token (left: None, right: Some(Authentication)) token, ca, certificate and key each fail with Authentication, and the gateway receives no provider

The two provider tests reach the fake gateway through GatewayClient with a fake forward that supplies a bearer token and mutual-TLS files, as SdkKubernetes does; the fixture gateway requires both, so the workspace and profile they create first also show that the forward still authenticates the connection. PATH stands in for a key because a test cannot set a variable safely while other tests run. With the first live run's scratch fallback in place of the fix (mutation), the first test passes and the second fails at token.

Guards and characterization, which pass before and after by design:

  • kubernetes_inference::local_gateways_still_reject_a_cluster_service_endpoint fails when the skip ignores the gateway runtime (mutation).
  • kubernetes_inference::other_endpoints_on_cluster_gateways_keep_their_catalog_reads fails when any http: name containing .svc counts as a Service (mutation); that mutation also fails the endpoint table.
  • Dropping the sandbox agent.inference location from the document-level key rule fails a_cluster_service_endpoint_takes_a_key_only_with_a_cluster_gateway at "docker agent inference" (mutation).
  • openshell-provider fake_gateway_tests::a_service_name_profile_and_a_sandbox_without_grants_pass_endpoint_ambiguity_checks (rows from the local and hermes-auth fixtures, unauthenticated and authenticated): it composes the provider profile and the sandbox policy that the fake gateway received with OpenShell's own compose_effective_policy and find_endpoint_ambiguities. The check finds no ambiguity, and a ClusterIP on the sandbox's rule alone gives exactly one allowed_ips conflict. It passes on v1 with no production change; the first live run confirmed it on an OpenShell v0.1.4 gateway, and the second stored the same rule.

Other checks

  • The docs' vllm_runtime and ollama_runtime blocks, including the Ollama block's new spec output, and docs/provider.md's vllm_runtime example compute their specs with OpenTofu 1.12.6 and the vllm and ollama providers of the final head's bundle. ollama_runtime reports port 11434, /data and no key_env, and both specs carry hostReserveGiB 32, the default the node-memory bullet names.
  • The documented Secret and ConfigMap commands, and the Secret replacement for a key change, produce the expected objects in a kubectl client dry run against an empty kubeconfig; the second live run ran the Secret and ConfigMap commands on a cluster. The key change was never run on a cluster.
  • nemoclaw-build docs, then docs --check, pass on the final head, including link and anchor checks. nemoclaw-build fern check needs Node.js, which this host lacks; deferred to CI.
  • Not run live: commit 6 as committed (the vLLM route's maxTokens: 2048 ran; the Ollama example's did not, and the Ollama readiness wait was observed, not run as written), the third v1 merge, the key change, OpenShift, and other network plugins.

Live evidence (not qualification; #12732 stays open)

The second live run, on 2026-10-18, used head 59545ebf4: v1 7d7772eda and commits 1-5. Since then the branch gained commit 6, which makes the docs changes this run called for, and the third v1 merge (64c384eff); this PR's own code did not change, and v1's changes from that merge did not run live.

Setup. A kind cluster with one GB300 worker and the nvidia RuntimeClass (the worker's containerd default runtime is runc). The linux_arm64 bundle came from that head's cargo ci --full; the vLLM runtime, Ollama runtime and OpenClaw agent images were built from that head and loaded on the worker by digest. The docs steps ran as written, except for the namespaces, the image digests, the deployment UID and context, hardware (gb300, arm64), and runtimeClassName: nvidia, which step 3 says to set on such a node.

Locally modified agent image. With the pinned Fabric v0.5.0, OpenClaw cannot start in OpenShell sandboxes (v1 #13372). The first apply registered the keyed provider and created the sandbox, then stopped at the agent with start_failed; Fabric's start reported setpriv: activate capabilities: Operation not permitted, with and without the key. Every later apply in this run used the head's OpenClaw image with /usr/bin/setpriv removed, built locally for this run only. Without setpriv, Fabric's adapter runs the OpenClaw gateway directly.

Keyed vLLM (in-cluster-vllm.yaml with QWEN_INFERENCE_KEY set):

  • Provider fix: apply registered the keyed provider qwen on the managed Kubernetes gateway. At 620ea6966 this step failed with "observation authentication failed".

  • Server: steps 1-4 created the Secret, ConfigMap, PVC, Deployment, Service and NetworkPolicy, and rollout status finished in 296 s. Inside the model Pod, /health answered 200 without a key; /v1/models answered 401 without a key and with a wrong key, and chat 401 without a key; with the key, /v1/models and a chat with tools and tool_choice: auto answered 200.

  • Policy rule: a read-only GetSandbox showed one network rule, the same after each sandbox replacement:

    sandbox assistant phase SANDBOX_PHASE_READY policy version 1; policy-input cluster_grants: []; managed rules: ["nemoclaw-inference-qwen-eb79800cf1772956a635ba0b"]
    rule nemoclaw-inference-qwen-eb79800cf1772956a635ba0b: qwen.nemoclaw-pr13063-r2-models.svc.cluster.local:8000 ports [8000] protocol=rest allowed_ips=[] binaries=2
    rules with allowed_ips: []; Service ClusterIP 10.96.23.27 appears in policy: 0
    

    The agent's model entry names that endpoint as base_url, and its key variable holds an openshell:resolve:env: placeholder.

  • OpenClaw turn: with the example's route as committed before commit 6, the turn failed with vLLM 400 (max_completion_tokens=166699 cannot be greater than max_model_len); with maxTokens: 8192 it failed the same way (prompt of at least 24,577 tokens). With maxTokens: 2048 the turn succeeded: 6 × POST /v1/chat/completions -> 200, all from the sandbox's OpenShell supervisor Pod; the sandbox's workload Pod never reached the server. The 4B model did not reply with the requested words; it tried a messaging tool.

  • 401 without the key: a Pod with the supervisor labels in the sandbox namespace got GET /v1/models 401 without a key, while the supervisor's requests got 200, so OpenShell supplied the key.

  • Key exposure, 0 matches in each place: the sandbox environment (only the placeholder variable and NEMOCLAW_ANONYMOUS_API_KEY="unused" name a key); all 24 sandbox files under /sandbox and /tmp outside the Node compile cache, including OpenClaw's configuration, its SQLite WAL and its log; export; the deployment state directory; ConfigMaps in both namespaces; Secrets in the gateway namespace, raw and base64; the logs of 4 gateway-namespace containers; the model Pod log.

  • Export: keeps credential: {env: QWEN_INFERENCE_KEY} and maxTokens: 2048; planning the export reports no changes.

Keyless Ollama ("Run Ollama Instead" steps 1-4, then in-cluster-ollama.yaml without maxTokens):

  • rollout status finished in 25 s; plan and apply succeeded; one turn replied "in-cluster ok" with 1 × POST /v1/chat/completions -> 200 from the supervisor Pod.
  • The stored policy held one rule, ollama.nemoclaw-pr13063-r2-omodels.svc.cluster.local:11434 ports [11434] protocol=rest allowed_ips=[], with cluster_grants: []. The agent uses NEMOCLAW_ANONYMOUS_API_KEY.
  • The rollout finished 45 s before the runtime logged "ready: managed service readiness confirmed"; commit 6 adds that wait to step 4.
  • Planning the export reports no changes.

NetworkPolicy:

  • vLLM: plain Pods in the sandbox namespace, the server namespace and default timed out, and so did a Pod with the supervisor labels in default.
  • Ollama: plain Pods timed out; a Pod with the supervisor labels in the sandbox namespace got 200 on /api/version and /v1/models. Without a key, the NetworkPolicy is the only access control, as the docs say.

Earlier findings. The first live run (2026-10-16, head 620ea6966 on v1 ef3115d4e) found the provider bug that commit 4 fixes and the docs gaps that commit 5 fixes; this run confirmed both. Its re-apply-after-destroy failure is fixed in v1 by #13408: here, destroy and a new apply with the same state succeeded.

v1 observations, not this PR: after the failed agent start, plan --destroy and destroy succeeded. After that start failure, apply refused to replace the sandbox for a changed image.ref ("apply cannot replace sandbox 'assistant'; its files and conversation history are not separately retained"), but replaced it for a changed route maxTokens, which deletes the same files.

Cleanup. Both destroys completed; the run's namespaces and their PVs were deleted; the cluster's namespaces, PVs, PVCs and cluster-scoped objects match the start; GPU memory was 0 MiB at the end. The key file was deleted after the last check.

Review items left unchanged

  • On a cluster gateway, a mistyped Service endpoint (for example http://qwen.models.svc:8000/v1) fails planning with the generic "inference discovery inputs are invalid" (discovery.rs drops the cause). The text predates this PR; a hint naming the accepted form could follow separately.
  • A trailing space or NUL in a Service endpoint is accepted, because validate_endpoint_url rejects only some control characters. The host stays the Service, so the key goes nowhere else; the fix belongs in endpoint validation for every endpoint, separately.
  • The feat commit messages say "Q1" and call the endpoint table red; the PR body is what lands on squash merge, and it describes both correctly.

Questions pending with the maintainers (#12641)

  • Q1, key over in-cluster HTTP: may a YAML provider set credential on the Service form with a Kubernetes or OpenShift gateway? HCL already allows it, and managed Docker vLLM already sends its key over private HTTP. If not, drop the second commit and the key parts of the docs and the vLLM example; the routing half needs no decision, and commit 4 stands on its own.
  • Q2, discovery: may compile skip the control-host catalog read for these endpoints? The control host cannot resolve cluster DNS; this follows refactor: stop checking external inference servers from the control host #13291.
  • Q3, cluster domain: this PR accepts only the lowercase <service>.<namespace>.svc.cluster.local form. OpenShell's own is_kubernetes_service_host (profiles.rs, 5a7728c) also accepts <service>.<namespace>.svc, any letter case, and a trailing dot. Should NemoClaw accept those, or a custom cluster domain?
  • Q4, NetworkPolicy selector: the docs admit Pods labelled openshell.ai/boundary-role=supervisor (with openshell.ai/managed-by=openshell), OpenShell's own labels at 5a7728c. Anyone who can create a Pod in the sandbox namespace can set them. Is that stable enough to document, or should we ask OpenShell for a supported selector?

🤖 Generated with Claude Code

Update (maintainer)

Merged v1 and reworked, following the principle settled in #13131: NemoClaw does what it owns, and leaves destination policy to OpenShell (#13232).

  • No cluster-DNS special cases. Removed is_cluster_service_endpoint, CLUSTER_SERVICE_ENDPOINT, the cluster-only credential exception, and the rule rejecting a cluster address with a key on Docker or Podman. Instead, the general provider rule forbidding a credential on http: endpoints is gone. OpenShell decides where a sandbox's key may go, as it already decides where its traffic goes.
  • Catalog reads. Plans no longer read catalogs (refactor: stop checking external inference servers from the control host #13291). Discovery now builds a catalog query only for endpoints NemoClaw's own connection rules allow (HTTPS, or HTTP to a literal loopback or private address). Others, such as a cluster Service, get none, rather than making compilation fail. Onboarding then can't suggest that server's models.
  • Kept: the credential fix for Kubernetes gateways (the connection's secrets are separate from those of the objects it manages), its fake-gateway tests, the compile test for routing to a cluster Service, and both examples. kubernetes_inference.rs now checks that any HTTP or HTTPS endpoint takes a key on any gateway, wherever the provider is declared.
  • Docs: "Use a Model Server in the Cluster" is now a short section. The server is deployed with the platform's own tools, and "Supply the Key on Other Platforms" covers the key. The step-by-step runbook was removed. inference.md and security.md say to prefer HTTPS for credentialed endpoints, because over plain HTTP the key travels unencrypted. limits.md keeps the two model-server rows and drops the resolved Authenticate a managed Kubernetes gateway through an existing OIDC issuer #12692 and Pull images from private registries #12709 rows.

cargo ci passes locally: 1,565 unit tests and 153 lifecycle tests. fern check reports 0 errors.

gaveezy and others added 13 commits October 12, 2026 15:35
Native vLLM authentication guards only `/v1` paths. On a live bearer
service, `POST /invocations` returned a full chat completion without the
key, and `/tokenize` and `/metrics` answered too (review finding X1).
Recipe `VLLM_*` variables can also register management routes under
`/v1`, such as `/v1/load_lora_adapter`, which any key holder could then
call (X1-L1).

Bearer services now launch with `--middleware
nemoclaw_vllm_routes.OpenAIRoutes`, which vLLM adds as its outermost
user middleware. It passes `GET /v1/models`, `POST` to the five
inference endpoints, and public `GET /health`. Every other request,
including `OPTIONS` (X1-N2) and `HEAD /health` (X1-N1), gets 404 before
reaching vLLM, and WebSockets are closed. The `vllm`, `vllm-amd64` and `qwen38` images install the filter,
run a GPU-free check against vLLM's own `build_app` during the image
build (X1-T1), and carry `org.nemoclaw.inference.routes=openai-v2`.
Docker bearer installs require that label, and the provider's rejection
names it and `docs/build.md` (X1-N3). The build stages the route files
only into contexts whose Dockerfile copies them (X1-N4). Services
without authentication are unchanged.

BREAKING CHANGE: bearer vLLM images built before this change lack the
routes label, so plan and apply reject them. Rebuild them.

Validation:
- `cargo ci` passed in 690 s on Linux ARM64: 1380 tests, 4 doctests,
  and 127 lifecycle tests.
- With the production hunks reverted, the 4 new or extended Rust tests
  fail and the build-context test does not compile. They pass on this
  branch.
- Removing the label from the lifecycle fixture makes the two bearer
  `remote_service` tests fail at plan, through the bundled provider,
  with the new rejection.
- The image-build test file passed 6/6 against vLLM's real app in an
  image built from #12736 whose route files are byte-identical. With a
  pass-through filter 4 of the 6 tests fail; with the earlier
  `openai-v1` filter, 3 fail.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and test fixtures

## Failure

Review of #12736 found six problems that do not depend on Kubernetes:

- OpenShell rejection text was discarded. `remote_error` maps every
  gateway status to a fixed category, so on kind a CreateSandbox
  rejection for conflicting `allowed_ips` endpoint metadata reached the
  user only as "observation query failed".
- Removing a ready sandbox still read its active-policy status, which
  teardown does not use; a failing status read blocked removal.
- The deployment lock is an `flock` on the open file description. A
  child spawned concurrently holds a copy of the descriptor until
  `exec`, so dropping `Store` could leave the deployment locked, and the
  next open failed with "another operation holds the deployment lock".
- Several tests wrote a script and executed it at once. A concurrent
  spawn that inherited the write descriptor made the exec fail with
  "Text file busy" (ETXTBSY).
- `cargo images build --platform linux/amd64 hermes` failed with Bake's
  "failed to find target hermes".
- The docs did not give the OpenClaw request format, how to recover when
  a malformed request leaves the runtime `unknown` (#12642), or that
  gateway profiles written before #12941 cannot be read.

## Decision

- `ObservationError` gains `Rejected { operation, code, detail }`.
  `remote_rejection` keeps the gateway's detail only for CreateWorkspace,
  CreateSandbox, DeleteProvider and DeleteProviderProfile, whose
  requests carry no credentials, and only for FailedPrecondition,
  InvalidArgument, AlreadyExists, OutOfRange and ResourceExhausted.
  `sanitized_detail` reduces the detail to printable ASCII of at most
  1024 characters and redacts bearer tokens, key/value credentials and
  token-like runs; `sanitized_resource_detail` also keeps one known
  resource name. Credential-bearing requests, reads and exec keep
  category-only errors.
- `Rejected` owns its text, so `ObservationError` is `Clone` but no
  longer `Copy`; workspace callers clone it.
- Teardown of a ready sandbox skips the active-policy status read. The
  owned identity checks still run.
- `Drop for Store` unlocks before the file closes, which releases the
  lock for every copy of the descriptor.
- Test fixtures execute an existing interpreter or binary and pass the
  written script as data. The provider staging test, which now runs the
  staged file through `/bin/sh`, asserts the executable bit that
  OpenTofu needs.
- `images::plan` lists each platform's harnesses with
  `buildx bake --print agents` and names the platforms that build a
  requested harness; other selections keep Bake's resolution.
- Docs: the headless OpenClaw request, the reported malformed-request
  failure and the whole-deployment replacement procedure, which
  rejections keep their detail, and the profile-format break.

API change: `ObservationError` (also `nemoclaw_sdk::ObservationError`)
is no longer `Copy` and has a new variant. Code that copies it must call
`.clone()`, and exhaustive matches need a `Rejected` arm. Every use in
this workspace is updated.

## Validation

- `cargo ci` on linux_arm64 passed in 690 s: fmt, clippy `-D warnings`,
  build, 1387 nextest tests (174 skipped) and 4 doctests, schema,
  bundle, and 127 lifecycle tests (48 skipped).
- Each new test failed with its production change reverted and passed
  with it: the two `remote_rejection` unit tests, the three redaction
  tests, the rejection-detail and ready-sandbox teardown fake-gateway
  tests, the lock test, and the harness-platform test. The
  credential-privacy test passes on v1 by design; it failed when
  CreateProvider was opted into rejection detail. The staging test
  failed when staging cleared the executable bit.
- Repeated `cargo test` runs on this host: the `nemoclaw-sdk` lib suite
  passed 22 of 22 runs (v1: 7 of 22, with tests that reopen the
  deployment lock failing), and the `nemoclaw-test-fixtures` lib suite
  50 of 50 (v1: 46 of 50; the kept failure logs show "Text file busy").
  The other touched suites passed 10 of 10 on both.
- `nemoclaw-build docs --check` passed.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odel budget

Plan and apply accepted OpenClaw and Hermes routes to managed vLLM and
Ollama services whose serving.contextTokens could not hold the agent's
prompt, and reported nothing. The managed Ollama examples served 8192
tokens, while one measured initial OpenClaw prompt used 19,947 tokens.
The pinned Hermes Agent refuses a window below 64,000 tokens or, when
it cannot read the window through the sandbox proxy, assumes 131,072
(review finding HM-1).

Before any mutation, plan and apply now emit Progress::Warning for a
route to a managed vLLM or Ollama service when:
- an OpenClaw route's effective contextWindow exceeds the service's
  serving.contextTokens;
- the smaller of the two cannot hold 20,000 prompt tokens plus the
  route's reply allowance;
- the route's token metadata cannot be assessed; or
- a Hermes route's service serves fewer than 64,000 tokens.
The warnings never reject a document. The CLI collects them even with
--progress off and prints them in text output and in a JSON `warnings`
field, including when the command fails. The managed Ollama examples
now serve 32768 tokens with a matching route contextWindow.

Progress gains a Warning variant, so exhaustive matches on it need a
new arm.

Validation: cargo ci passed on linux_arm64 in 526 s (fmt, clippy
-D warnings, build, 1391/1391 tests, schema, bundle, 127/127 lifecycle
tests). Without the production change the 14 new tests do not compile.
With only the Progress::Warning variant, 10 of the 12 advisory tests
fail, and the 2 tests that assert no warning fail under boundary
mutants (<= 64000, >= contextTokens). With the CLI ignoring warnings,
both CLI tests fail. The branch CLI reports 2 and 1 warnings for the
previous managed Ollama examples and none for the updated ones.
`nemoclaw-build docs --check` passes.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts and profile sources

## Failure

#12736 routes sandboxes to model Pods that the deployment runs in its
cluster, and the OpenShell and Fabric providers could not express that:

- Provider credentials are parsed and resolved only through
  `nemoclaw_docker::credentials`; a caller cannot supply another source.
- An inference profile grants only the literal IP in its endpoint URL.
  A cluster model is reached by a `<name>.svc.cluster.local` host, so a
  sandbox policy cannot grant its ClusterIP, and nothing checks which
  Service owns the address.
- Two internal invariants, the profile metadata field set and the
  static search rule, were enforced with `expect`, so a violation would
  abort the provider instead of returning an observation error.

Review finding N1b on #12736: only the ignored bundled lifecycle test
constructed `FabricProvider::with_services`, so a regression that
dropped the injected callbacks passed the regular test step.

## Decision

- `openshell_provider::Services` validates and resolves credential
  sources, validates a cluster source, and returns a cluster Service's
  verified addresses. `DockerServices` keeps the Docker credential
  behaviour and returns `BindingMismatch` for every cluster source.
  `GatewayClient::with_services`, `OpenShell::connect_with_services`,
  `OpenShellProvider::with_services` and `FabricProvider::with_services`
  inject an implementation. `Default` and `OpenShell::connect` use
  `DockerServices`, and the bundled provider binaries still use the
  defaults.
- `openshell_provider_profile` gains an optional `cluster_source`. It is
  a bound field, resets when omitted on update, and any change replaces
  the profile. `nemoclaw_openshell::profile::cluster_definition` accepts
  only an `http://<host>.svc.cluster.local:<port>/v1` endpoint and grants
  only the addresses `Services::cluster_addresses` returns, after
  `service_address_allowed` rejects unspecified, loopback, multicast,
  link-local, broadcast and IPv4-mapped addresses. The source and
  addresses are kept in their own annotations; refresh re-reads the
  addresses and refuses a profile whose endpoints no longer match.
- `PolicyInput.cluster_grants` names managed rules whose `allowed_ips`
  come from verified cluster profiles (`RuntimeBinding::granted_policy`).
  Sandbox create and refresh check each grant against the deployment's
  own profile. The field is omitted from serialized policy when empty,
  so stored sandbox annotations do not change.
- `nemoclaw_tofu::Definition::bound_fields`: refresh returns
  `BindingMismatch` when an observed bound field differs from state,
  treating omission as the empty value. Without it, a refresh wrote a
  substituted `cluster_source` into state.
- `annotations()` returns `Result`, so unknown metadata returns
  `Incomplete`; an unparsable search rule returns `Query`.
- The SDK's `image_runtime::policy_input` sets an empty
  `cluster_grants`; nothing in the SDK produces grants yet.

Docker and Podman deployments are unchanged: the SDK emits no cluster
source or cluster grants. The provider schema gains
`openshell_provider_profile.cluster_source` and the `openshell_sandbox`
policy block's `cluster_grants`; with `DockerServices`, a resource that
sets either fails when the provider creates or reads it.

## Validation

- `cargo ci` on linux_arm64 passed in 709 s: fmt, clippy
  `-D warnings`, build, 1393 nextest tests (174 skipped) and 4
  doctests, schema, bundle, and 127 lifecycle tests (48
  skipped), including all 44 `openshell-provider::contract` and
  3 `fabric-provider::contract` tests.
- On the base, the two new `nemoclaw-provider` refresh tests fail and
  the other four new tests do not compile. On this tree, each new test
  failed under a mutant of the production code it covers and passed
  without it: dropping the `bound_fields` check, restoring the v1
  profile definition, making `FabricProvider::with_services` ignore its
  services (the N1b mutant), and restoring either `expect`.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…el services

Managed vLLM and Ollama containers on Docker always ran with a fixed
104 GiB memory limit and no CPU cap. Any image, model, or serving change
replaced a running model container without asking, so a routine re-apply
could take a serving model down.

Each managed vLLM or Ollama service now accepts container.cpuLimitMillis,
container.memoryLimitGiB, and a service-level updatePolicy (Preserve, the
default, or Recreate):

- A CPU limit becomes a CFS quota per 100 ms period, the period kubelet and
  docker --cpus use, raised to the kernel's 1 ms minimum. A memory limit
  sets memory and memory_swap. Omitted limits add no CPU settings or
  labels and keep the 104 GiB memory limit.
- Labels force replacement when a limit changes. The pinned Docker
  provider (v4.6.0) otherwise updates limits in place: it drops the CFS
  quota from updates, and lowering memory on a running model can OOM-kill
  it (review finding CL-1).
- Under Preserve, plan and apply refuse a plan that deletes a running or
  incompletely observed model container, or lowers its memory, with
  DockerModelUpdateRefused. The CLI help names
  spec.services.<name>.updatePolicy. Missing or stopped containers are
  still replaced.
- An explicit memory limit must cover private shared memory and the
  recipe's preparation memory.

Breaking change: under the default Preserve, changing a Docker model's
image, model, serving settings, or limits no longer replaces a running
container. Set updatePolicy: Recreate to allow the replacement and its
downtime. The release notes, inference guide, and change table say so.

Validation on linux_arm64: cargo ci passed every step in 686 s: fmt,
clippy -D warnings, build, 1385 nextest tests and 4 doctests, schema
check, bundle, and 127 lifecycle tests. Each of the 8 new tests fails
on v1 without this change, and the remote_service lifecycle scenarios
fail against a bundle built from v1's production code.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Kubernetes API

## Failure

#12736 runs vLLM and Ollama model services on managed Kubernetes and
OpenShift gateways. The SDK had no code that creates, verifies, updates
or removes a model's cluster objects, so a cluster gateway could not
host a model service.

The review of #12736 at 487cfc8 found these defects in that code; the
code here contains the fixes from the later #12736 commits:

- X2-AUTOSCALE (high): readiness stopped on the first
  `PodScheduled=False/Unschedulable`, which Kubernetes also reports while
  an autoscaler adds a Node, preemption runs, a claim binds or a device
  plugin registers.
- X2-PRESERVE-NEVER-SERVED and X2-PREFLIGHT-TERMINAL (medium): `Preserve`
  refused to replace a Pod that never served, and the Node check ran for
  Failed and never-scheduled Pods, so recovery needed list-Nodes
  permission and broke on admission-injected init containers.
- X2-RBAC-MSG, X2-RECREATE-NONSCHED and X2-TESTS (low): a denied Node
  list read "observation permission denied", an image-only update under
  `Recreate` skipped the Node check, and 8 preflight mutants survived.
- STOPPED-RT (low, code part): `ModelRuntimeStopped` did not name the Pod.

## Decision

Add the reconciler as an SDK library behind a configuration gate, so it
can be reviewed and tested before any document reaches it:

- `kubernetes::services`: `Spec` and `StorageSpec` for the
  `kubernetes_service` and `kubernetes_service_storage` resource kinds;
  retained model and credential PVCs; an immutable ConfigMap, a
  ClusterIP Service, a NetworkPolicy that admits only OpenShell
  supervisor Pods on the serving port, and a non-root single-GPU Pod.
- `Operations`: preflight, ensure, read, remove, recover and wait_ready.
  Each create saves its address in a local receipt first, so a lost
  response is reported, not adopted. Every read verifies the cluster,
  namespace UID, claims and owned objects against the receipt.
  Admission is checked with server-side dry runs, for replacements under
  temporary names before the current Pod is stopped.
- Readiness: a 30 s transient budget, a 9 h overall budget, and a
  15-minute Unschedulable grace that restarts when the rejection clears
  and ignores Pods nominated by preemption. Only a fresh runtime status
  with a nonzero PID from the recorded container is ready.
- Update policy: `Preserve` refuses to replace a Pod that may be serving
  (`status::may_serve`). Before `Recreate` replaces one, the admitted
  replacement is checked against Node labels, taints and allocatable
  capacity; changed scheduling inputs need list-Nodes permission and the
  refusal names it.
- `ObservationError` gains the Kubernetes object, model runtime,
  scheduling, update-refusal, unrecorded-resource and admission
  variants. `Cluster` gains `create_model`, `dry_run` and
  `dry_run_object`. vLLM and Ollama services gain an optional
  `kubernetes` field. The fake Kubernetes API gains fault controls.
- Gate: Kubernetes and OpenShift gateways keep `spec.services`
  `maxProperties: 0`, and every other gateway forbids a service's
  `kubernetes` field. No document can reach the new code.

The cluster rule that requires `container.cpuLimitMillis` and
`container.memoryLimitGiB` with `kubernetes` is left for the PR that
lifts the gate. With it, a Docker service with `kubernetes` and no
limits was refused with "cluster model services require
container.cpuLimitMillis" instead of the gate.

## Validation

- `cargo ci` on linux_arm64 passed in 722 s: fmt, clippy `-D warnings`,
  build, 1507 nextest tests (174 skipped; 89 new) and 4 doctests,
  schema, bundle, and 127 lifecycle tests (48 skipped), including the
  `kubernetes_hcl` and `kubernetes_lifecycle` provider contract tests.
- On the base, the new integration tests do not compile (no
  `nemoclaw_sdk::kubernetes::services`), and the readiness and status
  unit tests live in modules this commit adds. The two gate tests also
  failed on the base, because the field does not exist there.
- With the container-limit rule restored, both gate tests failed with
  the limit message. 15 production mutants each failed at least one new
  test, 45 of the 89 in total: no Unschedulable grace, no grace reset,
  nominated Pods counted as rejected, no `Preserve` refusal, every Pod
  treated as serving, no Node check, no dry runs, unverified claims or
  cluster identity, open ingress, stale status accepted, terminal Pods
  ignored, unchecked object drift, and either gate rule removed.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gateways

## Failure

Managed Kubernetes and OpenShift gateways rejected every vLLM and Ollama
service, so a cluster deployment needed a model endpoint outside
NemoClaw. The reconciler behind the configuration gate could not be
used: nothing compiled a document to its resources, and the provider
did not serve them.

The review of #12736 found these defects in the code that connects it;
this commit contains the #12736 fixes:

- X2-TAINT (high): a first apply that stopped at readiness, for example
  on an Unschedulable Pod, left the service resource tainted; no
  supported apply recovered it.
- NEW-M1-DRIFT (low): no OpenTofu contract test changed cluster objects
  between applies.
- N2b and X1-N3 (nits): a wrong-architecture runtime image got the
  generic metadata message, and the label message did not name
  org.nemoclaw.inference.routes.
- STOPPED-RT (docs part), D3n, L1 and MG-WORD-3 (docs).

## Decision

Lift the gate for managed cluster gateways and connect the reconciler:

- Configuration: a vLLM or Ollama service on a managed Kubernetes or
  OpenShift gateway needs `kubernetes` settings, explicit
  `container.cpuLimitMillis` and `container.memoryLimitGiB`, private IPC
  and no Docker placement; `KubernetesService::resolve` combines them
  with the service-level `updatePolicy`. External gateways still reject
  services, and Docker and Podman still reject `kubernetes`.
- Compile: the runtime stage emits `nemoclaw_kubernetes_service_storage`
  (prevent_destroy) and `nemoclaw_kubernetes_service`, ahead of agents.
- Provider: `ClusterServicesBackend` serves both types. Owner and
  generation are derived from the spec. A first apply that is not ready
  returns `Mutation::stopped`: complete state with a warning, so
  OpenTofu does not taint it and an unchanged apply resumes waiting.
  The provider refuses bound port changes and removal outside destroy.
- Images: plan and apply verify each cluster runtime image's platform
  and labels from its metadata bundle; bearer vLLM needs the routes
  label.
- Deployment: cluster bindings and teardown, corrections limited to
  model workloads after a failed rollout, and a NetworkPolicy warning
  for every cluster service.

Sandboxes cannot route to these services yet: that needs endpoint grants
and credential reads that are not part of this commit. Validation
rejects a provider whose `serviceRef` names a cluster service with
"inference providers cannot reference cluster model services yet; use an
external endpoint", instead of the later "invalid native inference
policy". Tests use temporary fixtures with an external endpoint. The
legacy `kubernetes.{cpuLimitMillis,memoryLimitGiB,updatePolicy}` layout
from #12736 branch builds is not accepted.

## Validation

- `cargo ci` on linux_arm64 passed in 607 s: fmt, clippy `-D warnings`,
  build, 1544 nextest tests (182 skipped; the base ran 1507) and 4
  doctests, schema, bundle, and 135 lifecycle tests (48 skipped; the
  base ran 127), among them the 8 new contract tests through OpenTofu.
  `nemoclaw-build docs --check` passed.
- On the base, with this commit's tests: the SDK and provider
  integration binaries do not compile (`Mutation::stopped`,
  `Definition::derived`); with those two files from the base, 18 new
  tests fail, and the 8 contract tests fail because the base provider
  does not serve the resource types. 12 unit tests are in files the base
  lacks. 10 pass on the base, which rejects every cluster service.
- 22 production mutants, applied one at a time, each disabled one
  change, such as the X2-TAINT fix (`Mutation::stopped` replaced by a
  partial error), the routing refusal, the container-limit rule, owner
  and generation derivation, the bound port refusal or the routes label.
  Together they failed 37 of the 48 new or renamed tests. Three
  survived: the defensive Docker `Preserve` guard, the SDK's
  retained-storage comparison and the deployment image preflight, which
  the provider repeats.
- `nemoclaw-provider::contract` summed budget 110 -> 150 s: the 8 new
  tests add 43.6 s locally, about 30 s at CI speed, putting the binary
  at its old budget.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
## Failure

Sandboxes could not use the cluster vLLM and Ollama services that the
previous commit deploys: validation refused every inference provider
whose `serviceRef` names a cluster service. Without that refusal, a
routed document failed with "invalid native inference policy": the
sandbox policy had no way to grant the private Service address, and the
OpenShell provider could not read the bearer key, which lives in the
model Pod's credential PVC.

The review of #12736 found these defects in the routing code; this
commit contains the #12736 fixes:

- F1 (blocker): OpenShell rejected every sandbox that used a cluster
  model service, because the sandbox rule and the provider profile gave
  the same endpoint different `allowed_ips`.
- F8 (high): the endpoint used the short `<svc>.<ns>.svc` name, which
  does not resolve in OpenShell sandboxes (no DNS search list).
- U1 (low): a serving-port change got the generic sandbox refusal
  instead of naming whole-deployment destroy.
- T2-PINS (low): three cluster credential-source checks had no test.
- SEC-TRUST (low, security and inference guides), NEW-SDK-LIFECYCLE,
  MG-WORD-2, T5-T7 and DOCKER-CONTRAST (nits).

## Decision

Route only through identities the deployment owns and verifies:

- Credentials: a bearer cluster vLLM registration carries a
  `clusterService` credential source (owner, model name, storage, exact
  endpoint). The bundled OpenShell provider validates it and reads the
  key by exec into the model Pod, only while the Pod runs with its
  recorded identity; the key stays out of OpenTofu state.
- Grants: the provider profile carries `cluster_source` provenance and
  the sandbox policy marks the rule as a cluster grant. The provider
  fills it with the owned Service's verified ClusterIPs, after checking
  that ready EndpointSlice members are the recorded Pod.
- Endpoints use `<service>.<namespace>.svc.cluster.local`, compared
  exactly with the bound storage.
- A routed cluster service's port change is refused before runtime
  reconciliation with the port message, even with separate state files.
- The bundle's OpenShell and Fabric providers are built from
  nemoclaw-provider with these callbacks (`OpenShellServices`).
- Add `examples/kubernetes/local-{vllm,ollama}.yaml`, the cluster cases
  of the context advisory, and the security and routing docs, and list
  the `cluster_credentials` lifecycle tests in the contributing docs.
  Remove the previous commit's refusal, its test and the unrouted test
  fixtures.

## Validation

- `cargo ci` on linux_arm64 passed in 661 s: fmt, clippy `-D warnings`,
  build, 1573 nextest tests (185 skipped; the base ran 1544) and 4
  doctests, schema, bundle, and 138 lifecycle tests (the base ran 135),
  among them the two bundled cluster credential tests and the SDK
  port-change test. `nemoclaw-build docs --check` passed.
- On the base (the previous commit's production code with this commit's
  tests): 26 of the 32 new tests do not compile, because they call APIs
  this commit adds (`Source::ClusterService`, `OpenShellServices`,
  `cluster_inference_profile`, the Pod credential and endpoint reads).
  The other 6, including the SDK port-change lifecycle test, fail: 5
  because the cluster examples are refused, 1 because export accepts
  endpoint provenance drift. Without the refusal, the 5 fail with
  "invalid native inference policy".
- 26 mutants, one at a time, each disabled one behavior the new tests
  cover: the credential source, its owner, name and host checks, the
  Pod readiness, restart and key-format checks, `cluster_source`,
  cluster grants, the EndpointSlice, ClusterIP and receipt checks, the
  exact FQDN, the port refusal, and the bundled providers' callbacks.
  Every new test failed under at least one. One survived: OpenShell's
  `.svc.cluster.local` suffix check, which the SDK's exact host
  comparison precedes on every path.

The tree equals #12736 merged with v1 except the dropped legacy-field
migration and the deviations the split documents.

Split from #12736.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

This repository limits you to 5 open pull requests. Please close or merge an existing PR before opening another one.

@github-actions github-actions Bot closed this Oct 13, 2026
gaveezy and others added 9 commits October 13, 2026 02:39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base now includes v1 025b95a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR-6 now includes v1 025b95a. Resolve the docs conflicts with v1's
retained-resource removal (#12929):
- docs/inference.md: keep v1's link to Remove Retained Resources for Docker
  services and state that removing a cluster service's PVCs is not covered
  yet (#12640), because that procedure covers only Docker engines.
- docs/kubernetes.md: keep this branch's destroy and retention text and add
  v1's sentence that removing the retained resources is not covered yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR-7 now includes v1 025b95a and its resolution of the docs conflicts
with v1's retained-resource removal (#12929). The merge is clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bearer route filter was a Python ASGI middleware loaded through
vLLM's `--middleware` flag. Three images installed it and ran a Python
check during every build, and the build staged both files. NemoClaw
keeps its own code and tests in Rust.

The supervisor now owns the published port for bearer services. It
binds `0.0.0.0:<serving.port>` before starting vLLM, so a port conflict
fails startup, and starts vLLM on `127.0.0.1` at the next port, or 65534
when `serving.port` is 65535. Its hyper HTTP/1.1 server forwards only
`GET /health`, `GET /v1/models` and `POST` to the five inference
endpoints, matching the method and the raw request-target path exactly.
Every other request, including absolute-form targets, `CONNECT`,
`OPTIONS`, `HEAD` and protocol upgrades, gets 404
`{"error":"Not found"}` without a connection to vLLM. Forwarded
requests keep their query and end-to-end headers, including
`Authorization`, lose hop-by-hop headers, and stream in both
directions; a client disconnect closes the vLLM request, and an
unreachable vLLM gives 502. vLLM's uvicorn trusts forwarding headers
from loopback, so the filter sets `X-Forwarded-For` to the connecting
address and drops `X-Forwarded-Proto`. Request headers must arrive
within 30 s. If the filter fails, the supervisor stops vLLM and reports
the error; when supervision ends, the filter closes its listener and
connections. Readiness still probes `/v1/models` with the key, now
through the filter. Services without authentication are unchanged.

The Python filter, its build check and their staging are removed, and
`runtimes/vllm/test_auth.py` returns to its v1 content. The images keep
`org.nemoclaw.inference.routes=openai-v2`, which now identifies the
supervisor filter. The runtime declares hyper, hyper-util and
http-body-util at the versions reqwest already locks; its dependency
closure gains only httpdate 1.0.3.

Validation:
- `cargo ci` passed in 537 s on Linux ARM64: 1401 tests,
  4 doctests, and 127 lifecycle tests.
- The 15 route tests do not compile without `routes.rs`. Each of 15
  mutations of it, such as passing every request, keeping hop-by-hop
  headers, buffering responses or dropping the header timeout, fails
  at least one of them. The changed SDK launch test fails on the parent.
- The ignored retained-source rebuild passed offline in 52 s.
- An image built from this tree with `runtimes/vllm/build.json` has
  ID sha256:6adb9cc9088b and the routes label, and contains no Python
  route file. It was not run on a GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gaveezy and others added 2 commits October 18, 2026 10:48
v1 moved from 7d7772e to 64c384e (#13390 to #13413).

Conflict: docs/security.md's inference transport row. #13388 says
NemoClaw accepts HTTP and HTTPS URLs and recommends HTTPS for
credentialed endpoints; this branch adds that a key for an in-cluster
Service endpoint crosses the cluster network over plain HTTP. The row
keeps both, and v1's new onboarding catalog row.

`schema --check` reports both generated files current.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second live run on kind followed the corrected "Use a Model Server in
the Cluster" steps and both examples, and a review read them again. The
run worked only after a change to the vLLM example, and found gaps in
the Ollama steps.

## Failure

- With the vLLM example as written, OpenClaw asked for
  `max_completion_tokens=166699`, and vLLM, with a 32768-token context,
  answered 400. With `maxTokens: 8192` it still answered 400, because
  OpenClaw's prompt is about 22-28k tokens. 2048 worked.
- For Ollama, `rollout status` finished at the first `GET /api/version`,
  but the runtime logged "ready: managed service readiness confirmed"
  about 50 s later, after loading the model. Requests before then can
  fail.
- "Run Ollama Instead" did not say to install the `ollama` provider, to
  read `data.ollama_runtime.ollama.spec`, or to rename the Deployment's
  `configMapKeyRef` and `claimName`. Followed as written, the Ollama Pod
  waits for the vLLM ConfigMap or mounts the vLLM PVC. The copied probe
  comment "GET /health needs no key" was wrong for Ollama.
- The page did not say that both runtimes refuse to start without
  `host_reserve_gib` (default 32) plus 20 GiB of the node's available
  memory, on a GPU with its own memory.
- The key change did not say to retire the old key.
- Both examples use OpenClaw, which cannot start in OpenShell sandboxes
  with the pinned Fabric (#13372); the page did not say so.

## Change

- Both examples set `maxTokens: 2048` on the route, with a comment, as
  v1's OpenClaw examples do; `examples/managed-ollama-gpu.yaml` uses the
  same value for `qwen3:0.6b`. The Ollama example says to wait until
  the model is loaded.
- "Run Ollama Instead" names the `ollama` provider, shows the `spec`
  output, lists the `configMapKeyRef` and `claimName` renames, gives the
  probe comment for Ollama, and waits for the runtime's log line after
  the rollout.
- "You need" states the node memory check, from
  `vllm::hardware_capacity::check_memory` and
  `ollama::hardware_capacity::check_memory`: `host_reserve_gib` plus
  20 GiB for a GPU with its own memory, the GPU budget plus 20 GiB on
  `dgx-spark` and `rtx-spark`.
- After a key change, readers remove the old key and unset its
  variable.
- One sentence links #13372.
- `docs/limits.md`: the Ollama steps have now been tried, so the row
  lists only OpenShift and other network plugins as untested.

## Validation

- The live run used `maxTokens: 2048` for vLLM and reached an OpenClaw
  reply. The Ollama turn ran without `maxTokens`; the value added here
  was not run.
- The docs' `vllm_runtime` and `ollama_runtime` blocks, including the
  new `spec` output, compute their specs with OpenTofu and the bundle's
  providers; both report `hostReserveGiB` 32.
- The onboarding journeys for both examples, `deployment_journey` and
  `kubernetes_inference` pass. `nemoclaw-build docs --check` passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaveezy gaveezy changed the title feat(kubernetes): route sandboxes to cluster model services feat(sdk): route sandboxes on Kubernetes gateways to in-cluster model servers Oct 18, 2026
@gaveezy
gaveezy changed the base branch from split/7-cluster-model-services to v1 October 18, 2026 11:01
@gaveezy
gaveezy marked this pull request as ready for review October 18, 2026 11:01
…-routing

Rework: drop the cluster-DNS special cases and remove the general rule that
forbade a credential on http: endpoints, leaving destination policy to
OpenShell. Discovery skips catalog reads NemoClaw's own connection rules
disallow instead of failing compilation. Keep the Kubernetes credential fix;
shorten the in-cluster model server docs.
@cv
cv enabled auto-merge (squash) October 18, 2026 12:53
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 1293189 into v1 Oct 18, 2026
@cv
cv deleted the split/8-cluster-sandbox-routing branch October 18, 2026 13:07
cv added a commit that referenced this pull request Oct 19, 2026
…in-cluster route (#13484)

## Failure

#12734 asks for unit and fixture coverage of managed-gateway OIDC
authentication, token refresh and authentication failures, and of
per-agent identity and routing for agents that use cluster-local
inference. The Kubernetes gateway code that #13414 and #13063 added had
little of either.

**OIDC.** Every SDK Kubernetes operations and connect test used the
development profile, so the `oidc` branches from #13414 had no unit or
fixture test: the auth resource identified by its namespace once ready,
no issuer objects or signing material, and the token read from the
variable `tokenEnv` names. The forwarded fake-gateway tests always
supplied the token the gateway expected. Only the live
`kubernetes_live::oidc` test refuses a token on the managed Kubernetes
path, and it checks neither the error class nor that nothing changed.

**Several agents on an in-cluster model.** `kubernetes_inference`
covered one sandbox, from the `local.yaml` fixture. No test checked
per-agent names or routes for the three-agent cluster examples:
`example_configurations_are_valid_fabric_configurations` compiles them
only to validate their Fabric configurations. The #13063 commit message
names catalog-skip tests, such as
`kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service`,
that v1 does not have.

## Decision

These tests characterize existing behavior; no production code changes.

### OIDC

- `kubernetes_operations`: with an `oidc` spec, `ensure` of the auth
resource adds no cluster objects and no local signing material. `read`
reports no identity before the resource is ready, and the namespace UID
after.
- `kubernetes_connect`: `running` takes the spec to prepare from. A
connection's token equals the value of the variable `tokenEnv` names,
and no state file contains it. When that variable is unset or empty,
`connect` fails with the `tokenEnv` message.
- Tests can't safely set a variable while others run, so `tokenEnv`
names variables that Cargo and nextest set for every test process:
`CARGO_MANIFEST_DIR` holds a token, and `CARGO_PKG_LICENSE_FILE` is
empty because the package declares an SPDX license. `PATH`, the
precedent in `fake_gateway_tests`, can't be used: the schema forbids it
as `tokenEnv`, so the operations refuse the spec with `Query` before
`connect` reads a token.
- `fake_gateway_tests`: the `Forward` stub's token is now a field, and
`Forward::client` opens a new `GatewayClient`. A gateway that requires a
fresh token refuses every call with a stale one, so nothing changes, and
the provider reports `ObservationError::Authentication` without state.
That variant carries no gateway text, so it can't echo the token. A new
client with the fresh token then succeeds, as the next command's
provider process would; a `GatewayClient` keeps its client for the
process's lifetime.

No test changes a variable's value between commands. That a refreshed
token takes effect on the next command follows from these tests and
`an_existing_issuers_token_reaches_gateway_only_runs`, which resolves
`tokenEnv` into OpenTofu's environment on each command.

### Three agents on one in-cluster route


`three_agents_on_a_cluster_gateway_share_one_service_registration_with_their_own_rules`
compiles `examples/kubernetes/external-gateway.yaml` and
`examples/openshift/external-gateway.yaml` with the provider endpoint
set to `http://qwen.models.svc.cluster.local:8000/v1`. It checks:

- one `openshell_inference` whose server is the Service endpoint with
the example provider's credential, and no `cluster_source`;
- in each of the three sandboxes, an FQDN rule for the Service's host,
port and `/v1/**`, without `allowed_ips` or `cluster_grants`;
- one `fabric_agent` per sandbox, named by that sandbox's `agent.name`,
whose models use the Service as `base_url`;
- the same graph with `spec.sandboxes` reversed.

`examples/kubernetes/managed-development.yaml` keeps its hosted
endpoint, because its explicit policies name it, and is checked only for
agent names. The test reads agent names from each document: `main` in
the external examples, `primary` in managed-development.


`a_cluster_service_endpoint_reads_no_catalog_while_https_and_private_addresses_keep_theirs`
pins the skip that #13063 landed in `endpoint_requests`: an endpoint
that fails `validate_endpoint`, such as plain HTTP to a Service name,
has no catalog request, while an HTTPS endpoint and plain HTTP to
`10.0.0.5` each keep one.

The rule lookup and the expected Service rule endpoints move into
helpers that the single-sandbox test also uses. Its assertions are
unchanged.

## Validation

The tests passed when added. If one fails later, the fix belongs in its
own PR, with that test as its failing test.

- `cargo ci` passed: tools, fmt, clippy, build, test (1606 passed),
schema, bundle, and lifecycle (150 passed), within budget.
- `cargo nextest run -p nemoclaw-sdk -E
'test(/kubernetes_connect|kubernetes_operations|kubernetes_inference|inference_discovery/)'`
and `cargo nextest run -p openshell-provider --lib` pass.
- `cargo test -p nemoclaw-sdk --test integration` on the three new OIDC
tests passes, so both Cargo variables are set under `cargo test` too.
- Each key assertion failed against a temporary change, since reverted.
- OIDC inputs and fixtures: development auth on `ensure`; an existing
auth directory; a receipt already marked ready; `tokenEnv` naming
another variable; the token copied into the state directory; a set
variable in the missing-token test; a missing client TLS Secret; the
stale forward supplying the fresh token; a gateway accepting any token;
a new client with a third token.
- Production mutations: `operations.rs` identifying the `oidc` auth
resource by its first issuer object; `operations.rs` accepting an empty
token; `Mutation::failed` carrying state; no credential on a
registration that several sandboxes share.
- Routing inputs: a second registration, another Service port, a
`cluster_source`, a cluster grant or `allowed_ips` on one sandbox,
agents named after their sandboxes (also for managed-development alone),
another model `base_url`, agent metadata that depends on sandbox order,
no validation skip, rejected private HTTP, and skipped HTTPS.
- On a single-node k3s v1.36.5 cluster (linux_arm64) with Agent Sandbox
v0.5.0, the `live-kind` profile without the kind-only registry test
passed:
`kubernetes_live::the_gateway_installs_authenticates_and_is_removed_keeping_storage`,
`kubernetes_live::on_openshift_the_sandbox_runs_as_the_namespace_uid`,
`kubernetes_live::oidc::a_managed_gateway_accepts_an_existing_issuers_tokens_and_refuses_another_audience`,
and the three `kubernetes_chart` tests. The agent was the Pi image from
v1 CI's `live-images-linux_arm64` artifact for `d33d50647`, imported
into k3s by digest. 6 passed in 82 s.
- Deferred to CI: `cargo ci live-docker`, and `cargo ci live-kind` on
kind including `kubernetes_live::registry`, which `cargo ci` selects
because `openshell-provider` changed. Docker isn't installed on this
host.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
cv added a commit that referenced this pull request Oct 27, 2026
…not on clusters (#13824)

## Failure

NemoClaw manages vLLM and Ollama containers on a local Docker engine
(`spec.services`) but places no model servers on Kubernetes or
OpenShift. The reason lived only in #12732's closing comments, and
`scope.md` lists the managed gateways among NemoClaw's kept decisions
but not managed model services. A contributor recently asked whether
cluster model servers were unsupported, or supported but still to be
translated into Kubernetes resources.

## Decision

Add the rule to the decisions `scope.md` keeps as NemoClaw's own
promises:

- **Docker:** NemoClaw manages the services because nothing else on a
single host decides whether a model fits the GPU and memory, when the
server is ready, or where its key and model cache live.
- **Kubernetes and OpenShift:** the platform does all of that (scheduler
and GPU device plugin, probes, Secrets, operators), so NemoClaw places
no model servers there. Sandboxes reach a server the platform runs
through an inference provider at its Service address (#13063).
- **Shared contract:** both paths start from the same runtime images and
the same `vllm_runtime` and `ollama_runtime` descriptions. The SDK's
managed installers compile the same data sources (`RUNTIME_DATA_SOURCE`
in `services/installers/{vllm,ollama}`). Only who applies them differs.

The entry links #12732, where the decision was made, and the "Use a
Model Server in the Cluster" section.

## Validation

`cargo run --locked -p nemoclaw-build -- fern check` reports 0 errors
and 1 warning, which is not from this change. `git diff --check` is
clean.
cv pushed a commit that referenced this pull request Oct 27, 2026
)

## Failure

Reviewing #13080's follow-ups (#13837) turned up docs that no longer
match v1: references to the Qwen recipe #13506 removed, an incomplete
list of cluster rights, links to closed issues as open work, an
HTTPS-only claim #13063 relaxed, and a skills example the schema
rejects.

## Decision

```mermaid
flowchart LR
    R["recipes.md: inline Qwen example and adapter"] --> R2["Removed (#13506)"]
    K["kubernetes.md: cluster rights"] --> K2["Add ServiceAccounts, Roles,<br/>RoleBindings, pods/portforward"]
    K3["kubernetes.md: #12709 open"] --> K4["Link Pull from Private Registries"]
    U["usage.md: Podman removal not covered"] --> U2["Link the Podman removal steps"]
    U3["usage.md: credentials require HTTPS"] --> U4["Prefer HTTPS, as inference.md says"]
    A["agents.md: harness under agent"] --> A2["harness, with kind, on the sandbox"]
```

- The rights are what the pinned chart creates with NemoClaw's values
(`serviceAccount.create` and `rbac.create` default on) and the
port-forward the SDK opens to the gateway pod.
- #12709 closed after #13412 added Docker registry logins; #12640's
Podman removal steps are in `usage.md`.

## Validation

- The `agents.md` example, merged into `examples/fabric-openclaw.yaml`,
validates against the schema; the old one fails with "'harness' was
unexpected".
- `cargo run --locked -p nemoclaw-build -- docs --check` passes; `git
diff --check` is clean.

Part of #13837.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
cv pushed a commit that referenced this pull request Oct 28, 2026
## Failure

`docs/limits.md` says NemoClaw's vLLM runtime has been tried as a model
server in the cluster, but the only such run (#13063, 2026-10-18) used a
locally modified OpenClaw image, and the row doesn't say whether a key
was used. `docs/kubernetes.md` still says the route was tried on one
kind cluster, although #12733's OpenShift Local run also got Pi replies
through in-cluster Ollama.

## Decision

The keyed run that #13546 asks for is now [recorded on the
issue](#13546 (comment)).
At `v1` `e2eb215a4`, an OpenClaw agent on a managed gateway got a reply
through an in-cluster vLLM server behind a key, on kind with one GB300
worker. The agent and runtime images were built from that revision
without changes.

- The limits row now names that run, and says vLLM on OpenShift is
untested.
- The Kubernetes guide's sentence counts the OpenShift Local node.

```mermaid
flowchart LR
  A[OpenClaw sandbox] --> S[OpenShell supervisor Pod]
  S -- key added by OpenShell --> V["vLLM Service<br/>models namespace"]
  V --> G[GB300 worker]
  R["Run record<br/>#13546"] -.-> L[docs/limits.md row]
  O["OpenShift Local Ollama run<br/>#12733"] -.-> K[docs/kubernetes.md sentence]
```

Part of #13546; it closes after this merges.

## Validation

- `git diff --check` is clean, and both links point at existing anchors.
- `nemoclaw-build fern check` didn't run locally because this host has
no npm, so CI runs it.
- The run itself is in the linked record. Since that run, `v1` has moved
to OpenShell 0.1.5 and Agent Sandbox v1.0.3.
@wscurran wscurran added feature PR adds or expands user-visible functionality security and removed security labels Oct 28, 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 feature PR adds or expands user-visible functionality platform: k8s Affects Kubernetes deployments provider: ollama Ollama local model provider behavior provider: vllm vLLM local or hosted provider behavior v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants