Skip to content

feat(fabric-provider): configure agents through typed fabric_agent resources - #13167

Merged
cv merged 28 commits into
v1from
feat/fabric-agent
Oct 14, 2026
Merged

cv merged 28 commits into
v1from
feat/fabric-agent

Conversation

@cv

@cv cv commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #13144. Part of #13131.

#13160 has merged; this targets v1.

Failure

fabric_agent_configuration took the whole Fabric agent document as one opaque config_json string. OpenTofu could not type-check it, plans showed one JSON blob, and the sandbox it configured was a set of loose identity strings. Nothing checked the document against the harness until the bridge applied it.

Decision

fabric_agent replaces it:

  • References: it takes sandbox = openshell_sandbox.<name>.ref, harness = data.fabric_harness.<name>.ref, and gateway.
  • Inputs: name and description are Fabric's metadata, and settings is harness.settings. Every section of Fabric's agent configuration (instructions, models, runtime, tools, skills, mcp, workflow, environment, discovery, relay, telemetry) is a typed input derived from Fabric's published schema (SchemaName::Agent). A unit test fails if Fabric adds a section that isn't an input.
  • Planning: plans reject a document Fabric cannot parse, naming the field but not its value. They also reject one the harness catalog does not accept, such as mode = "append" with Pi, using the adapter's catalog records now carried in the fabric_harness ref. Once the sandbox is known, plans refuse an agent name or harness the sandbox does not launch.
  • Changes: changing the sandbox, harness, or name replaces the agent; any other change reconfigures it without replacing the sandbox. Removal still releases the binding without stopping the agent; stopping it needs a bridge operation (follow-up).
  • Old state: state recorded before typed Fabric agents (record version 10, which still binds fabric_agent_configuration) is rejected with the recovery message; the record version is now 11.

To map Fabric's schema, nemoclaw-tofu now:

  • maps nullable types to their optional type, and unions of one scalar type, such as string enums, to that type;
  • writes objects and values the schema leaves open as JSON text (jsonencode), because tf-provider cannot decode OpenTofu's dynamic values;
  • keeps undeclared properties of objects that allow them, such as a model's api, in an extensions JSON-text attribute, so a document crosses OpenTofu without loss;
  • accepts maps and lists of objects as top-level typed inputs (labeled blocks such as models "default" {}), and adds a validate_inputs hook that checks related inputs while others are still unknown.

The SDK compiles each sandbox's document into these inputs, with a data.fabric_harness read named after the sandbox, so adding a sandbox changes no existing agent. Readiness, state recovery, plan reporting, and export use the same shared compose and split functions (nemoclaw_fabric::agent). Diagnostics still name the sandbox, not the agent.

Not in this change:

