AgentBlueprintProtocol (Agent Blueprint Protocol v1.1.0)

Copy Markdown View Source

The facade decodes and verifies protocol artifacts through the Elixir reference implementation.

Use it when an application needs artifact codecs and combined verification calls.

This module does not authorize operations.

Example

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

Summary

Types

A typed error result returned by a fallible facade operation.

Functions

Returns canonical JSON bytes for the supplied artifact.

Decodes and validates Blueprint bytes under the supplied parse limits.

Decodes and validates Deployment bytes under the supplied parse limits.

Decodes and validates Federation envelope bytes under the supplied parse limits.

Returns the field mapping data for the supported federation carriers.

Intersects the Blueprint, Deployment, and host bound sources.

Checks an artifact against a consumer support posture.

Runs the composed verification pass for a Blueprint and Deployment pair.

Compares manifest identities with identities reported by a host.

Types

failure()

(since 1.0.0)
@type failure() :: {:error, AgentBlueprintProtocol.Error.t()}

A typed error result returned by a fallible facade operation.

Functions

canonical_bytes(blueprint)

(since 1.0.0)

Returns canonical JSON bytes for the supplied artifact.

Example

iex> with {:ok, blueprint} <- AgentBlueprintProtocol.Blueprint.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))), do: match?({:ok, bytes} when is_binary(bytes), AgentBlueprintProtocol.canonical_bytes(blueprint))
true

decode_blueprint(bytes, bounds \\ Bounds.maximum())

(since 1.0.0)
@spec decode_blueprint(binary(), AgentBlueprintProtocol.Bounds.t() | map()) ::
  {:ok, AgentBlueprintProtocol.Blueprint.t()} | failure()

Decodes and validates Blueprint bytes under the supplied parse limits.

Example

iex> bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
iex> match?({:ok, %AgentBlueprintProtocol.Blueprint{}}, AgentBlueprintProtocol.decode_blueprint(bytes))
true
iex> match?({:ok, %AgentBlueprintProtocol.Blueprint{}}, AgentBlueprintProtocol.decode_blueprint(bytes, %{bytes: 5000}))
true

decode_deployment(bytes, bounds \\ Bounds.maximum())

(since 1.0.0)
@spec decode_deployment(binary(), AgentBlueprintProtocol.Bounds.t() | map()) ::
  {:ok, AgentBlueprintProtocol.Deployment.t()} | failure()

Decodes and validates Deployment bytes under the supplied parse limits.

Example

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

decode_federation_envelope(bytes, bounds \\ Bounds.maximum())

(since 1.0.0)
@spec decode_federation_envelope(binary(), AgentBlueprintProtocol.Bounds.t() | map()) ::
  {:ok, AgentBlueprintProtocol.Federation.t()} | failure()

Decodes and validates Federation envelope bytes under the supplied parse limits.

Example

iex> bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/federation-envelope.json"))
iex> match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.decode_federation_envelope(bytes))
true
iex> match?({:ok, %AgentBlueprintProtocol.Federation{}}, AgentBlueprintProtocol.decode_federation_envelope(bytes, %{bytes: 5000}))
true

federation_mapping()

(since 1.0.0)
@spec federation_mapping() :: [AgentBlueprintProtocol.Federation.Mapping.Row.t()]

Returns the field mapping data for the supported federation carriers.

Example

iex> is_list(AgentBlueprintProtocol.federation_mapping())
true

intersect(sources)

(since 1.0.0)

Intersects the Blueprint, Deployment, and host bound sources.

Example

iex> with {:ok, blueprint} <- AgentBlueprintProtocol.Blueprint.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))), {:ok, deployment} <- AgentBlueprintProtocol.Deployment.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))), {:ok, blueprint_bounds} <- AgentBlueprintProtocol.BoundsAlgebra.from_blueprint(blueprint), {:ok, deployment_bounds} <- AgentBlueprintProtocol.BoundsAlgebra.from_deployment(deployment), sources = %AgentBlueprintProtocol.BoundsAlgebra.Sources{blueprint: blueprint_bounds, deployment: deployment_bounds, host: deployment_bounds, protected_clamp: :acknowledge}, do: match?({:ok, %AgentBlueprintProtocol.BoundsAlgebra.Result{}}, AgentBlueprintProtocol.intersect(sources))
true

negotiate(artifact, support)

(since 1.0.0)

Checks an artifact against a consumer support posture.

Example

iex> with {:ok, blueprint} <- AgentBlueprintProtocol.Blueprint.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))), support = %AgentBlueprintProtocol.Negotiation.Support{revisions: MapSet.new([1]), core_fields: MapSet.new([])}, do: match?({:ok, %AgentBlueprintProtocol.Negotiation.Outcome{}}, AgentBlueprintProtocol.negotiate(blueprint, support))
true

reconcile(blueprint, deployment, inputs)

(since 1.0.0)

Runs the composed verification pass for a Blueprint and Deployment pair.

Example

iex> with {:ok, blueprint} <- AgentBlueprintProtocol.Blueprint.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))), {:ok, deployment} <- AgentBlueprintProtocol.Deployment.decode(File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))), {:ok, host_bounds} <- AgentBlueprintProtocol.BoundsAlgebra.from_deployment(deployment), inputs = %AgentBlueprintProtocol.Reconcile.Inputs{host_bounds: host_bounds, support: %AgentBlueprintProtocol.Negotiation.Support{revisions: MapSet.new([1]), core_fields: MapSet.new([])}, keys: [], protected_clamp: :acknowledge, observations: %AgentBlueprintProtocol.Deployment.Observations{}}, do: match?({:ok, %AgentBlueprintProtocol.Evidence{}}, AgentBlueprintProtocol.reconcile(blueprint, deployment, inputs))
true

verify_compatibility(deployment, observed)

(since 1.0.0)

Compares manifest identities with identities reported by a host.

Example

iex> match?({:error, %AgentBlueprintProtocol.Error{code: :invalid_type}}, AgentBlueprintProtocol.verify_compatibility(:invalid, :invalid))
true