Skip to content

fix(openshell-provider): let explicit teardown delete workspaces - #13262

Merged
cv merged 1 commit into
v1from
feat/hcl-destroy
Oct 15, 2026
Merged

cv merged 1 commit into
v1from
feat/hcl-destroy

Conversation

@cv

@cv cv commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #13230. Part of #13131.

Failure

A hand-written configuration that creates an openshell_workspace couldn't be torn down. tofu destroy -var destroy=true refused the workspace ("workspaces must be retained"), even though OpenTofu already has a configurable way to keep a resource, lifecycle { prevent_destroy = true }, which generated graphs set on their workspaces. The provider's own refusal duplicated that, and left hand-written configurations without a supported teardown.

Decision

  • Workspaces deletable during teardown. A workspace gets a sandbox's protection: deletion needs the provider's destroy = true, and replacement is still refused. Keeping a workspace is expressed with prevent_destroy. Generated graphs keep setting it, and the SDK's teardown keeps declaring the workspace, so SDK deployments still retain theirs.
  • Delete path. The OpenShell backend can now delete a workspace through DeleteWorkspace, with the same identity check before sending. remove accepts a retained workspace when destroying.
  • Clearer refusal. The message now names the provider's destroy = true; an always-retained resource says it can't be deleted.
  • Test fixtures. The fake gateway implements DeleteWorkspace, refusing a workspace that still holds objects as OpenShell does. The SSH Docker simulator deletes volumes.
  • Example and docs. The travel example documents teardown with tofu destroy -var destroy=true, and docs/provider.md describes the workspace lifecycle and prevent_destroy.

Validation

  • travel_example now ends with teardown. tofu destroy without destroy = true fails and leaves the sandbox in place; with it, the workspace and every other object are removed. The new steps failed before the change.
  • The adapter tests cover workspace deletion and confirmed absence during teardown.
  • Plain cargo ci passes locally: 1538 unit tests and 144 lifecycle tests.
  • cargo ci live-docker passes locally, including the SDK teardown tests, which still retain their workspaces.

Workspaces were always retained, so a hand-written configuration could
not be torn down even with destroy = true. OpenTofu's prevent_destroy
already retains a workspace, and generated graphs set it. A workspace now
has a sandbox's protection: explicit teardown may delete it, and
replacement is still refused. The backend deletes workspaces through
DeleteWorkspace, the test fixtures support workspace and volume deletion,
and the travel example documents and tests its teardown.
@cv
cv enabled auto-merge (squash) October 15, 2026 11:57
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit ed72ab9 into v1 Oct 15, 2026
@cv
cv deleted the feat/hcl-destroy branch October 15, 2026 12:08
@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 labels 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.
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: 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