Run in Livebook

Host import

This notebook decodes the shipped artifacts, compares declared build identities with host observations, intersects bounds, calls reconcile/3, and reads each part of the resulting evidence.

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"}])

Locate and decode both shipped artifacts and the plain JSON views used to build host observations.

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

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"))
blueprint_json = JSON.decode!(blueprint_bytes)
deployment_json = JSON.decode!(deployment_bytes)

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

%{blueprint_decoded: true, deployment_decoded: true}
%{blueprint_decoded: true, deployment_decoded: true}

Compare observed identities

Compatibility compares each manifest identity with an exact observed identity. The empty list and a matching list illustrate the two results. These are fixture observations constructed from the example so this notebook is self-contained. They demonstrate the comparison API, not independent discovery of the host environment. In an integration, obtain build identities and descriptor digests from your host's own inventory, and obtain host bounds from its configured limits.

alias AgentBlueprintProtocol.Compatibility.Observed
{:ok, blueprint_members} = AgentBlueprintProtocol.Blueprint.members(1)
{:ok, deployment_members} = AgentBlueprintProtocol.Deployment.members(1)
core_fields = MapSet.new(blueprint_members ++ deployment_members)
support = %AgentBlueprintProtocol.Negotiation.Support{
  revisions: MapSet.new([1]),
  core_fields: core_fields
}
{:ok, negotiation} = AgentBlueprintProtocol.negotiate(blueprint, support)

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

identities =
  Enum.map(deployment_json["build_identities"], fn item ->
    %{kind: item["kind"], name: item["name"], version: item["version"], digest: item["digest"]}
  end)

none = AgentBlueprintProtocol.verify_compatibility(deployment, %Observed{identities: []})
full = AgentBlueprintProtocol.verify_compatibility(deployment, %Observed{identities: identities})

%{
  negotiated_revision: negotiation.protocol_revision,
  notices: notices,
  none:
    case none do
      {:error, error} -> error.code
      {:ok, _} -> :matched
    end,
  full: match?({:ok, %AgentBlueprintProtocol.Evidence{}}, full)
}
%{none: :compatibility_entry_missing, full: true, notices: [], negotiated_revision: 1}

Intersect bounds

These fixture bounds start from the Manifest for the lesson. A real host starts from its configured limits. A host can narrow an operational value. A protected narrowing returns a denial under the deny posture and a clamp record under the acknowledge posture.

alias AgentBlueprintProtocol.BoundsAlgebra
alias AgentBlueprintProtocol.BoundsAlgebra.{BoundSet, Sources}

{:ok, blueprint_bounds} = BoundsAlgebra.from_blueprint(blueprint)
{:ok, deployment_bounds} = BoundsAlgebra.from_deployment(deployment)
{:ok, host_values} = BoundSet.to_map(deployment_bounds)
host_values = %{host_values | max_attempts: 2, disclosure_ceiling: :none}
{:ok, host_bounds} = BoundSet.new(host_values)

sources = %Sources{
  blueprint: blueprint_bounds,
  deployment: deployment_bounds,
  host: host_bounds,
  protected_clamp: :deny
}

denied = BoundsAlgebra.intersect(sources)
{:ok, acknowledged} = BoundsAlgebra.intersect(%{sources | protected_clamp: :acknowledge})
{:ok, effective} = BoundSet.to_map(acknowledged.effective)

%{
  denial:
    case denied do
      {:error, error} -> error.code
      {:ok, _} -> :allowed
    end,
  effective_attempts: effective.max_attempts,
  clamp_fields: Enum.map(acknowledged.clamps, & &1.field)
}
%{
  denial: :protected_bound_clamp_denied,
  effective_attempts: 2,
  clamp_fields: [:disclosure_ceiling, :max_attempts]
}

Observations

Descriptor observations can be absent, partial, or complete. This self-contained fixture copies declarations from the example; production observations come from independent host inventory. Keep the narrowed host_bounds from the preceding section.

alias AgentBlueprintProtocol.{Reconcile, Deployment, Evidence, Digest}

observed_all =
  Map.new(deployment_json["tool_bindings"], &{&1["logical_operation"], &1["descriptor_digest"]})

operation = observed_all |> Map.keys() |> Enum.sort() |> hd()
observed_partial = Map.take(observed_all, [operation])

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

coverage =
  Enum.map([{:none, %{}}, {:partial, observed_partial}, {:full, observed_all}], fn {label,
                                                                                    observed} ->
    {:ok, evidence} =
      AgentBlueprintProtocol.reconcile(blueprint, deployment, %{
        inputs
        | observations: %Deployment.Observations{observed: observed}
      })

    check = Enum.find(evidence.checks, &(&1.surface == :bind and &1.subject == ["deployment"]))
    %Evidence.Binding{checked: checked, not_verified: skipped} = check.detail
    {label, %{checked: checked, not_verified: skipped, verified: check.verified}}
  end)

