Skip to content

fix(openshell-provider): plan new objects without reaching the gateway - #13283

Merged
cv merged 2 commits into
v1from
feat/plan-without-gateway
Oct 15, 2026
Merged

cv merged 2 commits into
v1from
feat/plan-without-gateway

Conversation

@cv

@cv cv commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Part of #13254. Stacked on #13282.

Failure

When OpenTofu planned a new OpenShell object, the provider connected to the object's gateway to check that its name wasn't already taken. On its own that was only an early warning. But it stops runtime and OpenShell resources from sharing one root: on a fresh install, the gateway doesn't exist until the same apply installs it, so every first plan would fail. For managed Kubernetes gateways, the connection even opened a port-forward to a pod that doesn't exist yet.

Decision

Planning an OpenShell object reaches no gateway. It still validates the gateway ref locally; otherwise it does nothing.

Ownership checks don't weaken: before every create or update, reconcile already observes the live object and refuses a name owned by someone else. A conflicting name now surfaces at apply instead of plan, which is how OpenTofu providers usually behave.

Fabric agents keep their plan-time check against their sandbox. It only runs once the sandbox ref is known, by which point the gateway exists.

Validation

  • New contract test new_objects_plan_without_reaching_the_gateway: plans standalone HCL whose gateway endpoint has nothing listening. It failed before the change with Resource planning failed.
  • All 59 OpenShell contract tests pass, including the ownership and foreign-object cases, now enforced at apply.
  • cargo ci passes locally: 1539 unit tests, 145 lifecycle tests.
  • docs/provider.md says where ownership is checked.

cv added 2 commits October 15, 2026 12:20
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.
Base automatically changed from feat/literal-gateway-ref to v1 October 15, 2026 19:36
@cv
cv merged commit 530313a into v1 Oct 15, 2026
@cv
cv deleted the feat/plan-without-gateway branch October 15, 2026 20:30
cv added a commit that referenced this pull request Oct 15, 2026
…fu root (#13286)

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_graph` merges the runtime graph
into the object graph.
- **Gateway reads:** the runtime's gateway read, which waits for the
gateway it installs, replaces the plan-time read. On a fresh install or
a pending gateway change it moves to apply; otherwise it runs at plan.
- **Ordering:** every object already waits on the apply-time gateway
read, which now waits on every runtime resource and readiness read. So
the runtime settles before any object changes, within one apply. A spike
with the bundled OpenTofu confirmed that destroy follows the same chain,
removing objects before the runtime.
- **Plan and apply:** one saved plan, checked against runtime bindings
(bound process specifications, retained storage) and object targets
together.
- **Docker models:** the protection against disrupting a running model
applies to that plan.
- **Lost creations:** only OpenShell and Fabric creations are recorded,
since OpenTofu saves every other ID. After a failed apply, the record
forgets creations this apply added but OpenTofu never started; a failure
stops OpenTofu before everything that depends on what failed. A creation
whose apply started, or whose address OpenTofu didn't report, stays
pending, and so does any earlier unresolved one.
- **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:**
  - the runtime stage and its state subdirectory;
  - the runtime pending and destroy markers;
  - the gateway-not-running deferral and its message;
- `OperationResult::deferred_resources`, and the CLI section that
printed it;
  - the Kubernetes "unfinished platform apply" rule.

Per the decisions on #13254: no compatibility work, and a gateway that's
down is an ordinary failure.

## Validation

- `cargo ci` passes locally: 1527 unit tests, 145 lifecycle tests.
- `cargo ci live-docker` passes: 9 tests, including the managed
gateway's plan, apply, no-op, destroy and recovery with real Docker and
OpenTofu.
- **New unit test:**
`a_failed_apply_forgets_only_new_creations_it_never_started`.
- **Updated tests:**
- **Two-stage expectations:** the Helm recovery, remote-service and
Kubernetes interruption tests used the second state directory,
stage-specific command scripts and runtime-only markers. They now use
one state; tests of removed rules are deleted.
- **Live tests:** Brev, Spark, hosted parity and the dummy agent now
expect one plan that creates runtime and objects together. These need
their own hardware and weren't run here.

The architecture, apply-flow and state docs still describe two stages;
the docs PR for #13254 updates them.
@wscurran wscurran added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression v1 NemoClaw v1 branch labels Oct 26, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery area: security Security controls, permissions, secrets, or hardening bug-fix PR fixes a bug or regression v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants