AgentBlueprintProtocol.Deployment (Agent Blueprint Protocol v1.1.0)

Copy Markdown View Source

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

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

Summary

Types

A typed error returned by AgentBlueprintProtocol.Deployment.

t()

The public data type for AgentBlueprintProtocol.Deployment.

Functions

Reports whether the Deployment names the supplied Blueprint release.

Returns the Blueprint release identity recorded by the Deployment.

Encodes a Deployment as canonical JSON bytes.

Computes the Deployment content digest.

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

Reports whether a Deployment member contributes to its content digest.

Returns the Deployment fields covered by its content digest.

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.

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

Returns the tagged JSON value held by the Deployment.

Checks the Deployment binding against a Blueprint and supplied observations.

Checks the declared Deployment digest against its covered content.

Types

reason()

(since 1.0.0)
@type reason() :: AgentBlueprintProtocol.Error.t()

A typed error returned by AgentBlueprintProtocol.Deployment.

t()

(since 1.0.0)
@type t() :: %AgentBlueprintProtocol.Deployment{
  value: AgentBlueprintProtocol.Json.value()
}

The public data type for AgentBlueprintProtocol.Deployment.

Functions

binds?(deployment, blueprint)

(since 1.0.0)
@spec binds?(t(), AgentBlueprintProtocol.Blueprint.t()) :: boolean()

Reports whether the Deployment names the supplied Blueprint release.

Example

{: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(deployment)

(since 1.0.0)
@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

{: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(arg1)

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

Encodes a Deployment as canonical JSON bytes.

Example

{: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(deployment)

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

Computes the Deployment content digest.

Example

{: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(binary, bounds \\ Bounds.maximum())

(since 1.0.0)
@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

match?(
  {:ok, %AgentBlueprintProtocol.Deployment{}},
  AgentBlueprintProtocol.Deployment.decode(
    File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))
  )
)
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?(member_name)

(since 1.0.0)
@spec digest_covered?(binary()) :: boolean()

Reports whether a Deployment member contributes to its content digest.

Example

AgentBlueprintProtocol.Deployment.digest_covered?("tool_bindings")

digest_input(arg1)

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

Returns the Deployment fields covered by its content digest.

Example

{: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(value, opts \\ %{})

(since 1.0.0)
@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):

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

Example

{: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)
)
{: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(revision)

(since 1.1.0)
@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(arg1)

(since 1.0.0)

Returns the tagged JSON value held by the Deployment.

Example

{: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(deployment, blueprint, obs)

(since 1.0.0)

Checks the Deployment binding against a Blueprint and supplied observations.

Example

{: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(deployment)

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

Checks the declared Deployment digest against its covered content.

Example

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

AgentBlueprintProtocol.Deployment.verify_content_digest(deployment)