coverage
[
  none: %{
    checked: [:release_binding, :binding_completeness, :effect_recovery],
    verified: false,
    not_verified: [:binding_staleness, :binding_descriptors]
  },
  partial: %{
    checked: [:release_binding, :binding_completeness, :effect_recovery],
    verified: false,
    not_verified: [:binding_staleness, :binding_descriptors]
  },
  full: %{
    checked: [:release_binding, :binding_completeness, :effect_recovery,
     :binding_descriptors],
    verified: false,
    not_verified: [:binding_staleness]
  }
]

Absent and partial descriptors leave :binding_descriptors unverified. Full descriptor coverage checks that kind, but leaves :binding_staleness unverified until both clock and age inputs are supplied. A successful return does not mean every optional check ran.

Mismatched and stale observations

A well-formed different digest denies. The fixed clock checks the example's binding timestamps at the inclusive one-second age limit, then advances beyond it. Elixir takes a DateTime; npm takes a timestamp string such as "2026-08-20T00:00:01Z" and uses maxAttestationAgeMs.

other_digest = Digest.to_tagged(Digest.hash(:blueprint_content, "different descriptor fixture"))
mismatch = Map.put(observed_all, operation, other_digest)

{:error, mismatch_error} =
  Deployment.verify_binding(deployment, blueprint, %Deployment.Observations{observed: mismatch})

fresh = %Deployment.Observations{
  observed: observed_all,
  now: ~U[2026-08-20 00:00:01Z],
  max_attestation_age_ms: 1_000
}

{:ok, evidence} =
  AgentBlueprintProtocol.reconcile(blueprint, deployment, %{inputs | observations: fresh})

check = Enum.find(evidence.checks, &(&1.surface == :bind and &1.subject == ["deployment"]))

{:error, stale_error} =
  AgentBlueprintProtocol.reconcile(blueprint, deployment, %{
    inputs
    | observations: %{fresh | now: ~U[2026-08-20 00:00:02Z]}
  })

%{
  mismatch: mismatch_error.code,
  fresh: check.detail,
  fresh_verified: check.verified,
  stale: stale_error.code
}
%{
  mismatch: :binding_descriptor_mismatch,
  stale: :binding_attestation_stale,
  fresh: %AgentBlueprintProtocol.Evidence.Binding{
    checked: [:release_binding, :binding_completeness, :effect_recovery,
     :binding_staleness, :binding_descriptors],
    not_verified: []
  },
  fresh_verified: true
}

Read evidence without losing names

The original names remain visible even for unfamiliar surfaces. Both artifact subjects are unsigned in this fixture. The producer notebook checks signed subjects.

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

not_verified =
  Enum.map(evidence.not_verified, fn
    name
    when name in [
           :tenancy,
           :live_policy,
           :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}

    other ->
      {:unknown_surface, other}
  end)

signatures =
  Enum.map(["blueprint", "deployment"], fn artifact ->
    check = Enum.find(evidence.checks, &(&1.surface == :signatures and &1.subject == [artifact]))

    case check do
      %{verified: true, detail: %Evidence.Signatures{key_ids: ids}} ->
        {artifact, {:verified_by, ids}}

      %{verified: false, detail: :no_signatures_present} ->
        {artifact, :not_verified}

      other ->
        {artifact, {:unknown_check, other}}
    end
  end)

%{
  signatures: signatures,
  effective_attempts: effective.max_attempts,
  effective_disclosure: effective.disclosure_ceiling,
  clamps: Enum.map(evidence.clamps, &{&1.field, &1.requested, &1.effective}),
  not_verified: not_verified
}
%{
  signatures: [{"blueprint", :not_verified}, {"deployment", :not_verified}],
  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
  ],
  clamps: [{:disclosure_ceiling, :full, :none}, {:max_attempts, 3, 2}],
  effective_attempts: 2,
  effective_disclosure: :none
}
Unverified name in this runMeaning
signaturesAt least one artifact subject is unsigned; here both are.
signature_created_atA signature timestamp is signed data, not an independent clock check.
lifecycle_stateReconciliation does not establish host lifecycle state.
signature_time_validityThe host judges the validity periods of the signing key and signature.
Host-owned namesTenancy, policy, authority, effects, execution, billing, and evaluation truth need host decisions.

The complete descriptor map and fixed clock establish both optional binding kinds in this run. The narrowed attempts 2 and disclosure :none remain effective, with both clamps recorded.

Decoder limits and error shape

A lower byte limit returns the same typed Error struct used by other fallible calls.

{:error, %AgentBlueprintProtocol.Error{} = limit_error} =
  AgentBlueprintProtocol.decode_blueprint(blueprint_bytes, %{bytes: 16})

%{code: limit_error.code, subject: limit_error.subject, detail: limit_error.detail}
%{code: {:ceiling, :bytes}, detail: nil, subject: []}

Next