Skip to content

feat(openshell-provider): name OpenShell objects by typed ref - #13152

Merged
cv merged 4 commits into
v1from
feat/openshell-refs
Oct 14, 2026
Merged

cv merged 4 commits into
v1from
feat/openshell-refs

Conversation

@cv

@cv cv commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Closes #13141. Part of #13131. Stacked on #13138.

Failure

OpenShell provider profiles, registrations, and sandboxes named their workspace, scoped profile, and provider registrations with separate strings. OpenTofu could not check that each name meant an object of the right type, and graphs had to pass names in a fixed order through depends_on.

Decision

  • Each OpenShell resource exports a computed ref: type, name, owner, generation, id, plus workspace for objects inside a workspace.
  • Profiles, registrations, and sandboxes take workspace = openshell_workspace.<label>.ref. Registrations take an optional profile ref in place of profile_name. Sandboxes take providers, a list of registration refs, in place of provider_names.
  • nemoclaw-tofu gains list references (references_list) and a schema version. The four OpenShell schemas move to version 1, so OpenTofu rejects state from the earlier schema instead of upgrading it. The SDK record version moves from 7 to 8 with a message pointing to the original release for recovery or teardown.
  • The SDK compiler emits ref expressions. nemoclaw_openshell::flatten rewrites refs in state, plans, and planned values back into the row fields the SDK compares, so plan gates, export, and binding checks are unchanged. Sandbox readiness reads the workspace from the sandbox's ref.

Validation

  • New nemoclaw-tofu unit tests for list references: schema shape and version, backend rows, unknown elements deferring planning, rejecting an element of another type, and refresh.
  • Regenerated the OpenShell contract fixtures (NEMOCLAW_REGENERATE_FIXTURES=1) and schema snapshot; updated the hand-written OpenShell and Fabric contract HCL; the SDK compile test now checks workspace and provider refs.
  • cargo ci passed locally on linux_arm64, including all 138 contract and system tests.

cv added 2 commits October 13, 2026 23:04
…refs

Provider types identify each other through separately passed strings,
such as a sandbox's workspace name, so OpenTofu cannot check that the
pieces belong to one object or say which resource type they came from.
The provider redesign in #13131 replaces these with a computed `ref`
object on the producing type and an object input on the consumer.

Definitions gain `exports` and `references`. The structured adapter
derives `ref` from the row, so backends never see it, and parts the row
does not know yet stay unknown. A reference input is one object
attribute whose declared attributes travel to the backend as row fields;
its `type` must match the exporting type, because OpenTofu drops object
attributes a consumer does not declare and would otherwise accept a ref
of another type with matching fields. A changed ref replaces its consumer
when the carried fields are immutable, and plans report the reference
attribute as the replacement path.

The fixture provider gains a ref-exporting workspace and a ref-taking
sandbox. Unit tests cover the schema, planning with known and unknown
refs, type checks, and refresh. A contract test through OpenTofu 1.12.6
covers create, an unchanged plan, replacement propagating to the
consumer, and rejecting a ref of another type.
OpenShell profiles, registrations, and sandboxes named their workspace,
scoped profile, and provider registrations with separate strings, so
OpenTofu could not check that each name meant an object of the right type.

Each OpenShell resource now exports a computed `ref`. Profiles,
registrations, and sandboxes take `workspace` as a workspace ref,
registrations take an optional `profile` ref in place of `profile_name`,
and sandboxes take `providers`, a list of registration refs, in place of
`provider_names`. The framework gains list references and a schema
version; these schemas move to version 1, so OpenTofu rejects state from
the earlier schema rather than upgrading it, and the SDK record version
moves to 8 with a message pointing to the original release for recovery
or teardown.

The SDK compiler emits ref expressions, and `nemoclaw_openshell::flatten`
turns refs in state, plans, and planned values back into the row fields
the SDK compares. Sandbox readiness reads the workspace from the sandbox
ref.

Regenerated the OpenShell contract fixtures and schema snapshot, and
updated the hand-written contract HCL and provider docs.

Closes #13141. Part of #13131.
Base automatically changed from feat/tofu-object-refs to v1 October 14, 2026 07:03
cv added a commit that referenced this pull request Oct 14, 2026
## Failure

Stacked v1 PRs such as #13152 target another feature branch. The bundle,
image, dependency, and documentation workflows filtered pull requests to
the `v1` base branch, so these PRs received none of those checks.

## Decision

Remove the pull-request base-branch filters from all four workflows.
Stacked PRs receive the existing four-platform bundle checks, image and
dependency checks, and documentation validation. Image and live-suite
change analysis still selects the applicable work. Keep documentation
previews restricted to PRs targeting `v1`; push, release, and Brev
triggers are unchanged.

Document that existing stacks must incorporate the updated workflows
before the checks can run.

## Validation

- `cargo ci` passed on linux_arm64: 1,463 selected tests and all 136
contract/system lifecycle tests passed, along with formatting, Clippy,
schema validation, and the bundle build.
- `actionlint -shellcheck='' -pyflakes='' .github/workflows/*.yml`
passed.
- `cargo run --locked -p nemoclaw-build -- fern check` passed; Fern
reported one warning in each validation pass.
- `git diff --check` passed.
Retain the list-reference and schema-version extensions from this PR. The parent typed-reference implementation is identical before and after its squash merge; merge current v1 workflow and contributor guidance updates.
@cv
cv enabled auto-merge (squash) October 14, 2026 07:36
The dummy live test discarded the workspace object when reading raw OpenTofu state, so its direct gateway query failed. Flatten typed refs before collecting the client row. The focused regression failed without workspace and passes after the change.
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 146a120 into v1 Oct 14, 2026
@cv
cv deleted the feat/openshell-refs branch October 14, 2026 08:05
cv added a commit that referenced this pull request Oct 14, 2026
Closes #13142. Part of #13131. Stacked on #13152.

