This module validates Federation TaskEnvelope values and converts supported state and carrier shapes.
Use it when reading an envelope or mapping it to a supported task carrier.
This module does not authorize operations.
Example
bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))
match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.decode(bytes))
Summary
Functions
Returns the carrier key used for A2A metadata.
Returns canonical JSON bytes for the supplied artifact.
Decodes a canonical Federation TaskEnvelope and validates its structure and portability.
Builds a Federation envelope from an A2A carrier value.
Maps an A2A state spelling to the logical state.
Builds a Federation envelope from an MCP carrier value.
Maps an MCP state spelling to the logical state.
Validates a tagged JSON value and wraps it in this artifact type.
Returns the field mapping rows for the supported federation carriers.
Returns the carrier key used for MCP metadata.
Returns the sorted Federation TaskEnvelope member names for a supported protocol revision.
Computes the commitment for a terminal Federation envelope.
Builds an A2A carrier value from a Federation envelope.
Maps a logical state to its A2A spelling.
Builds an MCP carrier value from a Federation envelope.
Maps a logical state to its MCP spelling.
Checks a Federation envelope against the supplied receiver context.
Types
@type t() :: %AgentBlueprintProtocol.Federation{ value: AgentBlueprintProtocol.Json.value() }
The public data type for AgentBlueprintProtocol.Federation.
Functions
@spec a2a_carrier_key() :: binary()
Returns the carrier key used for A2A metadata.
Example
iex> is_binary(AgentBlueprintProtocol.Federation.a2a_carrier_key())
true
@spec canonical_bytes(t()) :: {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}
Returns canonical JSON bytes for the supplied artifact.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:ok, bytes} when is_binary(bytes), AgentBlueprintProtocol.Federation.canonical_bytes(envelope))
true
@spec decode(binary(), AgentBlueprintProtocol.Bounds.t() | map()) :: {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
Decodes a canonical Federation TaskEnvelope and validates its structure and portability.
Example
iex> bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))
iex> match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.decode(bytes))
true
iex> match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.decode(bytes, %{bytes: 5000}))
true
@spec from_a2a_carrier(AgentBlueprintProtocol.Json.value()) :: {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
Builds a Federation envelope from an A2A carrier value.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), {:ok, carrier} <- AgentBlueprintProtocol.Federation.to_a2a_carrier(envelope), do: match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.from_a2a_carrier(carrier))
true
@spec from_a2a_state(binary()) :: {:ok, atom()} | {:error, AgentBlueprintProtocol.Error.t()}
Maps an A2A state spelling to the logical state.
Example
iex> AgentBlueprintProtocol.Federation.from_a2a_state("TASK_STATE_COMPLETED")
{:ok, :completed}
@spec from_mcp_carrier(AgentBlueprintProtocol.Json.value()) :: {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
Builds a Federation envelope from an MCP carrier value.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), {:ok, carrier} <- AgentBlueprintProtocol.Federation.to_mcp_carrier(envelope), do: match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.from_mcp_carrier(carrier))
true
@spec from_mcp_state(binary()) :: {:ok, atom()} | {:error, AgentBlueprintProtocol.Error.t()}
Maps an MCP state spelling to the logical state.
Example
iex> AgentBlueprintProtocol.Federation.from_mcp_state("completed")
{:ok, :completed}
@spec from_value(AgentBlueprintProtocol.Json.value()) :: {:ok, t()} | {:error, AgentBlueprintProtocol.Error.t()}
Validates a tagged JSON value and wraps it in this artifact type.
Example
iex> with {:ok, value} <- AgentBlueprintProtocol.Json.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.Federation.from_value(value))
true
@spec mapping() :: [AgentBlueprintProtocol.Federation.Mapping.Row.t()]
Returns the field mapping rows for the supported federation carriers.
Example
iex> Enum.all?(AgentBlueprintProtocol.Federation.mapping(), &is_struct(&1, AgentBlueprintProtocol.Federation.Mapping.Row))
true
@spec mcp_carrier_key() :: binary()
Returns the carrier key used for MCP metadata.
Example
iex> is_binary(AgentBlueprintProtocol.Federation.mcp_carrier_key())
true
@spec members(integer()) :: {:ok, [binary()]} | {:error, AgentBlueprintProtocol.Error.t()}
Returns the sorted Federation TaskEnvelope member names for a supported protocol revision.
Use this vocabulary when inspecting TaskEnvelope members. For
AgentBlueprintProtocol.Negotiation.Support.core_fields, a host that
supports every core field declares the union of
AgentBlueprintProtocol.Blueprint.members/1 and
AgentBlueprintProtocol.Deployment.members/1 for that revision.
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.Federation.members(1), do: length(names)
23
@spec terminal_commitment(t()) :: {:ok, AgentBlueprintProtocol.Digest.t()} | {:error, AgentBlueprintProtocol.Error.t()}
Computes the commitment for a terminal Federation envelope.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:ok, %AgentBlueprintProtocol.Digest{algorithm: :sha256, bytes: <<_::256>>}}, AgentBlueprintProtocol.Federation.terminal_commitment(envelope))
true
@spec to_a2a_carrier(t()) :: {:ok, AgentBlueprintProtocol.Json.value()} | {:error, AgentBlueprintProtocol.Error.t()}
Builds an A2A carrier value from a Federation envelope.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:ok, {:object, _}}, AgentBlueprintProtocol.Federation.to_a2a_carrier(envelope))
true
@spec to_a2a_state(atom()) :: {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}
Maps a logical state to its A2A spelling.
Example
iex> AgentBlueprintProtocol.Federation.to_a2a_state(:completed)
{:ok, "TASK_STATE_COMPLETED"}
@spec to_mcp_carrier(t()) :: {:ok, AgentBlueprintProtocol.Json.value()} | {:error, AgentBlueprintProtocol.Error.t()}
Builds an MCP carrier value from a Federation envelope.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:ok, {:object, _}}, AgentBlueprintProtocol.Federation.to_mcp_carrier(envelope))
true
@spec to_mcp_state(atom()) :: {:ok, binary()} | {:error, AgentBlueprintProtocol.Error.t()}
Maps a logical state to its MCP spelling.
Example
iex> AgentBlueprintProtocol.Federation.to_mcp_state(:completed)
{:ok, "completed"}
@spec verify_commitment(t(), AgentBlueprintProtocol.Federation.Context.t()) :: {:ok, AgentBlueprintProtocol.Federation.Context.receipt_fact()} | {:error, AgentBlueprintProtocol.Error.t()}
Checks a Federation envelope against the supplied receiver context.
Example
iex> with {:ok, envelope} <- AgentBlueprintProtocol.Federation.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))), do: match?({:error, %AgentBlueprintProtocol.Error{}}, AgentBlueprintProtocol.Federation.verify_commitment(envelope, %AgentBlueprintProtocol.Federation.Context{}))
true