Skip to content

feat(sdk): reconcile cluster model storage and workloads through the Kubernetes API - #13061

Closed
gaveezy wants to merge 52 commits into
v1from
split/6-cluster-reconciler
Closed

gaveezy wants to merge 52 commits into
v1from
split/6-cluster-reconciler

Conversation

@gaveezy

@gaveezy gaveezy commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Parked after #13131. This branch still merges cleanly with v1 and its tests pass, but #13131 changed the direction for model servers off Docker: the platform owns placement, readiness and keys (#13149, #13225, #13226), while this PR has NemoClaw own the Pods, read readiness over pods/exec and keep a generated key in a PVC. It waits on the maintainers' answer on #12641 about whether the SDK should place model servers on Kubernetes, and in what form. Its CI is green (Windows included) as of e318119.

Add the SDK library that reconciles a vLLM or Ollama model's storage, network boundary and Pod through the Kubernetes API, behind a configuration gate: no document can reach it until #13062 lifts the gate.

Why

#12736 runs 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 one. This PR is that code, split out so it can be reviewed on its own; #13062 connects it to configuration, compile and the OpenTofu provider, and #13063 routes sandboxes to it.

The #12736 review at 487cfc8 found these defects in this code. The fixes landed in #12736 (321896e, 6410b9e, 4c9db77) and are part of this PR:

  • X2-AUTOSCALE (high): readiness stopped on the first PodScheduled=False/Unschedulable, which Kubernetes also reports while a cluster autoscaler adds a Node, preemption evicts victims, an Immediate claim binds or a GPU device plugin registers.
  • X2-PRESERVE-NEVER-SERVED (medium): the default Preserve refused to replace a Pod that never served (never scheduled, image pull failure), contradicting the documented "correct and apply again" recovery.
  • X2-PREFLIGHT-TERMINAL (medium): the Node check also ran for Failed and never-scheduled Pods, so recovery needed cluster-scoped list-Nodes permission and failed on admission-injected init containers.
  • X2-RBAC-MSG, X2-RECREATE-NONSCHED, X2-TESTS (low): a denied Node list read only "observation permission denied"; under Recreate an image-only update skipped the Node check and could delete the only running Pod on a cordoned Node; 8 preflight mutants survived the tests.
  • STOPPED-RT (low), code part: ModelRuntimeStopped did not name the Pod. The kubectl procedure is in feat(kubernetes): manage vLLM and Ollama services on managed cluster gateways #13062's docs.

X2-PV-TOPOLOGY (low) is not fixed: the Node check does not read the retained volume's PersistentVolume node affinity. #13062's kubernetes.md lists PVC topology among the limits of the check. X2-TAINT (high) is fixed in #13062.

What changes

  • Objects (nemoclaw_sdk::kubernetes::services): Spec and StorageSpec are the encoded specs of the kubernetes_service and kubernetes_service_storage resource kinds, and validate_resource_spec now decodes them. storage_objects builds the retained <name>-data PVC, plus <name>-auth for bearer vLLM. compute_objects builds an immutable ConfigMap, a ClusterIP Service, a NetworkPolicy that admits only OpenShell supervisor Pods on the serving port, and a Pod: non-root, RuntimeDefault seccomp, all capabilities dropped, no service account token, restartPolicy: Never, one GPU, CPU and memory requests and limits, and a node selector that includes the model's architecture.
  • Operations (Operations): preflight checks StorageClass, RuntimeClass and API permissions and dry-runs new objects; ensure_storage/read_storage, ensure/read/remove/recover and wait_ready.
    • Each create first saves its address in a local receipt, so after a lost response the next operation reports the unrecorded object's kind, namespace and name instead of adopting it.
    • Every read verifies the cluster identity, namespace UID, retained claims and owned objects against the receipt, and names the object and field that drifted (KubernetesObjectMismatch) without values.
    • Remove deletes the compute objects, waits for the Pod to go before removing its NetworkPolicy, and keeps both PVCs.
  • Admission: Cluster::create_model, dry_run and dry_run_object report admission rejections (400, 403, 422, 429) as Admission { kind, name, detail } with the detail bounded and redacted by fix: report bounded OpenShell rejections and harden teardown, locking, and test fixtures #13056's sanitized_resource_detail. Before a changed Pod or ConfigMap is replaced, the replacement is dry-run under a temporary <name>-check-<hex> name; a rejection leaves the running Pod and the receipt unchanged.
  • Readiness (readiness.rs, status.rs):
    • Transient read failures retry for 30 s; the whole wait is bounded at 9 h; authentication, permission and binding failures stop at once.
    • Unschedulable grace (A3): a scheduler rejection stops readiness only after it persists for 15 minutes, measured locally from its first observation and restarted when it clears. A Pod nominated by preemption (status.nominatedNodeName) keeps waiting.
    • A Pod is ready only when the runtime's /data/status.json, read by exec from the recorded container, is newer than the container's start and reports ready with a nonzero PID. Permanent waiting reasons and terminal Pods fail with ModelRuntimeStopped, which names namespace/pod.
  • Update policy: under Preserve (the default from feat(services)!: add container limits and updatePolicy for Docker model services #13058), replacing a Pod that may be serving returns ModelUpdateRefused. status::may_serve treats terminal Pods, Pods without a Node, and placed Pods whose runtime container never started (image pull, never-pull, invalid name, container configuration errors) as never served; they are replaced without Recreate.
  • Node-fit preflight (A2): before Recreate replaces a Pod that may be serving, the admitted replacement is checked against Node labels, taints and each Node's allocatable CPU, memory and GPU. Changed scheduling inputs (node selector, tolerations, RuntimeClass, architecture, CPU or memory requests) need list-Nodes permission, and a denial names it; unchanged inputs are checked only when Nodes are readable and refuse only for Node state that blocks them, such as a cordon or a new taint.
  • Types: ObservationError gains KubernetesObjectMismatch, ModelRuntimeStopped, ModelScheduling, ModelUpdateRefused, UnrecordedResource and Admission, with Display text. services::{KubernetesService, ServiceToleration, TolerationEffect, TolerationOperator} and the resolved KubernetesSettings; vLLM Service and ManagedOllama gain an optional kubernetes field.
  • Gate (config/schema/validation.rs): Kubernetes and OpenShift gateways keep v1's spec.services maxProperties: 0, and every other gateway forbids a service's kubernetes field. Two new tests pin both rejections.
  • Test support: the fake Kubernetes API (crates/test-support/kube_api.rs) gains fault controls (request and create failures, denied resources, delayed deletion, admitted Pod overlays, recorded dry runs) and unique UIDs from a counter. v1's pub fn status and its 40 kube_faults/kubernetes_* characterization tests are unchanged and pass.
  • Generated: the JSON schema and docs/reference/configuration.md.

Breaking or user-visible changes

  • No change for any document that validates today. Kubernetes and OpenShift gateways still reject every model service, and every other gateway rejects the new kubernetes field.

  • Error text when a document sets a service's kubernetes field:

    Gateway Base (split/base-1-5) This PR
    Docker or Podman … at spec.services.<name> (…): unknown fields are not allowed … at spec.services.<name> (…): not
    Kubernetes or OpenShift … at spec.services.<name> (…): unknown fields are not allowed … at spec.services (…): maxProperties, from the v1 rule that rejects every service there

    Observed with the gate tests' documents, with and without container limits. The Docker message is less specific than the base's: the forbid rule has no x-nemoclaw-error, as in [tracking] feat(kubernetes): manage vLLM and Ollama services (split) #12736.

  • Schema and configuration reference: they now describe spec.services.<name>.kubernetes (KubernetesService, ServiceToleration, TolerationEffect, TolerationOperator). The reference's Required column says "With a managed Kubernetes or OpenShift gateway", which is not true until feat(kubernetes): manage vLLM and Ollama services on managed cluster gateways #13062 lifts the gate.

  • Rust API (publish = false crates; every use in the workspace is updated): exhaustive matches on ObservationError need arms for the six new variants; struct literals of vLLM Service and ManagedOllama need kubernetes or ..Default::default(); nemoclaw_sdk::kubernetes::services and Cluster::{create_model, dry_run} are new public API.

  • No CLI, bundle, state or prose-docs change.

Test proof

cargo ci (linux_arm64, this branch)

Run on the GB300 host (aarch64). The tree tested, fb0b9e14b, is the commit's tree.

ok tools in 0s
ok fmt in 1s
ok clippy in 38s
ok build in 77s
     Summary [  23.558s] 1507 tests run: 1507 passed, 174 skipped
ok test in 29s
ok schema in 0s
ok bundle in 150s
     Summary [ 419.230s] 127 tests run: 127 passed (3 slow), 48 skipped
ok lifecycle in 424s
All selected CI steps passed in 722s

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

Red runs edited only the working tree and restored the commit's tree afterwards.

On the base (split/base-1-5, d587066), with this PR's tests and test support but the base's production code:

Tests Command Result on the base
The 75 new integration tests in kubernetes_services.rs and its six kubernetes_service_*.rs modules cargo test --locked -p nemoclaw-sdk --test integration --no-run does not compile: E0432 unresolved import nemoclaw_sdk::kubernetes::services, E0433 cannot find services in kubernetes (9 errors)
readiness::tests (10) and status::tests (2) – do not exist: they are unit tests in modules this PR adds
config_kubernetes::kubernetes_gateways_reject_services_even_with_complete_cluster_settings cargo test … --test integration -- <name> (with the kubernetes_services module left out) FAILED: rejected as unknown fields are not allowed at the service, not by the gate at spec.services
config_kubernetes::local_engine_gateways_reject_cluster_service_settings_without_asking_for_container_limits same FAILED: unknown field \kubernetes`` when the test builds the service

On this tree, one production mutant at a time. Command for each: cargo nextest run --locked -p nemoclaw-sdk --profile ci --no-fail-fast (729 tests). Every failure under every mutant was a new test; 45 of the 89 new tests fail under at least one mutant, and all pass on the commit.

Mutant (production change) New tests that failed
The #12736 container-limit rule kept in cluster_config::constrain (the slice as first built) both gate tests: cluster model services require container.cpuLimitMillis instead of the gate (cargo test … config_kubernetes::)
gate-docker-off: no else forbid of kubernetes local_engine_gateways_reject_cluster_service_settings_without_asking_for_container_limits
gate-kubernetes-off: Kubernetes gateways accept services that carry kubernetes kubernetes_gateways_reject_services_even_with_complete_cluster_settings (v1's kubernetes_rejects_managed_services_even_when_no_route_selects_them still passes)
grace-off (A3): ModelScheduling stops readiness at once readiness::tests::a_persistent_scheduler_rejection_stops_after_the_grace_period, …a_scheduler_rejection_that_clears_within_the_grace_period_does_not_stop_readiness, …the_grace_period_restarts_when_the_scheduler_rejection_clears, readiness::unschedulable_pods_keep_waiting_without_exec_or_mutation_until_scheduled
grace-no-reset: a successful observation does not restart the grace readiness::tests::the_grace_period_restarts_when_the_scheduler_rejection_clears
nominated-ignored: a nominated Pod counts as rejected readiness::tests::a_pod_nominated_by_preemption_keeps_waiting_past_the_grace_period
preserve-off: no ModelUpdateRefused under Preserve update_policy::default_policy_keeps_pods_that_started_or_may_be_serving, …default_update_policy_preserves_nonterminal_pods_configuration_and_saved_receipts, …changing_only_update_policy_keeps_compute_and_removing_it_restores_protection
may-serve-always: every non-terminal Pod may be serving (X2-PRESERVE-NEVER-SERVED, X2-PREFLIGHT-TERMINAL) 8, including update_policy::default_policy_replaces_pods_that_never_served, update_policy::reverting_a_recreated_pod_that_never_scheduled_needs_no_recreate, scheduling::replacing_a_pod_that_is_not_serving_skips_the_node_check
node-fit-off (A2): no Node check before Recreate stops a serving Pod 13, including an_update_with_no_matching_node_preserves_the_running_pod_and_receipt, scheduling::a_cordoned_node_preserves_the_running_pod_and_saved_receipt, scheduling::losing_node_read_permission_preserves_the_running_pod_and_receipt, scheduling::image_and_runtime_only_updates_refuse_when_no_node_can_run_the_unchanged_pod, scheduling::tolerations_and_architecture_alone_are_scheduling_changes
dry-run-off: server-side dry runs skipped model_preflight_checks_admission_and_permissions_without_creating_resources, replacement_admission_rejection_preserves_the_running_model_and_its_receipt, replacement_admission_uses_temporary_names_without_changing_the_workload, diagnostics::admission_details_preserve_the_requested_pod_name_without_exposing_credentials, diagnostics::api_conflicts_name_the_requested_object_and_preserve_durable_bindings
claims-unverified: retained claims not re-verified retained_claim_loss_and_substitution_block_compute_mutation, exec_boundary::runtime_reads_reject_identity_changes_during_status_exec
cluster-identity-off diagnostics::namespace_drift_names_the_live_or_retained_identity_without_its_value
ingress-open: ingress from any OpenShell-managed Pod model_ingress_admits_only_openshell_supervisors_in_its_namespace
stale-status: a status older than the container start counts status::tests::readiness_requires_a_fresh_status_with_a_nonzero_process_identifier
terminal-ignored: terminal Pods not reported during readiness timed out: readiness::terminal_runtime_status_reports_the_stop_detail_before_attempting_exec, readiness::readiness_retries_failed_status_reads_and_reports_the_runtime_stop_reason, readiness::readiness_fails_fast_on_permanent_waiting_reasons_without_echoing_kubelet_text
compute-drift-unchecked: Service, NetworkPolicy and ConfigMap drift not compared changed_network_specs_refuse_refresh_and_update_but_allow_explicit_removal, update_policy::update_policy_does_not_mask_or_authorize_owned_object_tampering, diagnostics::tampered_model_objects_identify_the_object_and_field_without_values

Integration test names are under kubernetes_services::. The other 44 new tests, mostly ones that check an update or recovery is allowed (for example explicit_recreate_replaces_a_running_pod_and_keeps_retained_storage, image_and_runtime_only_updates_do_not_require_node_read_permission), did not fail under these mutants; their red is the compile failure on the base.

Lifecycle tests

This PR adds no lifecycle-only tests. All 127 selected by the lifecycle profile passed (JUnit: ci-6-lifecycle.xml). The ones that run this PR's changed SDK Kubernetes code (Cluster::create, now a wrapper of create_with) through OpenTofu and the fake Kubernetes API:

  • nemoclaw-provider::contract kubernetes_hcl::kubernetes_resources_plan_from_typed_settings_and_reject_invalid_ones
  • kubernetes_lifecycle::kubernetes_resources_apply_observe_the_release_and_tear_down_keeping_storage
  • kubernetes_lifecycle::kubernetes_resources_refuse_replaced_or_missing_objects_without_recreating_them
All 127 lifecycle tests (passed)
  • fabric-provider::contract (3): capabilities::capabilities_judge_the_image_for_the_configuration, pi_configuration_updates_without_replacing_the_sandbox, readiness::readiness_reports_the_configured_agent_and_its_failed_health
  • nemoclaw-e2e::integration (49): deployment:: (24), export_observations:: (4), fabric_deployment:: (4), helm_recovery:: (5), inference_discovery::optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_uncertainty, multiple_providers::provider_union_export_reapply_drift_and_destroy_remain_scoped_to_each_sandbox, remote_service:: (9), sandbox_readiness::standalone_sandbox_completion_rejects_unknown_health_and_retains_bindings
  • nemoclaw-provider::contract (29): discovery:: (3), gateway_readiness:: (1), gateway_storage:: (1), inference_capabilities:: (3), kubernetes_hcl:: (1), kubernetes_lifecycle:: (2), provider_protocol:: (4), runtime_image:: (1), service_capacity:: (1), service_readiness:: (2), service_storage:: (6), vllm_runtime:: (4)
  • openshell-provider::contract (44): capabilities:: (2), standalone:: (20), and the 22 example configurations
  • nemoclaw-fixture-provider::archive the_fixture_provider_is_found_beside_the_test_executables, nemoclaw-test-fixtures::ssh_relay the_relay_is_found_beside_the_test_executables

Live test on a real cluster (not qualification; #12732 stays open)

No document can declare a cluster model service until #13062, so this PR was tested on kind nvkind-demo (Kubernetes v1.37, one GB300) with a small out-of-tree driver that calls this PR's own kubernetes::services::Operations entry points through a real Kubernetes client. The driver is not part of the PR and contains none of its logic.

  • Passed: Ollama and bearer vLLM reconcile (storage, Service, supervisor-only NetworkPolicy, hardened Pod, readiness over pods/exec), idempotent re-apply, named drift errors, out-of-band Pod deletion and recovery, Preserve/Recreate, the admission dry run, the scheduling preflight, the 15-minute Unschedulable grace (901 s) and never-served replacement, teardown keeping both PVCs and the key, RBAC preflight (missing pods/exec, missing node list), missing StorageClass or RuntimeClass, port change, and wrong or stale prior ids.
  • Found and fixed (85e2b93): the access review checked only create pods/exec, but the kube-rs exec is a WebSocket upgrade that Kubernetes 1.37 also authorizes as get pods/exec. An identity with only create passed preflight, created the Pod and took the GPU, then failed readiness after 31.7 s as Transport. Now the access review checks get pods/exec too, and a refused upgrade (401/403) reports Authentication/Permission. Re-run on the cluster: that identity is refused in 0.1 s and nothing is created; with create and get the model reaches ready in 35.6 s.
Full live evidence (scenarios, messages, timings)

Date: 2026-10-14. Scenarios a–h ran 08:30–08:53 UTC; the follow-up scenarios i and j ran 09:07–09:15 UTC. Tree: pr6-v1-146a e9b2567 (tree cf2dc9457), which is PR-6 head c6acfac merged with v1 146a120. Scenarios i-A, i-B and i-B2 were re-run at 09:42–09:45 UTC (i3) on PR-6 85e2b93 (tree d3703310a): e9b2567 merged with v1 4025928 (0f9a6ab), plus the fix for the gap below. i-B3 ran only in i3.

Result. Against a real API server, kubelet, scheduler, NetworkPolicy enforcement and GPU, PR-6 behaved as its fake-API tests describe on the paths exercised below. Those paths cover reconcile, observation, update policy, admission, scheduling, readiness, teardown, the RBAC preflight, class and port preflight, and prior-id binding. One gap was found in i-B. It is fixed in 85e2b93, "fix(sdk): require get pods/exec for cluster model readiness", and the re-run passes:

  • Gap (e9b2567). PR-6's access review checked only create pods/exec. Its exec is a kube-rs WebSocket upgrade, which is an HTTP GET, and on v1.37 that GET also needs get pods/exec. An identity with only create passed preflight, and ensure created the Pod, which took the GPU. Readiness then failed after 31.7 s as Transport ("observation transport failed") instead of Permission.
  • Fix (85e2b93). The access review also checks get pods/exec. An exec upgrade refused with 401 or 403 now maps to Authentication or Permission. Other upgrade failures stay Transport.
  • Re-run on 85e2b93 (i3).
    • With only create pods/exec, every entry point that runs the access review returned Permission in 0.1 s. No Pod was created, and the GPU stayed at 0 MiB (i-B).
    • With that Role and a Running Pod, wait_ready and read returned Permission in 0.1 s, where e9b2567 returned Transport after 31.7 s (i-B3).
    • With create and get, the identity reached running=true and remove cleaned up (i-B2). i-A is unchanged.

Two checks belong to #13063: EndpointSlice ownership and the credential exec. Paths that were not run are listed under "Not run".

Driver (not part of the PR)

  • Source and build. crates/nemoclaw-sdk/examples/pr6_live.rs is untracked in a scratch clone of the tree above (git status: only ?? crates/nemoclaw-sdk/examples/). It was built with cargo build --locked --offline -p nemoclaw-sdk --example pr6_live (1 m 37 s).
  • Rebuild for i3. The same untracked example on a checkout of 85e2b93 (branch pr6-fix-85e2; git status: only ?? crates/nemoclaw-sdk/examples/), built with cargo build --locked -p nemoclaw-sdk --example pr6_live (16 s). Cargo.lock is the same in both trees.
  • What it calls. It decodes a kubernetes::services::Spec with Spec::decode, which validates it. Each invocation then calls one PR-6 entry point: Operations::{preflight, preflight_workload, ensure_storage, read_storage, ensure, read, read_for_removal, wait_ready, remove, recover}. These are the entry points that kubernetes_services.rs and kubernetes_service_*.rs call. The driver reimplements no PR-6 logic.
  • Client. A real kube::Client from v1's kubernetes::connect(&ClusterTarget { kubeconfig, context }); server comes from kubernetes::server. Most scenarios used the admin context kind-nvkind-demo. Scenario i used a ServiceAccount token kubeconfig with the same server string, so the recorded cluster identity matches.
  • Gateway prerequisite. The tests write a gateway receipt by hand. The driver instead runs v1's own gateway storage step, kubernetes::operations::Operations::ensure with a kubernetes_storage spec. That step creates the namespace and KEK Secret and writes the receipt with storageReady. No Helm gateway or OpenShell is installed, and PR-6 does not need one.
  • Specs. These are the compiled nemoclaw_kubernetes_service specs of earlier live runs: Ollama from deploy-v14/ollama and vLLM from the feat(sdk): route sandboxes on Kubernetes gateways to in-cluster model servers #13063 vLLM run. They get new owner UUIDs, names, generations and nemoclaw-pr13061-* namespaces from mkspecs.py.
    • The initial phase ran at 08:30.
    • The follow-up phase loads the saved specs, so the retained storage keeps its identity, and then adds new variants.
    • A variant changes only the field under test, plus updatePolicy: Recreate where a replacement has to get past Preserve.
    • The one hand-written spec is ollama-cpu80-recreate (e′). It raises CPU request and limit to 80000m because Spec::decode requires request ≤ limit, and the limit was 4000m. The follow-up phase regenerates it from mem72-recreate, and jq -S shows it is identical to the file that was used.

Cluster and images

  • Cluster. kind nvkind-demo (context kind-nvkind-demo), Kubernetes v1.37.0, containerd 2.3.4, arm64. The worker nvkind-demo-worker has 1× NVIDIA GB300 (driver 615.71.09), 72 CPU, nvidia.com/gpu: 1 and RuntimeClass nvidia. StorageClass standard is local-path with WaitForFirstConsumer. kindnet enforces NetworkPolicy.
  • Ollama. docker.io/library/nc-prototype-ollama@sha256:dea377de7fca1869992f76f539826a8004f2886bc57844f047abfa4ea0ab6737, model qwen3:0.6b (digest 7df6b6e0…), profile gb300, port 18888, CPU 1000m/4000m, memory 32/64 GiB, storage 20 GiB.
  • vLLM. docker.io/library/nc-prototype-vllm@sha256:e198b2e5646a40fb7edcee684a3e8f71fbdddaa392ecb505e41c20ac1792306f. It is built from a later stack head (label openai-v2), and its supervisor is a superset of what PR-6 needs. Model Qwen/Qwen3-4B@1cfa9a72…, authentication: bearer, profile gb300, gpuMemoryGiB 20, kvCacheGiB 6, memory 32/64 GiB, storage 100 GiB.
  • Pulls. Both images were already on the worker by digest, so no image was pulled. The models were downloaded from their registries into fresh PVCs.

Scenarios

  • Times are the driver's elapsed_s.
  • "UID unchanged" means kubectl get -o jsonpath='{.metadata.uid}' gave the same value before and after.
  • "Receipt unchanged" means the local receipt's sha256 was unchanged.
  • Error texts are quoted exactly in "Messages" below.
  • (code) marks a statement that follows from PR-6's code and is not shown by a saved log.
What was done Observed Result
a Ollama fresh reconcile in -ollama: preflight, ensure_storage, preflight_workload, ensure, wait_ready ensure_storage (0.2 s) created a 20Gi standard PVC carrying owner and generation labels. ensure (0.4 s, running=false) created an immutable ConfigMap, a ClusterIP Service on 18888/TCP and a NetworkPolicy. The NetworkPolicy has policyTypes [Ingress] and admits only Pods labelled openshell.ai/managed-by=openshell and boundary-role=supervisor, on TCP 18888. The Pod spec: uid/gid/fsGroup 1000, runAsNonRoot, seccomp RuntimeDefault, no SA token, no privilege escalation, drop [ALL], nvidia.com/gpu 1/1, runtimeClass nvidia, restartPolicy Never, and nodeSelector arch/os. wait_ready returned running=true at 74.5 s, a figure that includes the model download. status.json: phase ready, pid 133, updated 08:32:30, after startedAt 08:31:21. PASS
a′ Idempotence: preflight_workload, ensure twice with the prior id, read, read_storage All OK in 0.0–0.7 s, with running=true and the same ids. All 5 UIDs were unchanged. The ConfigMap, Service, NetworkPolicy and PVC resourceVersions were unchanged. The Pod's changed once, from a kubelet status write at 08:32:51; managedFields show no write after PR-6's create at 08:31:16. Receipt unchanged. PASS
b1 Service drift: externalIPs: [192.0.2.10]. Checked with read, ensure and read_for_removal. read and ensure returned M1 (at spec.externalIPs). read_for_removal was allowed. preflight_workload returned OK (see the note under "Deviations"). After the logged restore, read was clean. Pod UID unchanged. PASS
b2 NetworkPolicy and Pod drift. All four cases checked with read; only the ingress case also with ensure. read:
• ingress plus namespaceSelector: {} → at spec.ingress
• egress [{}] plus policyTypes [Ingress, Egress] → at spec.policyTypes
• egress alone → at spec.egress
• Pod generation label overwritten → at metadata.labels[nemoclaw.nvidia.com/generation]
ensure (ingress case only) returned the same mismatch. Each case read clean afterwards. Only the ingress restore command was echoed to the log; for the other three, the log has only kubectl's patched/labeled output. That ensure also refuses the other three is (code): its read_for_removal checks the generation label, and its network-object loop checks policyTypes and egress.
PASS
b3 Pod deleted out of band, then read, recover, wait_ready read returned the same id with running=false. No snapshot was taken between read and recover, so "read changed nothing" is (code). recover created Pod fdd06271…, and wait_ready took 32.8 s. PVC UID unchanged. The runtime log has one downloading: line, verifying selected Ollama model snapshot. PASS
b4 Foreign busybox Pod on 18888 carrying the model's owner and service labels The EndpointSlice listed both Pods, and PR-6's read and ensure reported no drift. PR-6 lists no EndpointSlices; #13063 adds that check. n/a (#13063)
c Memory limit 64→72 GiB under the default Preserve preflight_workload and ensure returned M2 in 0.2 s. Pod UID fdd06271… unchanged; receipt unchanged. PASS
c′ Same change with updatePolicy: Recreate preflight_workload was OK in 0.3 s, and the Pod list afterwards shows no -check- Pod. ensure replaced the workload in 2.2 s, and wait_ready returned running=true in 34.0 s. The new Pod 8f1df9d4… has a 72Gi limit. PVC, Service (ClusterIP kept) and NetworkPolicy UIDs were unchanged; the ConfigMap was recreated together with the Pod. PASS
d LimitRange with Container max memory 80Gi, then Recreate at 96Gi preflight_workload and ensure returned M3 (Admission) in 0.2 s, from a server-side dry run under a temporary -check-<hex> name. Pod and ConfigMap UIDs unchanged; receipt unchanged. The LimitRange was deleted afterwards. PASS
e Recreate plus nodeSelector example.com/pr13061-absent=true preflight_workload and ensure returned M4 in 0.3 s. The Pod stayed Running and the receipt was unchanged. PASS
e′ Recreate plus CPU request and limit 80000m, against 72 allocatable CPU. The limit was raised because Spec::decode requires request ≤ limit. M5 in 0.2–0.3 s. Pod unchanged. PASS
f First create in -sched with the absent nodeSelector preflight_workload OK; ensure returned running=false in 0.4 s. The Pod was Pending with PodScheduled=False/Unschedulable. PASS
f′ wait_ready through the full Unschedulable grace Returned M6 (ModelScheduling) after 901.0 s, matching the 15 min grace. A later read returned the same id with running=false. No ModelRuntimeStopped was reported, which is correct because the Pod never ran. PASS
f″ Corrected spec (nodeSelector removed) with no updatePolicy ensure (0.6 s) replaced the never-served Pod (56d205ad… → a81f8fca…) without needing Recreate. The new Pod was Pending on "1 Insufficient nvidia.com/gpu" while vLLM held the GPU, and was scheduled at 08:47:42. wait_ready kept waiting through that rejection and returned running=true at 138.6 s; this includes the download into a new PVC. PASS
g vLLM with bearer auth in -vllm: ensure_storage, preflight_workload, ensure, wait_ready Two PVCs: -data 100Gi and -auth 1Gi. The Pod mounts /credentials with the same security context as in a. wait_ready started at 08:38:39 and returned running=true in 273.8 s; status.json reads updated 08:43:12.8. The run-1 log has 13 downloading: lines, 11 of them naming files, followed by loading: and ready:. The data volume now holds 8.1G (du on the node in the follow-up, after both runs). Key file 600:1:64:1000:1000, marker v1. PR-6's credential predicate (status.rs) passed when run via kubectl with its final cat replaced by echo; the exact command line was not echoed. Bearer filter from inside the Pod over loopback: /v1/models gave 401 with no key, 401 with a wrong key and 200 with the key; /health gave 200. A plain Pod got HTTP 000 (curl exit 28, blocked). A Pod with the supervisor labels got 401 (admitted). The key appears in neither the run-2 runtime log nor the saved logs. PASS
h remove, then re-reconcile on the retained storage (vLLM; also Ollama) remove took 2.0 s for vLLM and 2.0 s for Ollama. It deleted the Pod, NetworkPolicy, Service and ConfigMap. The PVCs kept their UIDs (17e50a3a…, a264fa9d…, 11379a0b…). Afterwards read returned id null and read_storage returned the same id.
• Receipt: no copy was saved right after vLLM's first remove, so compute [] / specification null at that point is (code). The final receipt shows both.
• GPU: 0 MiB is logged after Ollama's remove. After vLLM's first remove, the release shows as the -sched Pod being scheduled at 08:47:42.
• vLLM re-reconcile: ensure_storage with the prior id took 0.2 s, ensure 0.5 s and wait_ready 196.7 s. The run-2 log has a single downloading: line, verifying selected model snapshot. The key's inode and mtime were unchanged; its content was compared by sha256, and the hash was not kept.
• Ollama re-reconcile: ready in 34.2 s, with a verify step only.
• An unchanged vLLM ensure kept the Pod UID. The final removes took 2.2 s (vLLM) and 1.6 s (Ollama).
PASS
i-A RBAC, no pods/exec. ServiceAccount in -ollama with:
• Role: get, create, delete on pods, PVCs, ConfigMaps, Services and NetworkPolicies, plus list endpointslices.
• ClusterRole/Binding nemoclaw-pr13061-rbac: get on Namespaces kube-system and -ollama, StorageClass standard and RuntimeClass nvidia; list Nodes.
SelfSubjectAccessReview create comes from the default system:basic-user.
can-i returned yes for all of the above, and no for pods/exec (create and get), Secrets, list pods and other namespaces. read and read_storage returned OK, so the cluster-scoped reads pass. preflight, preflight_workload, ensure_storage and ensure each returned M7 (Permission) in 0.1 s. Replaying PR-6's 7 access reviews as the SA, in its order, only create pods/exec came back allowed=false. Objects and receipt unchanged. The message does not name the missing permission; the tests assert only an error and no change.
• Re-run on 85e2b93 (i3): the same can-i answers and the same M7 results in 0.1 s. Of the 8 replayed reviews, create pods/exec and get pods/exec came back allowed=false. Objects and receipt (1334b3e5…) unchanged.
PASS on both trees
i-B Same, plus pods/exec: [create] on the Role (the only change) • Gap, on e9b2567 (i2): all 7 reviews were allowed, and preflight / preflight_workload returned OK in 0.1 / 0.2 s. ensure as the SA (0.4 s) created the workload; Pod f92c27bc… ran and took the GPU (4871 MiB). Then wait_ready returned M8 (Transport) after 31.7 s, and read returned M8 in 0.1 s.
• Cause: the kube-rs exec is a WebSocket upgrade, which is an HTTP GET. Run as the same SA, kubectl's identical WebSocket GET was refused with "cannot get resource "pods/exec"" (AuthorizePodWebsocketUpgradeCreatePermission BETA=1), and kubectl then fell back to SPDY POST (101). kube-rs has no such fallback. kube-client 4.2.0 returns a non-101 reply as UpgradeConnection(ProtocolSwitch(status)), and status.rs mapped that to Transport (code). Adding only get fixed it (i-B2). The driver does not log the HTTP status of PR-6's own request.
• Fixed in 85e2b93: the access review adds get pods/exec, and status.rs maps an upgrade refused with 401 or 403 to Authentication or Permission.
• Re-run on 85e2b93 (i3): of the 8 replayed reviews, only get pods/exec came back allowed=false. preflight, preflight_workload, ensure_storage, ensure and recover each returned M7 (Permission) in 0.1 s. No ConfigMap, Service, NetworkPolicy or Pod was created, and kubectl get pods -A shows no model Pod. The receipt hash stayed 1334b3e5…, and the GPU stayed at 0 MiB with no compute processes. read returned id null.
PASS on 85e2b93 (FAIL on e9b2567; gap fixed)
i-B2 Role pods/exec: [create, get] • e9b2567 (i2): on Pod f92c27bc… from i-B, wait_ready as the SA returned running=true in 0.4 s, and read with the prior id returned running=true. This Role plus the ClusterRole is enough for ensure, readiness and remove.
• 85e2b93 (i3), from no workload: all 8 reviews were allowed. preflight and preflight_workload returned OK in 0.1 / 0.2 s, and ensure_storage (0.2 s) kept PVC 11379a0b…. ensure (0.4 s) created the ConfigMap, Service, NetworkPolicy and Pod 0680d6d6…. wait_ready returned running=true in 35.6 s, which includes the Ollama verify on the retained PVC. read with the prior id returned running=true in 0.2 s, and the GPU showed 4871 MiB.
• Teardown (i3): after i-B3, the Role got [create, get] back. wait_ready (0.4 s) and read returned running=true again. remove as the SA took 1.5 s and deleted the four compute objects. The PVC kept its UID, the receipt hash returned to 1334b3e5… and the GPU to 0 MiB. read then returned id null, and read_storage returned the same storage id.
PASS on both trees
i-B3 i3 only. Exec refused after readiness: Pod 0680d6d6… Running from i-B2, then the Role goes back to pods/exec: [create] wait_ready and read do not run the access review, so they reach PR-6's exec. On 85e2b93, wait_ready returned M7 (Permission) in 0.1 s, and read with the prior id returned M7 in 0.1 s. The Role differs from the passing i-B2 reads only in get pods/exec, so the refusal is the exec upgrade; the driver does not log the HTTP status of PR-6's own request. A retry would sleep 1 s first, so wait_ready stopped after its first attempt (code: readiness.rs retries only Transport, Query and Incomplete). On e9b2567 the same refusal gave M8 after 31.7 s (i-B). As the SA, kubectl's WebSocket GET to the same Pod was refused with "cannot get resource "pods/exec"", and kubectl fell back to SPDY POST (101). read_for_removal returned OK with running=false, because the removal read does not exec (code). Pod UID and receipt unchanged. PASS
i-C e9b2567 only (not re-run). X2-RBAC-MSG: ClusterRole without list Nodes; Pod f92c27bc… Running ollama-cpu2-recreate (base + Recreate + CPU request 1000→2000m): preflight_workload (0.3 s) and ensure (0.2 s) returned M9. ollama-mem72-recreate (memory limit only, so no scheduling input changed) passed preflight_workload in 0.3 s; the 403 is tolerated. Control: with list Nodes restored, the cpu2 preflight_workload returned OK in 0.2 s. Pod UID and receipt unchanged. Teardown: remove as the SA took 1.7 s, and GPU went back to 0 MiB. All 5 RBAC objects and the token kubeconfig were deleted; kubectl get returns NotFound for each. PASS
j0 New deployment in -misc (misc-base = Ollama + absent nodeSelector, so it never takes the GPU), before any receipt: read with a prior id M10 (Incomplete) in 0.0 s. Nothing exists yet. PASS
j1 StorageClass pr13061-absent (NotFound) with fresh storage preflight, ensure_storage and preflight_workload each returned M11 in ≤0.1 s. Nothing was created: no PVC and no service receipt. Only the gateway KEK Secret and gateway receipt from the gateway step exist. PASS
j2 Same StorageClass change after misc-base's PVC 317e9b95… existed preflight returned M12 (BindingMismatch). The storage spec no longer matches the receipt, and the class lookup is skipped once storage is complete. PASS
j3 RuntimeClass pr13061-absent (NotFound), with storage present preflight, preflight_workload and ensure (prior id) each returned M13 in ≤0.1 s. No ConfigMap, Service, NetworkPolicy or Pod was created; receipt unchanged. PASS
j4 Serving port 18888→18889 against the existing service. misc-base had been ensured: Service 10.96.174.79:18888, Pod Pending/Unschedulable, GPU 0 MiB. preflight_workload and ensure (prior id) returned M14 in 0.2 s. All 5 UIDs, the Service port and the receipt were unchanged. PR-6 handles this case. PASS
j5 Wrong or stale prior id against that deployment:
• unknown PVC UID + current generation
• current PVC UID + another generation
• unknown storage id
read (0.1 s), ensure (0.3 s), read_storage, ensure_storage and remove each returned M12 (BindingMismatch). UIDs and receipt unchanged. Control: with the correct id, read and ensure returned OK. PASS
j6 remove with the correct id Took 0.2 s and deleted the ConfigMap, Service, NetworkPolicy and Pod. The PVC (Pending, no PV ever bound) and the KEK Secret remain. Receipt: compute [], specification null. PASS

Messages (exact; … shortens the generated object names):

  • M1: Kubernetes Service nemoclaw-pr13061-ollama/nc-…-model-… does not match its saved binding at spec.externalIPs; resources retained. The other drifts differ only in kind and field.
  • M2: Kubernetes model Pod nc-…-model-… is preserved by service updatePolicy: Preserve; replacing it requires explicit updatePolicy: Recreate, which permits downtime if the replacement cannot start; Pod, configuration, and saved receipt retained
  • M3: Kubernetes rejected Pod nc-…-check-ae1b7bc8f04a: pods "nc-…-check-ae1b7bc8f04a" is forbidden: maximum memory usage per Container is 80Gi, but limit is 96Gi
  • M4: Kubernetes model Pod nc-…-model-… cannot be scheduled: replacement preflight: no Node matches nodeSelector; the current Pod was not replaced; resources retained; correct scheduling constraints or capacity and apply again
  • M5: as M4, with no matching Node has enough allocatable cpu
  • M6: Kubernetes model Pod nc-…-model-… cannot be scheduled: Unschedulable: 0/2 nodes are available: 1 node(s) didn't match Pod's node affinity/selector, 1 node(s) had untolerated taint(s). preemption: 0/2 nodes are available: 2 Preemption is not helpful for scheduling.; resources retained; correct scheduling constraints or capacity and apply again
  • M7: observation permission denied
  • M8: observation transport failed
  • M9: changing a model's nodeSelector, tolerations, runtimeClassName, architecture, or CPU or memory requests requires permission to list nodes (cluster scope) to check the replacement Pod; the current Pod was not replaced
  • M10: observation is incomplete
  • M11: kubernetes.storageClass names a missing StorageClass; create it or select an existing class
  • M12: observed ownership, generation, or durable identity changed
  • M13: kubernetes.runtimeClassName names a missing RuntimeClass; create it or select an existing class
  • M14: changing the model serving port requires whole-deployment destroy and apply; destroy deletes sandbox files and conversation history but retains model and credential PVCs

Deviations and notes

  • Earlier RBAC attempt (08:37), superseded by i-A.
    • The Role there was namespaced only: get, list, watch, create, delete on the five kinds, list endpointslices, and a namespaces get rule. That rule has no effect at Role scope.
    • It granted nothing on Secrets and no patch or update.
    • read, preflight_workload and ensure returned M7 at PR-6's first cluster-scoped read. That attribution rested on code order, because both 403 paths return the same error.
  • Foreign Pod and credential read. PR-6 has no foreign-Pod check behind the Service, and none was expected; feat(sdk): route sandboxes on Kubernetes gateways to in-cluster model servers #13063 adds the EndpointSlice check. RuntimeFile::Credential exists in status.rs, but no PR-6 public API calls it (feat(sdk): route sandboxes on Kubernetes gateways to in-cluster model servers #13063 does). The same predicate was checked with kubectl in g.
  • Observation, not a bug. With an unchanged spec, preflight_workload returns OK while Service drift is present; this was logged in b1. read and ensure refuse it, and in the provider flow the refresh (read) runs before apply.
  • Other notes.
    • PR-6 creates objects without a field manager, so managedFields show manager: unknown.
    • On local-path, /credentials is a 0777 root directory, because hostPath volumes ignore fsGroup. The key file inside is 600, owned by uid 1000.
    • The admission diagnostic names the temporary -check-<hex> Pod. The test only requires the name to start with the model name.
    • M7 and M12 are generic: they do not name the missing permission or the mismatched id.
  • Not run.
    • Terminal Pod handling: ModelRuntimeStopped for Failed or Succeeded, ErrImageNeverPull and InvalidImageName.
    • ensure's recreate of a terminal Pod.
    • Image-pull failures (ErrImagePull, ImagePullBackOff).
    • A cluster-identity mismatch (different server or kube-system UID).
    • A lost create response (UnrecordedResource).
    • PVC topology (X2-PV-TOPOLOGY).
    • Live OpenShift.
    • An OpenShell gateway or sandbox.

Windows CI: test cost (fe57eb0, e318119)

windows_amd64 / Build and test timed out on two of this PR's fake-API tests at nextest's 24 s limit (2–4 s on Linux and macOS; flaky since c6acfac, 23.0 s at fe57eb0). The cost was in the tests, not the reconciler:

  • Durable writes (the main cost). Each table case deployed a full model service, and each deploy saves the service receipt atomically with sync_all about 14–16 times. The slowest test ran 24 cases: 384 receipt writes and 768 fsyncs, which FlushFileBuffers makes slow on Windows. The table tests now deploy once per backend and restore the deployed objects, fixture controls and state directory before each case (Objects::snapshot/restore). Mutating the reconciler (Service spec.type check, Mi parsing, Pod deletionTimestamp) still fails a later case of each converted test. On Linux, fsyncs per slow test: 768 → 32, 598 → 214, 616 → 256; time 2.0 → 0.25 s for the slowest.
  • Fixture connections. The shared HTTP fixture (crates/test-support/http.rs) answered one request per connection; it now keeps HTTP/1.1 connections open (2,000+ → 13–24 connections per slow test), reads requests through one buffer per connection (266k → 4k recvfrom), sets TCP_NODELAY, writes each response once, closes on Connection: close, HTTP/1.0, Transfer-Encoding, 1xx/204/304 and HEAD, and aborts kept connections when dropped. Tests in crates/nemoclaw-e2e/tests/fixture_keepalive.rs (also on Windows) cover keep-alive, pipelined requests, closing on drop and the closing response kinds.
  • Test client. The fixture client no longer loads the platform root store; the fixture serves plain HTTP.
  • None of this changes the reconciler's code. Full cargo ci at e318119: 1572 tests + 138 lifecycle, all passed. Windows CI is the check for the Windows times.

Updated for v1 4025928 and the pods/exec fix

  • 0f9a6ab merges v1 4025928 (no conflicts); 85e2b93 is the fix above, test-first: an_identity_without_get_on_pods_exec_is_refused_before_storage_or_a_pod_is_created and exec_boundary::refused_exec_upgrades_report_authentication_and_permission_without_retrying fail without it.
  • This PR's diff over v1 is its earlier diff plus exactly the fix (28 files).
  • Full cargo ci at 85e2b93: 1568 tests + 138 lifecycle, all passed.

Updated for v1 6526400 (after #13060 landed as #13125–#13128)

#13060 was closed after its code landed in v1 as #13125, #13126, #13127 and #13128 (Carlos Villela). An audit of all 67 of #13060's hunks found 66 byte-identical in v1 and one doc-comment rewording; nothing is missing and no API this stack uses changed. The branches merged v1 6526400 with no conflicts.

Earlier: v1 bceec80 (after #13056–#13059 merged)

#13056–#13059 are merged into v1, and the maintainers have since refactored that code in v1 (#13104, #13105, #13106, #13108, #13109, #13110, #13111, #13112). The stack follows v1 with signed merge commits, no rebase, and this PR's own diff stays as published except where noted.

Depends on / merge order

Split from #12736.

🤖 Generated with Claude Code

gaveezy and others added 11 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>
@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 10 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>
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>
An unauthenticated client could stop a bearer vLLM service until
reapply by opening about 1,000 idle connections to the published port.
The filter accepted without limit under the container's default soft
limit of 1024 open files, so the supervisor's memory sample could not
open /proc/meminfo, and supervision stopped vLLM as a protection
failure.

The filter now serves at most 256 connections at once; later clients
wait in the listen backlog. After vLLM starts, the supervisor raises
its soft open-file limit to the hard limit, and the cap shrinks so that
two descriptors per connection and 128 for the supervisor fit the
limit. A request body that cannot be read, such as invalid chunked
framing, gets 400 {"error":"Bad request"} instead of 502.

Two route tests asserted on ephemeral ports they had released, which
another test in the same process could take; they no longer reuse a
released port. The SDK launch test is renamed for what it checks.
docs/inference.md adds the connection limit, the 400, half-closed
clients, unlogged rejections and h2c offers, and replaces an example
that was not a spelling of an allowed path.

This also corrects the message of 25586e0: 16 mutations were run,
not 15, and each failed a route test; the filter moved to Rust because
review asked for it, while Python remains inside workload images; and
that commit changes behavior, so it is not a refactor.

Validation:
- The three new route tests failed before the fix: the soft limit
  stayed at 1024, a third connection was served past a limit of two,
  and an unreadable chunked body got 502. All 18 route tests pass
  30 stress iterations, and each of 6 mutations of the fixes fails
  one of them.
- With the review's flood of up to 1,100 idle connections under
  `prlimit --nofile=1024:524288`, 25586e0 stopped the vLLM stand-in
  after 7 s. With this commit it was still running after 40 s, also
  under 1024:1024.
- The route tests failed 10 of 100 single-process runs before and
  0 of 100 after.
- `cargo ci` passed in 565 s on Linux ARM64: 1404 tests, 4 doctests,
  and 127 lifecycle tests. The ignored retained-source rebuild passed
  offline in 53 s; dependencies are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR-2 now filters bearer vLLM routes in the runtime supervisor instead of
a Python middleware. The merge is clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The base now includes PR-2's Rust route filter. The merge is clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wscurran wscurran added area: providers Inference provider integrations and provider behavior area: security Security controls, permissions, secrets, or hardening platform: k8s Affects Kubernetes deployments provider: ollama Ollama local model provider behavior provider: vllm vLLM local or hosted provider behavior labels Oct 13, 2026
gaveezy and others added 3 commits October 13, 2026 20:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#13060, the base of this branch, was closed in favor of four smaller
pull requests that carry its work and are now merged into v1: #13125,
#13126, #13127, and #13128. This merge keeps v1's versions of that
code, so the branch becomes v1 plus this pull request's own changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaveezy
gaveezy changed the base branch from split/5-openshell-services-hook to v1 October 14, 2026 04:03
@gaveezy
gaveezy marked this pull request as ready for review October 14, 2026 04:03
@github-actions

Copy link
Copy Markdown
Contributor

gaveezy and others added 5 commits October 14, 2026 08:12
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On kind v1.37.0 (nvkind-demo), a ServiceAccount with `create` but not
`get` on pods/exec passed all seven access reviews. `ensure` created
the model Pod, which took the GPU; `wait_ready` then failed after
31.7 s and `read` failed with "observation transport failed".

kube-rs execs through a WebSocket upgrade, an HTTP GET, which the API
server authorizes as `get pods/exec`. With
AuthorizePodWebsocketUpgradeCreatePermission (beta, enabled on that
cluster) it also requires `create`. kube-client reports the refused
upgrade as `UpgradeConnection(ProtocolSwitch(403))`, which the exec
error mapping treated as a retryable transport failure.

- Review `get pods/exec` with the other permissions, so preflight
  refuses the identity with Permission before it creates storage or a
  Pod.
- Map a 401 or 403 exec upgrade refusal to Authentication or
  Permission, which stop readiness at once. Other upgrade failures stay
  Transport.
- Let the fake API deny one verb on a subresource.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
windows_amd64 / Build and test failed on this branch: nextest stopped
`tampered_model_objects_identify_the_object_and_field_without_values`
and `equivalent_kubernetes_quantities_allow_a_sequential_update_on_one_gpu`
at its 24 s limit, and other `kubernetes_services` tests took 9-18 s
there against 2-4 s on Linux and macOS.

The fake Kubernetes API answered one request per connection, then
closed it. These tests poll on paused time, so each of the slowest
opened 2,041 to 2,513 connections, and the 77 `kubernetes_services`
tests left 26,541 sockets in TIME_WAIT on Linux; Windows allows 16,384
dynamic ports by default. Windows was not available for this change, so
that these connections caused its slow runs is inferred from the
counts, not measured.

The fixture now answers requests on a connection until the client
closes it or sends `Connection: close`, or until the handler returns
`None`, which still closes the connection without a response. Each
connection runs on its own task, so a client holding a connection open
does not block other clients. The handler still sees one request at a
time. Request bodies are still framed by `Content-Length`; a request
with `Transfer-Encoding`, which no current test sends, ends its
connection. Accepted TCP streams set `TCP_NODELAY`, and each response
is one write. An error setting `TCP_NODELAY`, which macOS can return
for a stream its peer already reset, is ignored instead of stopping the
accept loop.

A 1xx, 204 or 304 status, or an answer to `HEAD`, also ends its
connection, with `Connection: close`. A client reads no body after
these, and after a 1xx it waits for a final status. On a kept
connection, a handler's body would be read as the next response, and a
1xx would leave the client waiting. No current handler answers `HEAD`
or with a 1xx or 304; every 204 has an empty body.

Dropping the fixture aborts the accept loop and every connection task
at once. A connection task that no worker is polling at that moment is
never polled again, so a request waiting on a kept connection gets no
answer. A task that another worker is polling can still finish that
poll. When the drop aborted only the accept loop, a multi-threaded
runtime could answer on a kept connection until it cancelled that loop:
a scratch probe with a pooled hyper client on 4 workers got 6 to 18
answers per 500 requests sent right after a drop, and gets 0 in 1,500
now.

Measured on linux_arm64 with the SDK integration binary and `--exact`,
three runs each:

| Test | Accepts before | After | Seconds before | After |
|---|---|---|---|---|
| `tampered_model_objects_...` | 2,172 | 24 | 2.23-2.31 | 1.88-2.01 |
| `equivalent_kubernetes_quantities_...` | 2,041 | 13 | 1.97-2.11 | 1.61-1.82 |
| `default_policy_replaces_pods_that_never_served` | 2,513 | 14 | 2.80-3.11 | 1.83-1.92 |

While `cargo nextest` ran the `kubernetes_services` tests, accepted
connections and the TIME_WAIT peak both fell from 26,541 to 211. Across
the non-ignored tests of the seven crates that include the fixture,
accepted connections fell from 32,031 to 819.

Two `docker_fixture` tests read a response until the server closed the
connection; they now send `Connection: close`. New `fixture_keepalive`
tests run on every platform, unlike the Unix-only `docker_fixture`.
They check that one connection serves several requests while another
client is answered, that the connection closes after each response
kind above, and that a dropped fixture closes a kept connection without
answering a request already waiting on it. On the single-threaded test
runtime, that last test yields so the runtime queues the waiting
request's task before the drop; it failed 200 of 200 runs when the drop
aborted only the accept loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared HTTP fixture read each request head one byte per socket
read, about 120 reads per request. On linux_arm64, that was 250,000 to
307,000 `recvfrom` calls in each of the three slowest
`kubernetes_services` tests. On windows_amd64 / Build and test, two of
those tests took 16.6 s and 23.0 s against nextest's 24 s limit.
Keeping connections open in the previous commit cut their connections
about 100-fold but did not change those Windows times.

Each connection now reads through one `tokio::io::BufReader`, kept for
all of its requests. A read can return the start of the next request,
which a reader made per request would drop. Each response is still one
write, passed through the reader to the stream. When a connection
closes is unchanged.

Measured on linux_arm64 with the SDK integration binary and `--exact`;
syscalls with `strace -c -f`, seconds from 3 runs without strace:

| Test | `recvfrom` before | After | All syscalls before | After | Seconds before | After |
|---|---|---|---|---|---|---|
| `tampered_model_objects_...` | 266,180 | 4,344 | 326,519 | 63,471 | 1.73-1.82 | 1.60-1.86 |
| `equivalent_kubernetes_quantities_...` | 249,860 | 4,082 | 290,257 | 43,426 | 1.36-1.59 | 1.28-1.58 |
| `default_policy_replaces_pods_that_never_served` | 306,586 | 5,026 | 352,161 | 49,362 | 1.71-1.81 | 1.52-1.80 |

Under nextest's `ci` profile, the 77 `kubernetes_services` tests'
summed time fell from 25.2 s in each of 3 runs to 23.3-23.7 s. Windows
was not available, so the effect on the Windows runs is not known.

A new `fixture_keepalive` test sends two requests with bodies in one
write and expects both answers in order. With a reader made per
request, it failed 20 of 20 runs at its 5 s timeout. It passes with the
byte reads it replaces, and passed 50 of 50 runs with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaveezy
gaveezy requested a review from cv October 14, 2026 15:31
gaveezy and others added 2 commits October 14, 2026 17:09
The SDK tests' fixture client had no CA, so kube-client built the
platform certificate verifier for it. On Linux that verifier reads every
native root certificate when it is built: about 250 file opens per
client. `default_policy_replaces_pods_that_never_served` builds 14
clients and opened 3,472 certificate files. The fixture serves plain
HTTP, so these clients never verify a certificate.

The client now has an empty trust store. On linux_arm64 that test's
`openat` calls fell from 4,561 to 1,088, with no certificate file
opened. On Windows and macOS the platform verifier loads nothing when
it is built, so this saves nothing there. The 213 SDK integration tests
whose names contain `kubernetes` pass, including the v1 tests that build
clients through `kube_faults`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On windows_amd64 / Build and test, nextest stopped
`tampered_model_objects_identify_the_object_and_field_without_values`
and `equivalent_kubernetes_quantities_allow_a_sequential_update_on_one_gpu`
at its 24 s limit, and `default_policy_replaces_pods_that_never_served`
took 18 s or was stopped. Each case of these table tests deployed model
storage and a workload on a new fixture, saving the service receipt 13
to 15 times. Each save flushes a temporary file, renames it over the
receipt and, on Unix, flushes the directory. These repeated deployments
made 86% of the 3,533 receipt writes in the 77 `kubernetes_services`
tests. That the flushes cause the Windows times is inferred from a
Linux model with slow, serialized flushes, not measured on Windows.

The table tests now deploy once per backend, and each case starts from
that deployment. `Objects::snapshot` and `Objects::restore` in the
shared fake API keep and put back the stored objects and the request
controls, including recorded requests, dry runs and pending deletions.
The SDK tests' `Deployed` also keeps the deployed state directory and
gives each case a new copy of it, made without a flush, with operations
that share one client and fixture. A case starts from the same objects,
receipt bytes and controls as a new deployment would; objects it creates
still get new UIDs. 28 tests changed; `api_conflicts_...` starts its
cases from a storage-only or a full deployment. Tests that deploy once
per backend or differently per case are unchanged, as is
`tolerations_and_architecture_alone_are_scheduling_changes`, where
sharing would save one Ollama deployment.

Measured on linux_arm64 with the SDK integration binary and `--exact`;
syscalls with `strace -f -c`, seconds from 3 runs without strace.
Before is 267c315; after includes the two previous commits, which do
not change these tests' writes:

| Test | `fsync` before | After | `renameat` before | After | Seconds before | After |
|---|---|---|---|---|---|---|
| `tampered_model_objects_...` | 768 | 32 | 384 | 16 | 1.88-2.31 | 0.22-0.29 |
| `equivalent_kubernetes_quantities_...` | 598 | 214 | 299 | 107 | 1.74-1.89 | 0.76-0.86 |
| `default_policy_replaces_pods_that_never_served` | 616 | 256 | 308 | 128 | 1.58-2.32 | 0.80-1.28 |

All `kubernetes_services` tests together renamed a receipt 3,533 times
before and 1,800 times after, including the new test from the first of
those commits. The remaining writes in `equivalent_...` and
`default_policy_replaces_...` come from the updates they test.

Changing production code to skip the Service `spec.type` check, to
misread mebibytes, or to ignore a Pod's deletion timestamp still fails
the tampering, quantity and default-policy tests, at their 15th, 7th
and 7th cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaveezy
gaveezy marked this pull request as draft October 16, 2026 08:08
gaveezy and others added 2 commits October 18, 2026 09:25
v1 removed crates/nemoclaw-e2e/tests/health.rs and its module line (#13379); this branch adds the fixture_keepalive module beside it. Keep fixture_keepalive and drop health.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`windows_amd64 / Build and test` timed out on
`images::harnesses_missing_from_the_selected_platform_name_the_platforms_that_build_them`
twice on this branch (24.1 s, nextest's limit for the test step). The
test plans five selections, and each plan runs `docker buildx bake
--print` twice, so it makes about ten Docker CLI calls. On v1's own
Windows runs it already takes 8.4-20.6 s; with this branch's added
tests running beside it, the calls get slower and it crosses the limit.

The test is now three tests with the same assertions: the missing-harness
error, each platform planning the harnesses it builds, and selections that
are not harnesses keeping Bake's resolution. Each makes at most four Bake
calls. A shared helper writes the Bake fixture and skips without buildx,
as before. No timeout or budget changes.

Breaking `plan` so it never names the building platforms fails the first
test; treating every harness as unsupported fails the first two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gaveezy added a commit that referenced this pull request Oct 18, 2026
#13131 superseded the stacked cluster work:

- the `nemoclaw` provider is gone (#13224);
- one OpenTofu root replaces the separate state files (#13286);
- off Docker, the platform owns keys and readiness (#13225, #13226);
- NemoClaw adds no address policy (#13232).

This merge takes v1's tree, so the branch now carries only the
in-cluster routing change that follows. #13061 and #13062 are parked.

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

cv commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Closing this, as discussed. Thanks for the work: it surfaced real constraints, and the reasoning below is why the approach doesn't fit where v1 has landed, rather than any flaw in its execution.

What this PR does

It adds an SDK library that runs vLLM and Ollama model servers on a cluster through the Kubernetes API:

  • Objects: creates and updates each model's storage, network boundary and Pod.
  • Placement: checks Nodes before scheduling, and handles autoscaling, preemption, cordoned Nodes and the Preserve and Recreate policies.
  • Readiness: reads it over pods/exec.
  • Keys: keeps a generated key in a PersistentVolumeClaim.

#13062 would connect it to configuration and the providers.

The principle

While working through #13131 we settled on one rule: NemoClaw does what it owns, and leaves to OpenShell, OpenTofu, Fabric and the platform what they own. It's behind several decisions since this PR was opened: #13226, #13225, #13151, #13256 and #13232. On Kubernetes, the platform is the cluster and whatever the user deploys to it with.

Why that rules this PR out

  1. Placement belongs to Kubernetes. Deciding where a Pod runs, and recovering when it can't, is what the scheduler, Deployments, StatefulSets and tools like Helm or KServe already do. This PR reimplements a slice of that reconciliation inside NemoClaw. The defects fixed during its review show the cost: the autoscaler case, never-served Pods, terminal preflight, the Recreate policy on a cordoned Node, and the PersistentVolume topology case that's still open. Each is an edge Kubernetes already handles, and NemoClaw would keep chasing more.

  2. Readiness belongs to the platform. We closed Runtime status over HTTP for readiness off Docker #13226, NemoClaw's own runtime status channel, for this reason. Platforms have probes, rollout waits and Pod status. Reading readiness over pods/exec from the machine running NemoClaw adds a parallel channel, with a different vantage point and broad permissions.

  3. Keys belong to the platform's secret store. Accept a user-supplied API key in the vLLM and Ollama runtime images #13225 was narrowed to: the runtime image accepts a key the platform supplies. feat(runtime): accept a user-supplied API key for authenticated vLLM servers #13294 implemented that: vLLM reads NEMOCLAW_INFERENCE_KEY, and vllm_runtime names it in launch.key_env. A NemoClaw-generated key kept in a PVC is a second secret mechanism alongside the cluster's own.

  4. Permissions. Owning Pods this way needs cluster-scoped Node listing and pods/exec. A deployment tool shouldn't need either just to point sandboxes at a model server.

  5. Maintenance. At about 7,300 lines, this would be the largest single subsystem in the SDK, with live-cluster behavior that's expensive to test.

What replaces it

When to revisit

If the maintainers decide on #12641 that NemoClaw should place model servers on clusters, this branch keeps the design and its review history, and can be reopened.

@cv cv closed this Oct 18, 2026
cv added a commit that referenced this pull request Oct 18, 2026
… servers (#13063)

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 #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 #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 (#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.
- #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):

- One conflict, in `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, next to `v1`'s new onboarding catalog row.
- `schema --check` reports both generated files current after #13390's
`imagePullSecrets`.

`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 (#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 #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](https://claude.com/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 (#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 #12692 and #12709 rows.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
@cv
cv deleted the split/6-cluster-reconciler branch November 21, 2026 20:45
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 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