Run in Livebook

Agent Blueprint Protocol walkthrough

This tour reads the shipped artifacts, checks one typed denial, negotiates support, reconciles the pair, reads evidence, and runs the shipped corpus. Each notebook in the set can run on its own.

Before you run

Use a tested combination: Elixir 1.19 with Erlang/OTP 28, or Elixir 1.20 with OTP 27, 28, or 29. You also need an internet connection for the first Hex install. Open this notebook with its Run in Livebook badge, choose a compatible runtime, then evaluate cells from top to bottom. No repository checkout is needed; examples and corpus files are read from the installed Hex package. The ~> 1.1.0 requirement permits later 1.1 patch releases. To replay this release's recorded outputs, change the install requirement to == 1.1.0.

The first cell installs the published package. Resources are read from the installed application with Application.app_dir/2.

Mix.install([{:agent_blueprint_protocol, "~> 1.1.0"}])

This cell checks that the installed application includes its example artifacts.

true = File.regular?(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
%{example_files_found?: true}
%{example_files_found?: true}

Read the shipped examples

The package contains a Blueprint and a Deployment Manifest. Decode both and compare the Blueprint's canonical bytes with the file bytes.

blueprint_bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
deployment_bytes = File.read!(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json"))

{:ok, blueprint} = AgentBlueprintProtocol.decode_blueprint(blueprint_bytes)
{:ok, deployment} = AgentBlueprintProtocol.decode_deployment(deployment_bytes)
{:ok, ^blueprint_bytes} = AgentBlueprintProtocol.canonical_bytes(blueprint)

%{blueprint: true, deployment: true, canonical_round_trip: true}
%{blueprint: true, deployment: true, canonical_round_trip: true}

Read a typed denial

This input has an unknown top-level member. Inspect the stable error fields rather than depending on an exception.

{:error, %AgentBlueprintProtocol.Error{} = error} =
  AgentBlueprintProtocol.decode_blueprint(~s({"unknown":true}))

%{code: error.code, subject: error.subject, detail: error.detail}
%{code: :unknown_member, detail: nil, subject: []}

Negotiate support

The support value lists the protocol revision accepted by this consumer. Notices are an open set, so this example matches the known name and keeps a catch-all.

support = %AgentBlueprintProtocol.Negotiation.Support{revisions: MapSet.new([1])}
{:ok, outcome} = AgentBlueprintProtocol.negotiate(blueprint, support)

notices =
  Enum.map(outcome.notices, fn notice ->
    case notice do
      :extension_deprecated -> :deprecated
      :extension_unknown_optional_retained -> :unknown_optional
      other -> {:unknown_notice, other}
    end
  end)

%{revision: outcome.protocol_revision, notices: notices}
%{revision: 1, notices: []}

Reconcile and read evidence

Reconciliation compares the artifacts with host inputs and returns protocol evidence. The summary reads every evidence field while leaving any new check shape unknown.

These are fixture bounds copied from the example Deployment to keep the notebook self-contained. They demonstrate the comparison API, not discovery of host configuration. In an integration, obtain host bounds from configured limits, build identities and descriptor digests from independent inventory, and public keys from the host's trust source.

alias AgentBlueprintProtocol.{BoundsAlgebra, Evidence, Reconcile}

{:ok, host_bounds} = BoundsAlgebra.from_deployment(deployment)

inputs = %Reconcile.Inputs{
  host_bounds: host_bounds,
  support: support,
  keys: [],
  protected_clamp: :acknowledge,
  observations: %AgentBlueprintProtocol.Deployment.Observations{}
}

{:ok, evidence} = AgentBlueprintProtocol.reconcile(blueprint, deployment, inputs)

checks =
  Enum.map(evidence.checks, fn
    %{surface: surface, subject: subject, verified: verified, detail: detail} ->
      detail_kind =
        case detail do
          nil -> :none
          %Evidence.Binding{} -> :binding
          %Evidence.Signatures{} -> :signatures
          %BoundsAlgebra.ClampEvidence{} -> :clamp
          %AgentBlueprintProtocol.Digest{} -> :digest
          other -> {:other_detail, is_struct(other)}
        end

      {surface, subject, verified, detail_kind}

    other ->
      {:unknown_check, is_map(other)}
  end)

not_verified =
  Enum.map(evidence.not_verified, fn name ->
    case name do
      :tenancy ->
        {:host_owned, :tenancy}

      :live_policy ->
        {:host_owned, :live_policy}

      name
      when name in [:authority, :effect_ownership, :execution, :billing, :evaluation_truth] ->
        {:host_owned, name}

      name
      when name in [
             :signatures,
             :signature_created_at,
             :lifecycle_state,
             :signature_time_validity,
             :binding_descriptors,
             :binding_staleness,
             :bind
           ] ->
        {:known_unverified, name}

      unknown ->
        {:unknown_surface, unknown}
    end
  end)

{:ok, effective} = BoundsAlgebra.BoundSet.to_map(evidence.effective_bounds)

%{
  protocol_revision: evidence.protocol_revision,
  blueprint_digest: AgentBlueprintProtocol.Digest.to_tagged(evidence.blueprint_digest),
  deployment_digest: AgentBlueprintProtocol.Digest.to_tagged(evidence.deployment_digest),
  checks: checks,
  effective_bounds: Map.take(effective, [:max_attempts, :max_tokens, :disclosure_ceiling]),
  clamps: Enum.map(evidence.clamps, &{&1.field, &1.requested, &1.effective}),
  optional_extensions_retained: evidence.optional_extensions_retained,
  not_verified: not_verified
}
%{
  protocol_revision: 1,
  checks: [
    {:canonical, ["blueprint"], true, :none},
    {:canonical, ["deployment"], true, :none},
    {:digest, ["blueprint"], true, :digest},
    {:digest, ["deployment"], true, :digest},
    {:negotiation, ["blueprint"], true, :none},
    {:negotiation, ["deployment"], true, :none},
    {:structure, ["blueprint"], true, :none},
    {:structure, ["deployment"], true, :none},
    {:portability, ["blueprint"], true, :none},
    {:portability, ["deployment"], true, :none},
    {:signatures, ["blueprint"], false, {:other_detail, false}},
    {:signatures, ["deployment"], false, {:other_detail, false}},
    {:bind, ["deployment"], false, :binding},
    {:bounds, ["bounds"], true, :none},
    {:bounds, ["disclosure_ceiling"], true, :clamp}
  ],
  not_verified: [
    host_owned: :tenancy,
    host_owned: :live_policy,
    host_owned: :authority,
    host_owned: :effect_ownership,
    host_owned: :execution,
    host_owned: :billing,
    host_owned: :evaluation_truth,
    known_unverified: :signature_created_at,
    known_unverified: :lifecycle_state,
    known_unverified: :signature_time_validity,
    known_unverified: :signatures,
    known_unverified: :bind,
    known_unverified: :binding_staleness,
    known_unverified: :binding_descriptors
  ],
  effective_bounds: %{max_attempts: 3, max_tokens: 100000, disclosure_ceiling: :summary},
  blueprint_digest: "sha-256:b1Aw4cU5AbV9k8bdbZkRCsySDHGpTAwB-aQm57Wh7B8",
  deployment_digest: "sha-256:tWFr0caS0AWFJd2UcB9gZv3kNjIUP8xZ08WWM_h8xgo",
  clamps: [{:disclosure_ceiling, :full, :summary}],
  optional_extensions_retained: []
}
Unverified namesWhy they remain
signaturesBoth example subjects are unsigned.
binding_descriptors, binding_staleness, bindNo descriptor inventory or clock/age was supplied. The host notebook adds these inputs.
signature_created_at, lifecycle_state, signature_time_validityCreation time, lifecycle state, and signing-key and signature validity periods remain host-owned.
tenancy, live_policy, authority, effect_ownership, execution, billing, evaluation_truthHost-owned decisions and observations.

Run the shipped corpus

The corpus loader checks the installed files before the runner evaluates the cases. The report shows the agreement totals.

alias AgentBlueprintProtocol.Conformance.{Corpus, Report, Runner}

corpus_root = Application.app_dir(:agent_blueprint_protocol, "priv/conformance")

files =
  for relative <- :filelib.wildcard(~c"**/*", String.to_charlist(corpus_root)),
      path = Path.join(corpus_root, relative),
      File.regular?(path),
      into: %{},
      do: {List.to_string(relative), File.read!(path)}

{:ok, corpus} = Corpus.load(files)
report = Report.build(corpus, Runner.run(corpus))

Map.take(report, [:agreement, :agreed, :disagreed, :total])
%{total: 626, agreed: 626, agreement: true, disagreed: 0}

Next