## Failure

The `openshell` and `fabric` providers took one gateway connection in
provider configuration. A fresh deployment had to defer configuring the
provider until the gateway existed, every object in a graph had to share
that connection, and refresh of a bound object depended on the provider
configuration still describing its gateway.

## Decision

- `data.openshell_gateway` takes `endpoint`, `credential_env`,
`tls_ca_env`, `tls_certificate_env`, and `tls_key_env`, and exports them
as a `ref` (`type = "openshell_gateway"`). The ref carries variable
names, never their values.
- Every OpenShell object, `fabric_agent_configuration`, and
`fabric_sandbox_readiness` takes `gateway` as that ref. Provider
configuration keeps only `destroy`. Gateway clients are cached per
connection.
- `nemoclaw-tofu` gains *carried* fields: inputs a backend uses but
never observes. Refresh and apply keep them from the recorded or desired
row, so objects keep their gateway connection in state and reach the
same gateway for refresh and removal without provider configuration.
Backends receive rows without the connection.
- Credential and TLS references update in place. A different endpoint is
a different gateway: reconstructible objects are replaced, and retained
or stateful objects refuse it, as an unavailable bootstrap gateway did
before.
- The Fabric configuration schema moves to version 1, rejecting earlier
state.
- The SDK puts the connection on the gateway data source, emits `gateway
= data.openshell_gateway.current.ref`, carries the connection in its
target rows so binding and export comparisons hold, and gives teardown
graphs (which read no data sources) the same ref as a literal object.

## Validation

- New `nemoclaw-tofu` unit test: carried fields survive refresh and
apply without being observed. New client tests: one client per
connection, and rows without a usable gateway ref have no client.
- SDK compile tests check that providers take no connection, that both
gateway reads take it, and that every object and readiness read takes
the ref without leaking carried fields.
- Regenerated the OpenShell contract fixtures and both schema snapshots;
updated the hand-written contract HCL, which uses a literal gateway
object, and the gateway-readiness and sandbox-readiness tests.
- `cargo ci` passed locally on linux_arm64, including all 138 contract
and system tests.
gaveezy added a commit that referenced this pull request Oct 14, 2026
PR-7 now carries v1 up to #13153 and PR-6's `get pods/exec` access
check. Three conflicts:

- `crates/nemoclaw-sdk/src/compile.rs`: v1 (#13152) dropped the
  `workspace` name interpolation because profiles, registrations, and
  sandboxes now take the workspace `ref`. The resolution keeps v1's
  structure and reapplies PR-8's change, which escapes
  `cluster_source` like `credential_source`.
- `crates/nemoclaw-sdk/tests/kubernetes_service_exec.rs`: PR-6 and
  PR-8 each appended a test; both are kept, PR-8's last.
- `docs/provider.md`: v1 (#13153) rewrote the `openshell` provider
  paragraph for gateway refs. The resolution keeps v1's text and
  replaces its managed-credential sentence with PR-8's three sentences
  on bundled checks and cluster vLLM keys.

v1's typed refs also break three PR-8 tests that configure the
providers with a gateway `endpoint` or write version 0 OpenShell and
Fabric state. `nemoclaw-e2e`'s integration tests do not compile at this
commit; the next commit adapts the three tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gaveezy added a commit that referenced this pull request Oct 14, 2026
## Why

Merging PR-7 brought in v1's #13152 and #13153. OpenShell objects and
Fabric configurations now take `gateway` and `workspace` as typed refs,
the `openshell` and `fabric` providers take only `destroy`, and those
resource schemas are version 1. Three PR-8 tests still used the earlier
shapes:

- `crates/nemoclaw-e2e/tests/cluster_credentials.rs` did not compile:
  `GatewayConfig` has no `endpoint` field (E0560).
- Its two `bundled_` tests configured the providers with `endpoint` and
  wrote version 0 state that carried the gateway and workspace as row
  fields.
- `plan_and_apply_refuse_cluster_port_changes_with_separate_state_files`
  wrote version 0 `openshell_sandbox` state. `tofu show` rejected it:
  "schema version 0 for openshell_sandbox.assistant in state does not
  match version 1 from the provider".

## Change

- `cluster_credentials`: the backend now picks a gateway client from
  each row's gateway fields, so `at_fixture` points compiled rows at the
  fixture instead of configuring the client with its endpoint. The
  `bundled_` tests write empty provider blocks, literal `gateway`,
  `workspace`, and `profile` refs in configuration and state, the
  registration's exported `ref`, and schema version 1.
- The SDK test's native state for OpenShell objects records the refs in
  place of the row fields they carry, plus the exported `ref`, at schema
  version 1.

Production code is unchanged.

## Validation

- `cargo test -p nemoclaw-e2e --test integration cluster_credentials`
  passes. With `NEMOCLAW_TEST_BUNDLE` from `cargo ci bundle`, both
  `bundled_` tests and the SDK test pass; the SDK test failed with the
  error above before this commit.
- A bundle whose `openshell` and `fabric` provider binaries use the
  default Docker-only services fails both `bundled_` tests, so they
  still check NemoClaw's cluster callbacks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wscurran wscurran added area: architecture Architecture, design debt, major refactors, or maintainability area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch labels Oct 22, 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: architecture Architecture, design debt, major refactors, or maintainability area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery refactor PR restructures code without intended behavior change v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants