# `AgentBlueprintProtocol.Deployment`
[🔗](https://github.com/baselabs/agent_blueprint_protocol/blob/v1.1.0/lib/agent_blueprint_protocol/deployment.ex#L1)

This module decodes and validates Deployment Manifest artifacts.

Use it when reading a manifest or checking its relation to a Blueprint.

This module does not authorize operations.

## Example

```elixir
bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
match?({:ok, %AgentBlueprintProtocol.Deployment{}}, AgentBlueprintProtocol.Deployment.decode(bytes))
```

# `reason`
*since 1.0.0* 

```elixir
@type reason() :: AgentBlueprintProtocol.Error.t()
```

A typed error returned by AgentBlueprintProtocol.Deployment.

# `t`
*since 1.0.0* 

```elixir
@type t() :: %AgentBlueprintProtocol.Deployment{
  value: AgentBlueprintProtocol.Json.value()
}
```

The public data type for AgentBlueprintProtocol.Deployment.

# `binds?`
*since 1.0.0* 

```elixir
@spec binds?(t(), AgentBlueprintProtocol.Blueprint.t()) :: boolean()
```

Reports whether the Deployment names the supplied Blueprint release.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

{:ok, blueprint} =
  AgentBlueprintProtocol.Blueprint.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
  )

AgentBlueprintProtocol.Deployment.binds?(deployment, blueprint)
```

# `bound_release`
*since 1.0.0* 

```elixir
@spec bound_release(t()) ::
  {:ok,
   %{
     blueprint_id: binary(),
     release_number: pos_integer(),
     content_digest: AgentBlueprintProtocol.Digest.t()
   }}
  | {:error, AgentBlueprintProtocol.Error.t()}
```

Returns the Blueprint release identity recorded by the Deployment.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?(
  {:ok, %{blueprint_id: id, release_number: number, content_digest: %AgentBlueprintProtocol.Digest{}}}
  when is_binary(id) and is_integer(number),
  AgentBlueprintProtocol.Deployment.bound_release(deployment)
)
```

# `canonical_bytes`
*since 1.0.0* 

```elixir
@spec canonical_bytes(t()) ::
  {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}
```

Encodes a Deployment as canonical JSON bytes.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?(
  {:ok, bytes} when is_binary(bytes),
  AgentBlueprintProtocol.Deployment.canonical_bytes(deployment)
)
```

# `content_digest`
*since 1.0.0* 

```elixir
@spec content_digest(t()) ::
  AgentBlueprintProtocol.Digest.t() | {:error, AgentBlueprintProtocol.Error.t()}
```

Computes the Deployment content digest.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?(
  %AgentBlueprintProtocol.Digest{},
  AgentBlueprintProtocol.Deployment.content_digest(deployment)
)
```

# `decode`
*since 1.0.0* 

```elixir
@spec decode(binary(), AgentBlueprintProtocol.Bounds.t() | map()) ::
  {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
```

Decodes canonical JSON bytes and validates the Deployment contents and digest.

## Example

```elixir
match?(
  {:ok, %AgentBlueprintProtocol.Deployment{}},
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )
)
```

```elixir
match?(
  {:ok, %AgentBlueprintProtocol.Deployment{}},
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json")),
    AgentBlueprintProtocol.Bounds.maximum()
  )
)
```

# `digest_covered?`
*since 1.0.0* 

```elixir
@spec digest_covered?(binary()) :: boolean()
```

Reports whether a Deployment member contributes to its content digest.

## Example

```elixir
AgentBlueprintProtocol.Deployment.digest_covered?("tool_bindings")
```

# `digest_input`
*since 1.0.0* 

```elixir
@spec digest_input(t()) ::
  AgentBlueprintProtocol.Json.value()
  | {:error, AgentBlueprintProtocol.Error.t()}
```

Returns the Deployment fields covered by its content digest.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?({:object, _}, AgentBlueprintProtocol.Deployment.digest_input(deployment))
```

# `from_value`
*since 1.0.0* 

```elixir
@spec from_value(AgentBlueprintProtocol.Json.value(), map()) ::
  {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
```

Validates the tagged value's structure and portability and constructs a draft artifact.
This function does not compare the declared digest with recomputed content and does
not verify signatures. Producers must compute and insert `deployment_digest`, encode
canonical bytes, and decode those bytes to check the completed artifact.

## Options

`:authored_extensions` defaults to `[]`. It is a list of critical namespace strings
whose bodies have already passed negotiation's schema validation for this same
value. It changes portability scanning of those bodies; it does not validate a
schema or establish content classification. Never infer this list from names alone.
Host consumers should use `AgentBlueprintProtocol.reconcile/3`, which derives it.

After successful negotiation of `value` with the host's `support` (an excerpt):

```elixir
{:ok, outcome} = AgentBlueprintProtocol.negotiate(value, support)
{:ok, draft} = AgentBlueprintProtocol.Deployment.from_value(value, %{
  authored_extensions: outcome.critical_extensions
})
```

## Example

```elixir
{:ok, value} =
  AgentBlueprintProtocol.Json.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?(
  {:ok, %AgentBlueprintProtocol.Deployment{}},
  AgentBlueprintProtocol.Deployment.from_value(value)
)
```

```elixir
{:ok, value} =
  AgentBlueprintProtocol.Json.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?(
  {:ok, %AgentBlueprintProtocol.Deployment{}},
  AgentBlueprintProtocol.Deployment.from_value(value, %{authored_extensions: []})
)
```

# `members`
*since 1.1.0* 

```elixir
@spec members(integer()) ::
  {:ok, [binary()]} | {:error, AgentBlueprintProtocol.Error.t()}
```

  Returns the sorted Deployment Manifest member names for a supported protocol revision.

  Hosts that support every core field of a revision declare the union of
  `AgentBlueprintProtocol.Blueprint.members/1` and
  `AgentBlueprintProtocol.Deployment.members/1` in
  `AgentBlueprintProtocol.Negotiation.Support.core_fields`.

  Revision 1 is supported. Other integers return `:protocol_revision_unsupported`
  with subject `["protocol_revision"]`; non-integers return `:invalid_type`.

  ## Example

      iex> with {:ok, names} <- AgentBlueprintProtocol.Deployment.members(1), do: length(names)
      19

# `to_value`
*since 1.0.0* 

```elixir
@spec to_value(t()) ::
  AgentBlueprintProtocol.Json.value()
  | {:error, AgentBlueprintProtocol.Error.t()}
```

Returns the tagged JSON value held by the Deployment.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

match?({:object, _}, AgentBlueprintProtocol.Deployment.to_value(deployment))
```

# `verify_binding`
*since 1.0.0* 

```elixir
@spec verify_binding(
  t(),
  AgentBlueprintProtocol.Blueprint.t(),
  AgentBlueprintProtocol.Deployment.Observations.t()
) :: :ok | {:error, AgentBlueprintProtocol.Error.t()}
```

Checks the Deployment binding against a Blueprint and supplied observations.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

{:ok, blueprint} =
  AgentBlueprintProtocol.Blueprint.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
  )

AgentBlueprintProtocol.Deployment.verify_binding(
  deployment,
  blueprint,
  %AgentBlueprintProtocol.Deployment.Observations{}
)
```

# `verify_content_digest`
*since 1.0.0* 

```elixir
@spec verify_content_digest(t()) :: :ok | {:error, AgentBlueprintProtocol.Error.t()}
```

Checks the declared Deployment digest against its covered content.

## Example

```elixir
{:ok, deployment} =
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )

AgentBlueprintProtocol.Deployment.verify_content_digest(deployment)
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
