Skip to main content

Structural Authorization Gates — AgentMesh Adapter

AgentMesh adapter that consumes external policy decisions, trust grades, and delegation scope chains as AGT trust signals. Provides Ed25519 signature verification for incoming trust artifacts.

Features

  • TrustGrade: Six-level external grade enum (VERIFIED → REVOKED) mapped to AGT scores (0–1000)
  • TrustArtifact: Signed external policy decision with Ed25519 verification and canonical JSON payload
  • DelegationChain: Multi-hop scope chain validation (contiguity, scope narrowing, cycle detection, expiry)
  • AuthzGate: Trust-gated task authorization consuming artifacts and delegation chains
  • TrustTracker: Tracks agent trust scores from external authorization outcomes

Installation

# Without cryptographic verification (limited — verify_signature() returns False)
pip install structural-authz-agentmesh

# With Ed25519 signing and verification (recommended)
pip install 'structural-authz-agentmesh[crypto]'

Quick Start

from datetime import datetime, timedelta, timezone
from structural_authz_agentmesh import (
    AgentProfile, AuthzGate, TrustArtifact, TrustGrade, generate_keypair,
)

# Generate keys (dev/test only — use your PKI in production)
authority_priv, authority_pub = generate_keypair()

# Define an agent
agent = AgentProfile(
    did="did:authz:analyst",
    name="Data Analyst",
    capabilities=["read:data", "analyze:reports"],
    trust_score=700,
)

# Issue a signed trust artifact from your external authority
artifact = TrustArtifact.sign(
    did=agent.did,
    grade=TrustGrade.TRUSTED,
    scopes=["read:data", "analyze:reports"],
    expires_at=datetime.now(timezone.utc) + timedelta(hours=8),
    private_key_b64=authority_priv,
    issuer_public_key_b64=authority_pub,
    issuer_id="my-policy-authority",
)

# Evaluate authorization
gate = AuthzGate(min_trust_score=500)
decision = gate.evaluate(
    agent=agent,
    task="Generate quarterly report",
    artifact=artifact,
    required_scopes=["read:data", "analyze:reports"],
)

print(decision.allowed)   # True
print(decision.artifact_grade)  # TrustGrade.TRUSTED

Delegation Scope Chains

from structural_authz_agentmesh import DelegationChain, DelegationLink

chain = DelegationChain(
    root_did="did:authz:analyst",
    root_scopes=["read:data", "analyze:reports"],
)

link = DelegationLink(
    delegator_did="did:authz:analyst",
    delegatee_did="did:authz:sub-analyst",
    scopes=["read:data"],          # must be a subset of root scopes
    delegator_public_key=analyst_pub,
    signature="...",               # Ed25519 signature from delegator
    expires_at=datetime.now(timezone.utc) + timedelta(hours=2),
)
chain.add_link(link)

valid, reason = chain.validate(required_scopes=["read:data"])

Trust Score Tracking

from structural_authz_agentmesh import TrustTracker

tracker = TrustTracker(success_reward=10, failure_penalty=50)
tracker.record_success(agent, task="Generate quarterly report")
tracker.record_failure(agent, task="Delete records", reason="Unauthorized scope")

history = tracker.get_history(did=agent.did)

Trust Grade → AGT Score Mapping

Grade AGT Score Meaning
VERIFIED 950 Fully attested, cryptographically proven
TRUSTED 750 Policy-approved, no flags
PROVISIONAL 500 Conditionally approved, pending attestation
RESTRICTED 300 Allowed but scope-limited
UNTRUSTED 100 Policy denied
REVOKED 0 Previously trusted, now invalidated — always blocked

Running Tests

pip install -e '.[dev]'
pytest

Metadata

Release files for structural_authz_agentmesh 3.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structural_authz_agentmesh 3.6.0
File Size Uploaded Provenance Actions
structural_authz_agentmesh-3.6.0.tar.gz 11.4 kB Without provenance Details for structural_authz_agentmesh-3.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for structural_authz_agentmesh 3.6.0
File Interpreter ABI Platform Actions
structural_authz_agentmesh-3.6.0-py3-none-any.whl Python 3 none any Details for structural_authz_agentmesh-3.6.0-py3-none-any.whl

Total release size: 20.3 kB

Release files / structural_authz_agentmesh-3.6.0.tar.gz

Download URL structural_authz_agentmesh-3.6.0.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e56120db582c714ab157e9ff21d7b48fe1d1cf1e94e6e462c452e85733f77dac
BLAKE2b-256 checksum
How to use checksums
8ffd83382d8179f5e3140c7f4450ff1c6b320b7bd9e9e37c73f3f19e4f0fe258
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / structural_authz_agentmesh-3.6.0-py3-none-any.whl

Download URL structural_authz_agentmesh-3.6.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4212f234413286fb908b3531043a41ce105ab2d125071c5f9c71361739a855ab
BLAKE2b-256 checksum
How to use checksums
1d34b04e236af9c7cf27bd5de4b4ee97d9eb10ee3eaa5381aab33e00a356681e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Security for structural_authz_agentmesh 3.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page