Producing artifacts
This notebook starts with the shipped Blueprint and Deployment Manifest, changes their values, recomputes their digests, signs both with a throwaway key, reconciles the pair, and saves canonical files for CI.
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 the shipped examples from the installed package or the current source checkout.
true = File.regular?(Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json"))
%{example_files_found?: true}%{example_files_found?: true}Tagged JSON and the producer sequence
| JSON | Elixir tagged value |
|---|---|
null | :null |
true | {:boolean, true} |
3 / 1.5 | {:integer, 3} / {:float, 1.5} |
"hello" | {:string, "hello"} |
[3] | {:array, [{:integer, 3}]} |
{"ready": true} | {:object, [{"ready", {:boolean, true}}]} |
Objects use ordered member lists so the decoder can retain order and reject duplicates before canonical encoding; an Elixir map is not a tagged JSON object. Json.decode/1 converts ordinary JSON to this representation.
from_value/2 constructs a structurally valid, portable draft, even while its declared digest still belongs to an earlier value. Compute the new digest, insert it, encode canonical bytes, and decode those bytes to check the completed artifact. Then sign its digest. Signatures are excluded from the content digest, so attaching one does not change it.
The template supplies every required member. Producers edit their identity, release number, ports, schemas, capabilities, effects, assertions, ceilings, and extensions to describe their own contract. The Manifest must identify that exact Blueprint release; its adapters, bindings, build identities, policies, timestamps, and host bounds describe the intended environment. This lesson changes only release number and model tokens, keeping the other fixture values coherent.
Formatted JSON is for reading. Artifact decoding requires canonical bytes, including no added trailing newline. Decode ordinary JSON with Json.decode/1 and encode the tagged value with Canonicalization.encode/1; content changes also require recomputing the artifact digest and recreating affected signatures.
Change the Blueprint and compute its digest
The Blueprint value comes from the shipped example. This cell changes its release number, validates the value, recomputes and inserts the content digest, and encodes canonical bytes.
alias AgentBlueprintProtocol.{Blueprint, Canonicalization, Digest, Json}
put_member = fn {:object, members}, name, value ->
{:object, List.keystore(members, name, 0, {name, value})}
end
replace_path = fn replace_path, {:object, members}, [name | rest], value ->
if rest == [] do
put_member.({:object, members}, name, value)
else
{^name, nested} = List.keyfind(members, name, 0)
updated = replace_path.(replace_path, nested, rest, value)
put_member.({:object, members}, name, updated)
end
end
blueprint_path = Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-blueprint.json")
{:ok, blueprint_value} = File.read!(blueprint_path) |> Json.decode()
{:ok, original_blueprint} = Blueprint.from_value(blueprint_value)
original_digest = original_blueprint |> Blueprint.content_digest() |> Digest.to_tagged()
blueprint_value = put_member.(blueprint_value, "release_number", {:integer, 2})
{:ok, blueprint_draft} = Blueprint.from_value(blueprint_value)
blueprint_digest = blueprint_draft |> Blueprint.content_digest() |> Digest.to_tagged()
blueprint_value =
put_member.(blueprint_value, "content_digest", {:string, blueprint_digest})
{:ok, blueprint_bytes} = Canonicalization.encode(blueprint_value)
{:ok, blueprint} = AgentBlueprintProtocol.decode_blueprint(blueprint_bytes)
{:ok, ^blueprint_bytes} = AgentBlueprintProtocol.canonical_bytes(blueprint)
%{
release_number: 2,
digest_changed: original_digest != blueprint_digest,
digest: blueprint_digest,
canonical_byte_size: byte_size(blueprint_bytes)
}%{
digest: "sha-256:RN6KYFSvPFYnoQj5dqA8B2_tjjm2bYGfwCpSYGqmMIE",
release_number: 2,
digest_changed: true,
canonical_byte_size: 1361
}Change the Deployment Manifest
The manifest now points to the changed Blueprint release and digest. It also changes one model-policy value before computing its own digest.
alias AgentBlueprintProtocol.Deployment
deployment_path = Application.app_dir(:agent_blueprint_protocol, "priv/examples/echo-deployment.json")
{:ok, deployment_value} = File.read!(deployment_path) |> Json.decode()
deployment_value =
replace_path.(
replace_path,
deployment_value,
["blueprint_release", "release_number"],
{:integer, 2}
)
|> then(
&replace_path.(
replace_path,
&1,
["blueprint_release", "content_digest"],
{:string, blueprint_digest}
)
)
|> then(&replace_path.(replace_path, &1, ["model_policy", "max_tokens"], {:integer, 40_000}))
{:ok, deployment_draft} = Deployment.from_value(deployment_value)
deployment_digest = deployment_draft |> Deployment.content_digest() |> Digest.to_tagged()
deployment_value =
put_member.(deployment_value, "deployment_digest", {:string, deployment_digest})
{:ok, deployment_bytes} = Canonicalization.encode(deployment_value)
{:ok, deployment} = AgentBlueprintProtocol.decode_deployment(deployment_bytes)
%{
digest: deployment_digest,
binds_changed_release: Deployment.binds?(deployment, blueprint),
canonical_byte_size: byte_size(deployment_bytes)
}%{
digest: "sha-256:F9n_bnRsD_pTbtsFk6uwRgx3pgQpDfGcXNVRhvwyBcs",
canonical_byte_size: 2539,
binds_changed_release: true
}Sign with Ed25519
The producer creates a throwaway Ed25519 key with Erlang/OTP's :crypto module. The protected header uses Ed25519, and the signature is attached to the Blueprint value. No key bytes are printed.
(
alias AgentBlueprintProtocol.{Base64Url, Signature}
alias AgentBlueprintProtocol.Signature.PublicKey
{public_key, private_key} = :crypto.generate_key(:eddsa, :ed25519)
protected =
{:object,
[
{"alg", {:string, "Ed25519"}},
{"b64", {:boolean, false}},
{"crit", {:array, [{:string, "b64"}]}},
{"kid", {:string, "example-producer-key"}}
]}
signed_attributes =
{:object,
[
{"algorithm", {:string, "Ed25519"}},
{"content_digest", {:string, blueprint_digest}},
{"created_at", {:string, "2026-08-20T00:00:00Z"}},
{"key_id", {:string, "example-producer-key"}},
{"purpose", {:string, "blueprint"}}
]}
entry_with = fn header, signature_bytes ->
{:object,
[
{"protected", header},
{"signed_attributes", signed_attributes},
{"signature", {:string, Base64Url.encode(signature_bytes)}}
]}
end
unsigned_entry = entry_with.(protected, <<0::512>>)
{:ok, signing_input} = Signature.signing_input(unsigned_entry)
signature_bytes = :crypto.sign(:eddsa, :none, signing_input, [private_key, :ed25519])
entry = entry_with.(protected, signature_bytes)
public_key_record = %PublicKey{
key_id: "example-producer-key",
algorithm: :ed25519,
key: public_key
}
{:ok, signed_bytes} =
blueprint
|> Blueprint.to_value()
|> put_member.("signatures", {:array, [entry]})
|> Canonicalization.encode()
{:ok, signed_blueprint} = AgentBlueprintProtocol.decode_blueprint(signed_bytes)
{:ok, ^signed_bytes} = AgentBlueprintProtocol.canonical_bytes(signed_blueprint)
%{
signature_verifies:
match?({:ok, %Signature.Attributes{}}, Signature.verify(entry, [public_key_record])),
digest_unchanged:
Digest.to_tagged(Blueprint.content_digest(signed_blueprint)) == blueprint_digest,
canonical_round_trip: true
}
)%{canonical_round_trip: true, signature_verifies: true, digest_unchanged: true}Accept the EdDSA header spelling
The protected header also accepts the EdDSA spelling. The signed attributes keep the Ed25519 algorithm name.
Sign the same input with the EdDSA protected-header spelling and verify it with the same public key.
(
eddsa_header =
put_member.(protected, "alg", {:string, "EdDSA"})
eddsa_entry = entry_with.(eddsa_header, <<0::512>>)
{:ok, eddsa_input} = Signature.signing_input(eddsa_entry)
eddsa_signature = :crypto.sign(:eddsa, :none, eddsa_input, [private_key, :ed25519])
eddsa_entry = entry_with.(eddsa_header, eddsa_signature)
%{
eddsa_header_verifies:
match?({:ok, %Signature.Attributes{}}, Signature.verify(eddsa_entry, [public_key_record]))
}
)%{eddsa_header_verifies: true}Sign the matching Manifest and reconcile the pair
The Manifest signs its own digest with purpose deployment. Reconciliation checks both signatures and compares their digests with the artifacts. The bounds here are fixture host configuration; a consuming application supplies independent configured limits. No private or public key material is printed.
(
deployment_attributes =
signed_attributes
|> put_member.("content_digest", {:string, deployment_digest})
|> put_member.("purpose", {:string, "deployment"})
deployment_entry =
entry
|> put_member.("signed_attributes", deployment_attributes)
|> put_member.("signature", {:string, Base64Url.encode(<<0::512>>)})
{:ok, deployment_input} = Signature.signing_input(deployment_entry)
deployment_signature = :crypto.sign(:eddsa, :none, deployment_input, [private_key, :ed25519])
deployment_entry =
put_member.(deployment_entry, "signature", {:string, Base64Url.encode(deployment_signature)})
{:ok, signed_deployment_bytes} =
deployment
|> Deployment.to_value()
|> put_member.("signatures", {:array, [deployment_entry]})
|> Canonicalization.encode()
{:ok, signed_deployment} = AgentBlueprintProtocol.decode_deployment(signed_deployment_bytes)
{:ok, attributes} = Signature.verify(deployment_entry, [public_key_record])
true = attributes.purpose == :deployment
true = Digest.to_tagged(attributes.content_digest) == deployment_digest
alias AgentBlueprintProtocol.{BoundsAlgebra, Evidence, Reconcile}
{:ok, host_bounds} = BoundsAlgebra.from_deployment(signed_deployment)
inputs = %Reconcile.Inputs{
host_bounds: host_bounds,
support: %AgentBlueprintProtocol.Negotiation.Support{revisions: MapSet.new([1])},
keys: [public_key_record],
protected_clamp: :acknowledge,
observations: %Deployment.Observations{}
}
{:ok, pair_evidence} =
AgentBlueprintProtocol.reconcile(signed_blueprint, signed_deployment, inputs)
signature_subjects =
Enum.map(["blueprint", "deployment"], fn artifact ->
check =
Enum.find(pair_evidence.checks, &(&1.surface == :signatures and &1.subject == [artifact]))
%{verified: true, detail: %Evidence.Signatures{key_ids: ids}} = check
{artifact, ids}
end)
# Reconcile once with the unsigned Manifest to show subject-aware coverage.
{:ok, mixed_evidence} = AgentBlueprintProtocol.reconcile(signed_blueprint, deployment, inputs)
%{
signed_subjects: signature_subjects,
pair_signatures_unverified: :signatures in pair_evidence.not_verified,
mixed_signatures_unverified: :signatures in mixed_evidence.not_verified
}
)%{
signed_subjects: [
{"blueprint", ["example-producer-key"]},
{"deployment", ["example-producer-key"]}
],
pair_signatures_unverified: false,
mixed_signatures_unverified: true
}The fully signed pair still leaves descriptor observations, binding freshness, and host-owned surfaces unverified. The mixed pair leaves the global signatures surface unverified because its Manifest is unsigned.
Save and reload the deliverables
This creates a named user output directory, abp-artifacts, in the runtime's current directory. Choose a new directory name for a new run; the cell refuses to overwrite existing artifacts. With a remote Livebook runtime, download these two files from that runtime to use them in your project. The signing key stays in memory and is not written.
output_dir = Path.expand("abp-artifacts")
:ok = File.mkdir(output_dir)
System.at_exit(fn _status -> File.rm_rf!(output_dir) end)
blueprint_output = Path.join(output_dir, "blueprint.json")
deployment_output = Path.join(output_dir, "deployment.json")
:ok = File.write(blueprint_output, signed_bytes)
:ok = File.write(deployment_output, signed_deployment_bytes)
{:ok, reloaded_blueprint} = AgentBlueprintProtocol.decode_blueprint(File.read!(blueprint_output))
{:ok, reloaded_deployment} =
AgentBlueprintProtocol.decode_deployment(File.read!(deployment_output))
{:ok, ^signed_bytes} = AgentBlueprintProtocol.canonical_bytes(reloaded_blueprint)
{:ok, ^signed_deployment_bytes} = AgentBlueprintProtocol.canonical_bytes(reloaded_deployment)
{:ok, _reloaded_evidence} =
AgentBlueprintProtocol.reconcile(reloaded_blueprint, reloaded_deployment, inputs)
%{files: ["abp-artifacts/blueprint.json", "abp-artifacts/deployment.json"], reloaded_pair: true}%{
files: ["abp-artifacts/blueprint.json", "abp-artifacts/deployment.json"],
reloaded_pair: true
}With Node.js 24 or newer, run these commands from the directory containing abp-artifacts:
npx @agent-blueprint-protocol/verifier@1.1.0 --artifact abp-artifacts/blueprint.json
npx @agent-blueprint-protocol/verifier@1.1.0 --artifact abp-artifacts/deployment.json
Both print a valid artifact report and exit 0. This CLI mode performs decoding checks. It does not use keys or reconcile the pair. The CI guide adds those checks when required. Download or copy the files into your project before closing the runtime. The walkthrough owns abp-artifacts and removes it on runtime exit; run the CLI while the runtime remains open.
Three producer errors
These examples show the typed error value for a missing artifact shape, an unsupported member, and a nonportable value.
alias AgentBlueprintProtocol.Error
missing_blueprint = Blueprint.from_value({:object, []})
unknown_member = AgentBlueprintProtocol.decode_blueprint(~s({"unknown":true}))
portable_value =
AgentBlueprintProtocol.Portability.scan({:object, [{"credential", {:string, "example"}}]})
errors =
Enum.map([missing_blueprint, unknown_member, portable_value], fn
{:error, %Error{} = error} -> error
other -> other
end)
errors[
%AgentBlueprintProtocol.Error{
code: :missing_required_field,
detail: nil,
subject: ["blueprint_id"]
},
%AgentBlueprintProtocol.Error{code: :unknown_member, detail: nil, subject: []},
%AgentBlueprintProtocol.Error{code: :forbidden_portable_value, detail: nil, subject: []}
]