AgentMesh adapter for structural authorization gates — consumes external policy decisions, trust grades, and delegation scope chains as AGT trust signals
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file structural_authz_agentmesh-3.4.0.tar.gz.
File metadata
- Download URL: structural_authz_agentmesh-3.4.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d86056322ecd64b24675eaf2a2edfab286d9c235151fa11c6f5c5eca0380fa0
|
|
| MD5 |
d2b309d332ad6923f33c9666646cdf20
|
|
| BLAKE2b-256 |
374bd568c5cd7dbb1bf28b95d6ce422ba8a84d304899a25abede9d00d8f446ad
|
File details
Details for the file structural_authz_agentmesh-3.4.0-py3-none-any.whl.
File metadata
- Download URL: structural_authz_agentmesh-3.4.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: RestSharp/106.13.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c80756968e20b7257370d9efaf4263e8d7460137dd110cba13fdc382d1de0890
|
|
| MD5 |
9814320dedc534c3effd458719a2eb80
|
|
| BLAKE2b-256 |
18e2f0d84e2f7ca9c9cd6010edf471f687b1d1cfc91e652179ca3905e4ed1631
|