Models¶
This page documents the data models used by sigstore-a2a.
SignedAgentCard¶
The SignedAgentCard model represents a signed A2A Agent Card with its attestations.
SignedAgentCard
¶
Attestations¶
The Attestations model contains the signature bundle and optional provenance.
Attestations
¶
Bases: BaseModel
Verification material for Agent Card signatures.
SLSAProvenance¶
The SLSAProvenance model represents SLSA build provenance.
SLSAProvenance
¶
Bases: BaseModel
SLSA provenance attestation following SLSA v1.1 specification.
ProvenanceBuilder¶
The ProvenanceBuilder class helps construct SLSA provenance attestations.
ProvenanceBuilder
¶
Builds SLSA provenance attestations for Agent Cards.
Initialize provenance builder.
| PARAMETER | DESCRIPTION |
|---|---|
build_type
|
URI identifying the build type
TYPE:
|
Source code in sigstore_a2a/provenance.py
build_provenance
¶
build_provenance(
agent_card: AgentCard | dict[str, Any] | str | Path,
source_repo: str | None = None,
commit_sha: str | None = None,
workflow_ref: str | None = None,
builder_id: str | None = None,
external_params: dict[str, Any] | None = None,
) -> SLSAProvenance
Build complete SLSA provenance for an Agent Card.
| PARAMETER | DESCRIPTION |
|---|---|
agent_card
|
Agent card to create provenance for
TYPE:
|
source_repo
|
Source repository
TYPE:
|
commit_sha
|
Git commit SHA
TYPE:
|
workflow_ref
|
Workflow reference
TYPE:
|
builder_id
|
Builder identifier
TYPE:
|
external_params
|
Additional external parameters
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
SLSAProvenance
|
Complete SLSA provenance attestation |
Source code in sigstore_a2a/provenance.py
create_build_definition
¶
create_build_definition(
source_repo: str | None = None,
commit_sha: str | None = None,
workflow_ref: str | None = None,
external_params: dict[str, Any] | None = None,
) -> ProvenanceBuildDefinition
Create build definition from build context.
| PARAMETER | DESCRIPTION |
|---|---|
source_repo
|
Source repository (e.g., "owner/repo")
TYPE:
|
commit_sha
|
Git commit SHA
TYPE:
|
workflow_ref
|
Workflow reference
TYPE:
|
external_params
|
Additional external parameters
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ProvenanceBuildDefinition
|
Build definition |
Source code in sigstore_a2a/provenance.py
create_builder_identity
¶
create_builder_identity(
builder_id: str | None = None,
version: dict[str, str] | None = None,
) -> BuilderIdentity
Create builder identity.
| PARAMETER | DESCRIPTION |
|---|---|
builder_id
|
Unique identifier for the builder
TYPE:
|
version
|
Builder version information
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BuilderIdentity
|
Builder identity |
Source code in sigstore_a2a/provenance.py
create_subject
¶
create_subject(
agent_card: AgentCard | dict[str, Any] | str | Path,
name: str | None = None,
) -> ProvenanceSubject
Create provenance subject from Agent Card.
| PARAMETER | DESCRIPTION |
|---|---|
agent_card
|
Agent card to create subject for
TYPE:
|
name
|
Optional name for the subject (defaults to agent name)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ProvenanceSubject
|
Provenance subject with digests |
Source code in sigstore_a2a/provenance.py
Usage Examples¶
Working with SignedAgentCard¶
from sigstore_a2a.models.signature import SignedAgentCard
import json
# Load a signed card
with open("signed-card.json") as f:
data = json.load(f)
signed_card = SignedAgentCard.model_validate(data)
# Access the agent card
print(f"Agent: {signed_card.agent_card.name}")
print(f"URL: {signed_card.agent_card.url}")
# Access attestations
print(f"Has signature: {signed_card.attestations.signature_bundle is not None}")
print(f"Has provenance: {signed_card.attestations.provenance_bundle is not None}")
Building Provenance¶
from sigstore_a2a import ProvenanceBuilder
# From GitHub Actions environment
provenance = ProvenanceBuilder().from_github_actions().build()
# Manual construction
provenance = ProvenanceBuilder() \
.set_builder("https://github.com/sigstore/sigstore-a2a") \
.set_repository("owner/repo") \
.set_commit_sha("abc123") \
.set_workflow_ref(".github/workflows/release.yml") \
.build()
Serializing Models¶
import json
from sigstore_a2a import AgentCardSigner
signer = AgentCardSigner()
signed_card = signer.sign_agent_card("agent-card.json")
# Serialize to JSON
json_str = json.dumps(
signed_card.model_dump(by_alias=True),
indent=2,
default=str
)
# Save to file
with open("output.json", "w") as f:
f.write(json_str)