Validation

  • After merging v1 (with refactor(openshell-provider): serve the gateway installation types #13187 and feat(fabric-provider): select harnesses with fabric_harness #13160), cargo ci --full passes locally (138 contract and system tests).
  • cargo ci passes locally (1495 unit, 138 contract and system tests).
  • New unit tests cover the schema mapping rules, lossless round trips of a full document (including api extensions), the reference and flatten rules, and plan-time harness rejection.
  • The Fabric contract test runs fabric_agent through pinned OpenTofu against the fake gateway: plan-time rejection without echoing values, a harness-unsupported field rejected at plan, apply, unchanged re-plan, update without sandbox replacement, drift repair, a lost reply, and teardown.

cv added 20 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.
The OpenShell provider parsed Fabric's runtime binding to start each
sandbox: it required `agent_runtime` to be `fabric`, built the command and
environment from the binding, and merged the image runtime's policy and
executables into the sandbox policy. OpenShell depended on Fabric.

Sandboxes now take `launch_json`: a command, environment, the policy used
when none is authored, the executables managed grants allow, and opaque
metadata. OpenShell merges that policy with the authored policy and
managed grants, records the launch in an annotation, and compares it on
refresh. `agent_name`, `agent_runtime`, and `runtime_json` are gone, and so
are the checks that the runtime is Fabric.

`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 for configuration, readiness, and the bridge. The
bridge refuses a binding that differs from the launch the sandbox
records, which the gateway checks against the live sandbox.

OpenShell schemas move to version 2 and the SDK record to version 9.

Part of #13143. Part of #13131.
Fabric images were read only through `fabric_capabilities`, which takes a
whole agent configuration and returns a catalog assessment. Nothing named
one harness, so a sandbox could not take what it launches from a typed
source.

`fabric_capabilities` becomes `fabric_harnesses`, the catalog listing. The
new `fabric_harness` data source selects one harness by `image` and
`adapter_id`, returns the `launch_json` that starts it for `agent_name`,
and exports a `ref` (`type`, `adapter_id`, `image`). It fails when the
image installs no runtime for the adapter. The SDK keeps reading
`fabric_harnesses`, now under its new name.

Closes #13143. Part of #13131.
# Conflicts:
#	crates/fabric-provider/src/sandbox_readiness.rs
#	crates/fabric-provider/tests/contract/fixtures/main.tf
#	crates/nemoclaw-sdk/src/state/mod.rs
#	crates/openshell-provider/src/lib.rs
#	crates/openshell-provider/tests/contract/fixtures/explicit-policy.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-claude.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-codex.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-hermes.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-mini-swe-agent.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-nooa-bench.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-nooa.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-openclaw.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-pi.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric-remote-agent.tf.json
#	crates/openshell-provider/tests/contract/fixtures/fabric.tf.json
#	crates/openshell-provider/tests/contract/fixtures/hermes-auth.tf.json
#	crates/openshell-provider/tests/contract/fixtures/hermes-interfaces.tf.json
#	crates/openshell-provider/tests/contract/fixtures/inference-tuning.tf.json
#	crates/openshell-provider/tests/contract/fixtures/inline-inference.tf.json
#	crates/openshell-provider/tests/contract/fixtures/local.tf.json
#	crates/openshell-provider/tests/contract/fixtures/multiple-models.tf.json
#	crates/openshell-provider/tests/contract/fixtures/multiple-providers.tf.json
#	crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json
#	crates/openshell-provider/tests/contract/fixtures/openclaw-dashboard.tf.json
#	crates/openshell-provider/tests/contract/fixtures/openclaw-web-search.tf.json
#	crates/openshell-provider/tests/contract/fixtures/tavily-web-search.tf.json
#	crates/openshell-provider/tests/contract/standalone/main.tf
#	crates/openshell-provider/tests/schema.txt
#	docs/provider.md
Fabric's agent configuration schema writes optional fields as nullable
type arrays, enums as alternatives of one scalar type, and adapter-owned
settings as objects without declared properties. None of these mapped
to OpenTofu types, so its sections could not become typed inputs.

Nullable types map to their optional type, alternatives of one scalar
type map to that type, and open objects become JSON text attributes,
as jsonencode writes them. Structured inputs now convert every shape,
not only objects, so a JSON text input's row field holds its object.
…puts

fabric_agent_configuration took the whole Fabric document as opaque
config_json, so OpenTofu could not type-check it, plans showed one JSON
string, and the sandbox and harness it targeted were loose strings.

fabric_agent takes the sandbox and harness by ref, its own name and
description, harness settings, and every section of Fabric's agent
configuration as typed blocks derived from Fabric's schema. It composes
the document the bridge applies and splits observed configuration back
into its inputs. Plans reject a document Fabric cannot parse, one the
harness catalog in the fabric_harness ref does not accept, and a name or
harness the sandbox does not launch.
Convert the sandbox state row through fabric_binding before calling the Fabric bridge, matching the generic launch contract.
…rces

The SDK compiled each sandbox's Fabric document into one config_json
string, and read it back from state for readiness, export, and recovery.

Each sandbox now compiles a fabric_agent whose inputs are that document's
sections, with the sandbox and the harness it launches passed by ref
from a data.fabric_harness read named after the sandbox. Readiness
compares the document those inputs compose, and state, plans, and export
read the agent's typed values back through the same shared rows.

Typed inputs must carry a document without loss: objects whose schema
also allows undeclared properties, such as Fabric's flattened model
extensions like api, keep them as JSON text in an extensions attribute.
Diagnostics name the sandbox an agent belongs to, not the agent.
…rces

# Conflicts:
#	crates/fabric-provider/src/lib.rs
#	crates/nemoclaw-e2e/tests/openshell_contract_fixtures.rs
#	crates/nemoclaw-sdk/tests/compile.rs
#	docs/provider.md
cv added 7 commits October 14, 2026 10:49
It reaches its fake engine through crate::fixture, which listens on a
Unix socket and is compiled only on Unix, so the Windows clippy build
failed.
refused_server bound an ephemeral port and dropped the listener, so a
fake server in a concurrent test could take the port. The SDK then read
that server's objects and failed with BindingMismatch instead of the
refused connection's Transport error, failing linux_amd64 CI. Keep a
socket bound to the port without listening: connections are still
refused, and no other test can bind it while the test runs.
Deployment state recorded at version 10 binds fabric_agent_configuration
resources, which no provider serves now that agents are fabric_agent.
Bump the record version so such state is rejected with the recovery
message instead of failing inside OpenTofu.
Base automatically changed from feat/fabric-harness-sources to v1 October 14, 2026 18:42
@cv
cv enabled auto-merge (squash) October 14, 2026 18:48
v1's tree equals #13160's final tree (9ee2697), which this branch
already contains, so the merge keeps this branch's tree.
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit a2c33fc into v1 Oct 14, 2026
@cv
cv deleted the feat/fabric-agent branch October 14, 2026 19:07
cv added a commit that referenced this pull request Oct 14, 2026
…ref (#13184)

Closes #13145. Part of #13131.

#13167 has merged; this targets `v1`.

## Failure

`fabric_sandbox_readiness` took nine separate inputs: the sandbox's
workspace, name, ID, owner, generation and launch, plus the agent's
whole `config_json`. The SDK had to rebuild that document a second time
just to pass it to readiness, and readiness depended on the agent only
through an explicit `depends_on`.

## Decision

`fabric_agent_readiness` replaces it and takes `agent =
fabric_agent.<name>.ref`, plus `gateway` and `read_trigger`.

- `fabric_agent` now exports a `ref` with its sandbox's identity, its
own `name`, and `config_sha256`: `sha256:<hex>` over its composed
document's JSON with object keys sorted.
- Readiness reads the sandbox's launch metadata itself and checks that
the sandbox launches that agent. It then compares the digest of the
applied document with the ref's digest before asking for health. The
check is the same as before; only its inputs changed.
- `config_sha256` uses a new `nemoclaw-tofu` feature: derived
attributes, computed from a resource's inputs. They are known while
planning once their inputs are, and recomputed from every observation. A
computed attribute can only carry its prior value forward, which would
be wrong as soon as the inputs change.
- The SDK's readiness block is now three attributes, and the ref
replaces the explicit `depends_on`.

The name and semantics may change again once Fabric's own readiness work
lands; see the issue.

## Validation

- `cargo ci --full` passes locally (unit tests, plus 138 contract and
system tests).
- New unit tests cover derived attributes (plan, update, refresh),
key-order-independent digests, the digest waiting for its inputs, and
the readiness ref's validation (unknown attributes defer, a ref of
another type is rejected, rejected values are not echoed).
- The Fabric contract tests run readiness through pinned OpenTofu
against the fake gateway with the new ref. The `fabric_agent` update
test's no-op re-plan shows the derived digest and the ref plan cleanly.
@wscurran wscurran added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery 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: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery 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