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.
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
@type reason() :: AgentBlueprintProtocol.Error.t()
A typed error returned by AgentBlueprintProtocol.Deployment.
@type t() :: %AgentBlueprintProtocol.Deployment{ value: AgentBlueprintProtocol.Json.value() }
The public data type for AgentBlueprintProtocol.Deployment.
Functions
@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)
@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)
)
@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)
)
@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)
)
@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()
)
)
Reports whether a Deployment member contributes to its content digest.
Example
AgentBlueprintProtocol.Deployment.digest_covered?("tool_bindings")
@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))
@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: []})
)
@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
@spec to_value(t()) :: AgentBlueprintProtocol.Json.value() | {:error, AgentBlueprintProtocol.Error.t()}
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))
@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
{: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{}
)
@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)