Skip to content

feat(fabric-provider): read agent readiness through the fabric_agent ref - #13184

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

cv merged 33 commits into
v1from
feat/fabric-agent-readiness

Conversation

@cv

@cv cv commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

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.

cv added 30 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
fabric_sandbox_readiness took the sandbox's identity and launch and the
agent's whole document as nine separate inputs, so the SDK rebuilt the
document a second time and ordered readiness with depends_on.

fabric_agent_readiness takes the fabric_agent ref instead. fabric_agent
exports its sandbox identity, name, and config_sha256, a key-order-
independent digest of the document its inputs compose, as a new
derived attribute: computed from inputs while planning and recomputed
from every observation. Readiness reads the sandbox's launch itself and
compares the applied document's digest with the ref's.
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.
v1's tree equals #13160's final tree (9ee2697), which this branch
already contains, so the merge keeps this branch's tree.
Base automatically changed from feat/fabric-agent to v1 October 14, 2026 19:07
cv added 2 commits October 14, 2026 12:09
# Conflicts:
#	crates/fabric-provider/src/agent.rs
#	crates/fabric-provider/src/lib.rs
#	crates/fabric-provider/src/provider.rs
#	crates/fabric-provider/tests/contract/fixtures/readiness.tf
#	crates/fabric-provider/tests/contract/main.rs
#	crates/fabric-provider/tests/schema.txt
#	crates/nemoclaw-fabric/src/agent.rs
#	crates/nemoclaw-sdk/src/compile.rs
#	crates/nemoclaw-sdk/tests/compile.rs
#	crates/nemoclaw-tofu/src/lib.rs
#	crates/nemoclaw-tofu/src/resource.rs
#	docs/contributing/integration-tests.md
#	docs/provider.md
@cv
cv enabled auto-merge (squash) October 14, 2026 19:19
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv merged commit 29139ae into v1 Oct 14, 2026
@cv
cv deleted the feat/fabric-agent-readiness branch October 14, 2026 19:31
gaveezy added a commit that referenced this pull request Oct 19, 2026
PR-6 merged v1 up to #13411. Three v1 changes move code this branch
builds on:

- #13224 removed the `nemoclaw` provider, which served this branch's
  cluster model types. They become `openshell_kubernetes_service` and
  `openshell_kubernetes_service_storage`, served by the openshell
  provider beside the Kubernetes gateway installation types: two more
  `INSTALLATION_TYPES` entries, and `cluster_services::definitions()`
  in `all_definitions()`. Their contract tests move to
  `openshell-provider::contract` with the Kubernetes gateway tests,
  their schema to the openshell snapshot, and the docs name the new
  types.
- #13286 plans and applies each deployment as one OpenTofu root. The
  cluster image preflight moves from the removed runtime stage into
  `Deployment::run`, before compilation. #13286 also removed the
  "unfinished Kubernetes platform apply" rule, so this branch's
  exception to it (`revises_only_model_workloads`), its test, and its
  usage.md paragraph go too. The compile test now checks that the
  apply-time gateway read, which every object waits on, waits on the
  cluster service, instead of checking that agents compile into a
  separate graph.
- #13184 added `Definition::derived`: a computed attribute kept out of
  backend rows. This branch's `derived` is an optional input checked
  against the spec and kept in the row, so ownership checks still see
  `owner` and `generation`. It is renamed `derived_input`.

Smaller follow-ups:

- #13093 added `ServiceDefinition::Container`; the cluster matches
  cover it. The cluster service is no longer a `runtime_process` kind:
  that flag now also selects Docker readiness and compute, which decode
  a Docker spec. Its only other readers handle the cluster kind first.
- #13223 dropped the `org.nemoclaw.runtime.spec` label everywhere; the
  cluster image check no longer requires it.
- #13369 removed `model_metadata` from OpenClaw routes, since Fabric
  v0.5.0's adapter rejects it; the cluster fixtures and docs drop it.

The remaining conflicts keep both sides.

`openshell-provider::contract`'s summed budget rises from 105 to 130 s,
keeping v1's margin: the 8 moved cluster model tests add 23.2 s in a
local linux_arm64 run (slowest 3.9 s, within the 6 s limit), about 17 s
at CI speed. `nemoclaw-provider::contract` keeps its v1 budget; this
branch's earlier raise to 150 s went with the tests.

Validation on linux_arm64: the `cargo ci` fmt, clippy, test, schema,
bundle and lifecycle steps pass (161 lifecycle tests, among them the 8
cluster model contract tests), as does `nemoclaw-build docs --check`.

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 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: security Security controls, permissions, secrets, or hardening 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