Skip to content

feat(openshell-provider): reach gateways through typed refs - #13153

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

cv merged 4 commits into
v1from
feat/gateway-refs

Conversation

@cv

@cv cv commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

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.

cv added 3 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.
The openshell and fabric providers took one gateway connection in
provider configuration, so a fresh deployment had to defer configuring
the provider until the gateway existed, and every object in a graph had
to share that one connection.

`data.openshell_gateway` now takes the endpoint and the names of the
credential and mutual-TLS variables, and exports them as a `ref`. Every
OpenShell object, `fabric_agent_configuration`, and
`fabric_sandbox_readiness` takes `gateway` as that ref; provider
configuration keeps only `destroy`. Clients are cached per connection.

The framework gains carried fields: inputs a backend uses without
observing, which refresh and apply keep from the recorded or desired row.
Objects carry their gateway connection that way, so refresh and removal
reach the same gateway without provider configuration, and backends see
rows without it. Credential and TLS references rotate in place; another
endpoint is another gateway, so retained and stateful objects refuse it.
The Fabric configuration schema moves to version 1.

The SDK emits the gateway connection on the data source and
`gateway = data.openshell_gateway.current.ref` on objects, carries the
connection in target rows so state comparisons hold, and gives teardown
graphs, which read no data sources, the same ref as a literal object.

Closes #13142. Part of #13131.
Base automatically changed from feat/openshell-refs to v1 October 14, 2026 08:05
Keep the gateway references and carried-field implementation from this PR across the parent squash merge. Incorporate current v1 CI guidance and the live-test sandbox binding repair.
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv enabled auto-merge (squash) October 14, 2026 08:27
@cv
cv merged commit 4025928 into v1 Oct 14, 2026
@cv
cv deleted the feat/gateway-refs branch October 14, 2026 08:28
cv added a commit that referenced this pull request Oct 14, 2026
)

Part of #13143 (the `fabric_harness` data sources follow in the next
PR). Part of #13131. Stacked on #13153.

## Failure

The OpenShell provider parsed Fabric's runtime binding to start each
sandbox. It required `agent_runtime` to be `fabric`, built the start
command and environment from the binding, and merged the image runtime's
policy and executables into the sandbox policy (`network.rs`). OpenShell
depended on Fabric's types, and could not launch anything else.

## Decision

As decided on #13143 (option 1), the launch carries the runtime's policy
contribution and OpenShell merges it:

- `openshell_sandbox` takes `launch_json`: `command`, `environment`,
`policy` (used when no explicit policy is authored), `binaries`
(executables managed grants allow), and opaque `metadata`. `agent_name`,
`agent_runtime`, and `runtime_json` are removed, along with the checks
that the runtime is Fabric.
- OpenShell merges the launch policy with the authored policy and
managed grants (`Launch::policy`/`granted_policy`, moved from the
runtime binding), records the launch in an annotation, and compares it
on refresh.
- `fabric_capabilities` returns `launch_json` for its configured agent.
Fabric records the agent name and runtime binding in the launch metadata
and reads them back (`fabric_binding`) for configuration, readiness, and
the bridge.
- The bridge refuses a binding whose agent or runtime binding differs
from the launch the sandbox records; the gateway already checks that
launch against the live sandbox. This keeps the protection the old
`runtime_json` comparison gave.
- `launch_json` is a JSON string rather than a typed object: the
framework maps nested objects to blocks, which can't be assigned from a
data source. A typed object input can follow once the framework supports
object attributes.
- OpenShell schemas move to version 2 and the SDK record to version 9,
rejecting earlier state. The SDK still compares the agent name in its
compiled rows, so renaming an agent of a bound sandbox stays refused.

## Validation

- The existing runtime-binding policy tests now run through `Launch`,
since the binding's policy delegates to it.
- Updated the fake-gateway, health, and SDK compile tests; regenerated
the OpenShell contract fixtures and schema snapshots; converted the
hand-written contract variables to `launch_json`.
- `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: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality 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: security Security controls, permissions, secrets, or hardening feature PR adds or expands user-visible functionality v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants