Repository navigation
refactor(sdk): plan, apply, and destroy each deployment as one OpenTofu root - #13286
Merged
Merged
Conversation
Objects took the gateway data source's ref, which a single root would leave unknown at plan time whenever the read waits for apply, planning objects as changed. They now take the same ref as a literal, known while planning; the gateway reads still gate them through depends_on and a compatibility precondition.
Planning a new OpenShell object connected to its gateway to check that the name wasn't already taken. On a fresh install with one root, the gateway doesn't exist until the same apply installs it, so every first plan would fail. Planning now only validates the gateway ref. reconcile already refuses a name owned by someone else before every mutation, so the ownership check moves to apply.
…fu root The SDK ran a runtime stage and an OpenShell stage as separate roots, with separate state, plans, markers, deferrals, and teardown. Compile one graph instead: the runtime's gateway read replaces the plan-time read, and the apply-time gateway read that every object waits on now waits on every runtime resource and readiness read, so the runtime settles first within one apply and destroy removes objects first. Plan, apply, export, and destroy use one state. Only OpenShell and Fabric creations are tracked for lost replies, and a failed apply forgets new creations OpenTofu never started. The runtime stage, its markers, the gateway deferral, deferred_resources, and the Kubernetes unfinished-platform rule are removed.
cv
enabled auto-merge (squash)
October 15, 2026 20:35
Helm checkpointing and recovery checked every saved binding against the runtime's targets, which now share the state with OpenShell and Fabric objects, so destroying a Kubernetes deployment refused its own objects. Check only the runtime's bindings, and initialize recovery with the deployment's graph so OpenTofu can read the objects in the checkpoint. The live Kubernetes test re-initializes after switching to the teardown graph, which needs more providers than the runtime graph.
Contributor
cv
added a commit
that referenced
this pull request
Oct 15, 2026
Closes #13254. Part of #13131. Stacked on #13286. ## Failure After #13286, the docs still described two OpenTofu stages: separate runtime and OpenShell plans, a `runtime/` state subdirectory, deferral of OpenShell planning until the gateway exists, a gateway-running check, both teardown plans, runtime-only recovery markers, and the removed "Resources awaiting a complete plan" output. ## Decision Describe what the SDK does now: - **`design/architecture.md`:** "Why Managed Apply Has Two Stages" becomes "Why Each Deployment Is One OpenTofu Root". It covers how dependencies apply the runtime before objects and destroy in reverse; why a fresh deployment can plan the gateway and its objects together; and that a stopped gateway is an ordinary failure. The recovery rules now describe the lost-creation tracking: OpenShell and Fabric creations only, and forgetting creations OpenTofu never started. - **`design/apply-flow.md`:** one plan → SDK checks → apply block in the diagram and steps. - **Reference and operations docs:** stage wording and stale paths in `state.md` (no `runtime/` directory; the Helm checkpoint is at the state root), `provider.md`, `reference/cli.md`, `usage.md`, and the contributor testing docs. - **Provider list:** `provider.md` and `apply-flow.md` no longer name the removed `nemoclaw` provider. ## Validation - `cargo run -p nemoclaw-build -- fern check`: 0 errors; the same single warning as before this change. - No remaining references to runtime or OpenShell stages, the `runtime/` state directory, or the removed output. `design/recipes.md`'s image-preparation "runtime stage" is unrelated and unchanged.
This was referenced Oct 15, 2026
cv
added a commit
that referenced
this pull request
Oct 18, 2026
…pplied (#13408) Closes #13005. ## Failure Running `model_live` on a DGX Spark (GB10) for #13005 found a regression from #13286. After `nemoclaw destroy`, re-applying the same configuration with a managed gateway failed at its first plan with `observation transport failed`: - Destroy removed the managed gateway's container but kept `openshell_workspace.deployment` in state. - With one OpenTofu root, the next plan refreshes that workspace before anything can reinstall the gateway. - #13286 had removed the old deferral for a stopped gateway, so nothing covered this case. The lifecycle tests didn't catch it, because the fixture gateway never goes away. `model_live` also had stale assertions: a retained `vllm_credential_storage`, which exists only with authentication, and a recovery check filtering on the removed `nemoclaw_` prefix. ## Decision - **Destroy deletes the workspace.** SDK destroy now keeps only data (gateway storage, model caches, credentials) and deletes the workspace with the deployment's other objects, as explicit HCL teardown does since #13262. The workspace lives in the gateway destroy removes, and by then its sandboxes, registrations and agents are gone. Re-applying reinstalls a managed gateway on its retained storage and recreates the workspace. - **CLI output:** destroy's "Retaining the workspace does not preserve sandbox files" warning is removed, since the workspace is no longer retained. - **`model_live`:** after destroy it expects the gateway storage and the model cache volume, and through recovery it checks that `openshell_*` and `docker_volume.*` identities are preserved. - **Docs:** `state.md`, `usage.md`, `provider.md` and the CLI reference describe the new retention. ## Validation - The teardown unit tests failed before the change and pass after. Lifecycle tests now expect no workspace after destroy, and a recreated one on re-apply. - `cargo ci` passes locally: 1552 unit tests and 153 lifecycle tests. - On a DGX Spark, with `examples/spark/vllm.yaml` adapted to Deep Agents, because OpenClaw is blocked by #13372: - `model_live::selected_model_apply_export_and_watchdog_recovery_preserve_data_and_identity` passes (658 s); - `model_live::selected_model_continues_from_retained_state` then re-applies the same configuration against the retained state and passes (317 s). Before this change it failed at its first plan.
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 <[email protected]>
cv
added a commit
that referenced
this pull request
Oct 18, 2026
## Failure On rootless Podman 5.8.8, applying `examples/managed-podman.yaml` created the gateway and then failed: ``` Gateway capability observation failed observation transport failed ``` The gateway itself was healthy, listening on its endpoint within a second. In the single root (#13286), `data.openshell_gateway.apply` runs during apply right after the gateway starts, with no wait. Docker gateways have a separate readiness check that holds the read back until the gateway listens; Podman gateways have none. So the read raced the gateway's startup, failed on its first attempt, and didn't retry. Run on its own against the running gateway, the same read succeeded. ## Decision For a managed gateway, the apply-time read waits up to 90 seconds, as the plan-time read already does. The wait ends as soon as the gateway answers, so on Docker, where the readiness check runs first, it costs nothing. External gateways are unchanged. The docs now say that managed rootless Podman needs Podman 5 or later, since the `pasta` networking report it requires first appeared there, and that Ubuntu 24.04's Podman 4.9.3 fails the prerequisite. ## Validation - **New test:** `the_apply_time_gateway_read_waits_for_a_managed_gateway` failed before the change (`Null` instead of `90`, for Podman) and passes for Podman and Docker. - **Live, on rootless Podman 5.8.8 with `pasta`:** with the rebuilt bundle, `nemoclaw apply` of the Podman example, with a fresh UID and the Hermes image, completes: gateway, workspace, provider, sandbox and agent. Destroy then deleted the agent, sandbox and gateway, and the documented removal procedure left nothing behind. - `cargo ci` passes locally: 1,571 unit tests and 153 lifecycle tests.
This was referenced Oct 18, 2026
gaveezy
added a commit
that referenced
this pull request
Oct 19, 2026
PR-6 merged v1 up to #13411. Three v1 changes move code this branch builds on: - #13224 removed the `nemoclaw` provider, which served this branch's cluster model types. They become `openshell_kubernetes_service` and `openshell_kubernetes_service_storage`, served by the openshell provider beside the Kubernetes gateway installation types: two more `INSTALLATION_TYPES` entries, and `cluster_services::definitions()` in `all_definitions()`. Their contract tests move to `openshell-provider::contract` with the Kubernetes gateway tests, their schema to the openshell snapshot, and the docs name the new types. - #13286 plans and applies each deployment as one OpenTofu root. The cluster image preflight moves from the removed runtime stage into `Deployment::run`, before compilation. #13286 also removed the "unfinished Kubernetes platform apply" rule, so this branch's exception to it (`revises_only_model_workloads`), its test, and its usage.md paragraph go too. The compile test now checks that the apply-time gateway read, which every object waits on, waits on the cluster service, instead of checking that agents compile into a separate graph. - #13184 added `Definition::derived`: a computed attribute kept out of backend rows. This branch's `derived` is an optional input checked against the spec and kept in the row, so ownership checks still see `owner` and `generation`. It is renamed `derived_input`. Smaller follow-ups: - #13093 added `ServiceDefinition::Container`; the cluster matches cover it. The cluster service is no longer a `runtime_process` kind: that flag now also selects Docker readiness and compute, which decode a Docker spec. Its only other readers handle the cluster kind first. - #13223 dropped the `org.nemoclaw.runtime.spec` label everywhere; the cluster image check no longer requires it. - #13369 removed `model_metadata` from OpenClaw routes, since Fabric v0.5.0's adapter rejects it; the cluster fixtures and docs drop it. The remaining conflicts keep both sides. `openshell-provider::contract`'s summed budget rises from 105 to 130 s, keeping v1's margin: the 8 moved cluster model tests add 23.2 s in a local linux_arm64 run (slowest 3.9 s, within the 6 s limit), about 17 s at CI speed. `nemoclaw-provider::contract` keeps its v1 budget; this branch's earlier raise to 150 s went with the tests. Validation on linux_arm64: the `cargo ci` fmt, clippy, test, schema, bundle and lifecycle steps pass (161 lifecycle tests, among them the 8 cluster model contract tests), as does `nemoclaw-build docs --check`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cv
added a commit
that referenced
this pull request
Nov 11, 2026
- inference.md: state only what was observed about Hermes's context window: Qwen/Qwen3-4B can't meet the 64,000-token minimum, and Hermes replied with qwen3:0.6b at 32,768 tokens in the live case; drop the unverified mechanism. - provider.md: each deployment is one OpenTofu root (#13286), so OpenShell objects wait for every runtime resource and readiness read; #13256 is by design. - Overrides.model doc comment: name each managed service's served model (vllm/config.rs served_model, services/registry.rs); regenerated. - models.md: NemoClaw checks only a parser name's form; vLLM rejects an unknown parser at startup (#14397 reports its error). - limits.md: split the #12651 row and add other harnesses to the managed Ollama row; inference.md and models.md say the several-GPU statements apply once #14384 lifts the one-entry limit.
cv
added a commit
that referenced
this pull request
Nov 11, 2026
Each deployment plans and applies as one root since #13286, so the provider reference no longer calls the managed gateway graphs runtime graphs.
cv
added a commit
that referenced
this pull request
Nov 11, 2026
Corrects the inference, model, recipe, SSH placement, and limits pages, the inference parts of the provider reference, and the generated configuration reference where they disagree with `v1`, for users who configure managed or external inference. ## Problem An audit of these pages against the commits since `v0.1.0-rc9` and the current code found statements that `v1` contradicts. For example, `inference.md` says a model change restarts the runtime inside the existing sandbox, but a changed agent configuration replaces the sandbox and deletes its files and conversations. Several limits link issues that are resolved or decided, and two describe gaps that CI's live cases now cover. ## Change Each change and what makes it necessary: - **Sandbox replacement** (`inference.md`, twice): a model, settings, or image change replaces the agent's sandbox. `compile.rs` sets `replace_triggered_by` on the agent configuration (#13375), and `usage.md`'s change path already says so. - **Default memory limit** (`inference.md`, `ServiceContainer.memoryLimitGiB` doc comment): NemoClaw sets the 104 GiB limit (`DEFAULT_MEMORY_LIMIT_GIB`); Docker has no such default. - **Fields Ollama rejects** (`inference.md`): `kind: ollama` has no `kvCacheGiB`, `batchTokens`, `recipe`, `serving.modelName`, or `authentication`, and its schema objects set `additionalProperties: false`, so a zero value is rejected too; the page said only nonzero values were. - **GPU selection** (`inference.md` managed Ollama prerequisites, `models.md` Nemotron example): a host with several GPUs works when `container.gpuDevices` selects one (#13929). - **Managed Ollama replies** (`inference.md`, `limits.md`): CI's `docker-openclaw-hermes-ollama` live case gets a Hermes reply through managed Ollama with `qwen3:0.6b` on the Linux AMD64 GPU runner, so "GPU inference and agent replies have not been tested" is replaced by what the case covers; tool use and other GPUs stay limits. The Hermes context section now says only what was observed: `Qwen/Qwen3-4B` can't meet Hermes's 64,000-token minimum, and Hermes replied with `qwen3:0.6b` at 32,768 tokens in that case; it no longer states an unverified mechanism. The limits row also covers harnesses other than Hermes. - **Linux AMD64 row removed** (`limits.md`): the hosted live cases reach agent replies on Linux AMD64 on every CI run. - **SSH engines** (`remote-service.md`, `limits.md`): retained-data removal on SSH engines is verified and the Docker procedure covers it (#12640, completed); the SSH capacity collector is a POSIX shell script, not Python (`hardware/ssh.rs`); SSH placement on GPU hardware has no live test (#12641). - **Decided issues** (`inference.md`, `limits.md`): a managed NIM service is not planned, and NIM works as an external endpoint (#12649); network-request approval and policy explanation belong to OpenShell's policy advisor, and `grants` replace presets (#12651), now two rows. The DGX Station rows, whose issues closed for replanning, point to #12641. - **Provider reference** (`provider.md`): `openshell_inference` takes a readiness `ref` as `server` (#13252), so the "until inference registrations take the ref" workaround is gone. Each deployment is one OpenTofu root (#13254, #13286), so the readiness and gateway sections describe one generated graph, in which OpenShell objects wait for every runtime resource and readiness read, instead of separate runtime and OpenShell graphs. Not checking external servers is by design (#13256). - **Plan-time configuration checks** (`agents.md`): #13319 is closed; #14148 tracks checking at plan time. - **Diagnostic limit** (`models.md`, `limits.md`): once a command's OpenTofu diagnostics exceed 16 KiB, the SDK replaces them with `child output exceeds the supported limit` (`process.rs`, #14399), which can hide vLLM's exit excerpt. - **Parser names** (`models.md`): NemoClaw checks only a parser name's form (`PARSER` in `vllm/constraints.rs`); vLLM rejects an unknown parser at startup, and the stop detail carries its error (#14397). - **Several GPUs** (`inference.md`, `models.md`): the statements about several selected GPUs apply once #14384 lifts `container.gpuDevices`'s one-entry limit, and the pages say so. - **Speculative tokens** (`recipes.md`): `serving.speculativeTokens` works only with a recipe and passes `--speculative-config` with the `mtp` method (`arguments.rs`, `vllm/schema.rs`); no guide described it. - **Configuration reference**: the container descriptions mention GPU selection, and the guide links for `ServiceContainer`, `ServiceUpdatePolicy`, the Ollama types, `ExternalOllama`, and `ServiceAuthentication` point to their sections instead of the general usage page. `Overrides.model` names each managed service's served model (`served_model` in `vllm/config.rs`, `services/registry.rs`); it named only vLLM's. The generator's dead `OllamaProxy` arm is removed. Regenerated with `nemoclaw-build schema`. Checked and left unchanged: the recent multi-GPU changes (#14388 to #14401), the vLLM bearer route filter, timeout budgets, profile catalog, memory reserves, hardware profiles, onboarding catalogs, Ollama and vLLM pins, image tags, interface pages, and the OAuth-refresh guide match `v1`. Left for follow-up, because no open issue tracks them: - Limits and `inference.md` sentences link issues closed for replanning with no successor: #12035 (llama.cpp, Model Router, Gemini), #12038 (hosted-provider guides), #12144, #12037, #12137, and #12042. - `agents.md` links #13313 for Hermes not sending API placeholders to MCP servers; #13313 tracked the `api` credential type. - The OpenClaw walkthrough row links #13372, which is fixed; whether the walkthrough was rehearsed afterward is unrecorded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #13254. Builds on #13264, #13265, #13282 and #13283, all merged.
Failure
The SDK ran each deployment as two OpenTofu roots: a runtime stage (managed gateway, model servers, storage) and an OpenShell stage (workspace, inference, sandboxes, Fabric agents). Each had its own state, plan, apply, destroy, export and recovery markers. Every operation ran OpenTofu twice, with stage-specific deferrals, markers and rules in between. Hand-written HCL never needed any of that.
Decision
Compile, plan, apply, export and destroy one root, with one state in the deployment's state directory.
Compilation:
compile::deployment_graphmerges the runtime graph into the object graph.Plan and apply: one saved plan, checked against runtime bindings (bound process specifications, retained storage) and object targets together.
Teardown: one teardown graph and one destroy, with Helm checkpointing around it as before. The retained workspace binding is required only once OpenShell objects are bound.
Export: one refresh-only observation over the single state.
Removed:
OperationResult::deferred_resources, and the CLI section that printed it;Per the decisions on Compile one OpenTofu root instead of separate runtime and OpenShell graphs #13254: no compatibility work, and a gateway that's down is an ordinary failure.
Validation
cargo cipasses locally: 1527 unit tests, 145 lifecycle tests.cargo ci live-dockerpasses: 9 tests, including the managed gateway's plan, apply, no-op, destroy and recovery with real Docker and OpenTofu.cargo ci live-kindpasses: all 5 Kubernetes tests, after a follow-up fix. Helm checkpointing and recovery now check only the runtime's bindings and read the shared state with the deployment's graph; the live test re-initializes after switching to the teardown graph.a_failed_apply_forgets_only_new_creations_it_never_started.The architecture, apply-flow and state docs still describe two stages; the docs PR for #13254 updates them.