Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 71 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,85 @@ pip install agent-passport-system

## Quick Start

Lead with the minimum you need to get a signed passport and a verifiable delegation: identity, delegation, and policy evaluation. Import the rest from `agent_passport` when you need it. Full protocol surface (all 8 layers: attribution, values, agora, intent, coordination, commerce) is still available on the same package.
This program issues an `AuthorityDelegationV1` grant, verifies it with an explicit clock, key resolver, root trust policy and revocation resolver, reserves spend through a verifier bound to the budget ledger, then revokes the grant. It was run against the published 5.0.0 wheel and printed the output below. `generate_key_pair()` returns the keys `publicKey` and `privateKey`. The older `create_passport` and `create_delegation` functions produce the pre-draft compatibility formats.

```python
from agent_passport import (
generate_key_pair, create_passport, sign_passport, verify_passport,
create_delegation, verify_delegation, create_action_receipt,
# full surface available, import more when you need it:
# build_merkle_root, load_floor, attest_floor, evaluate_compliance, ...
AuthorityVerifierConfig, InMemoryAuthorityBudgetLedger, create_authority_chain_verifier,
generate_key_pair, verify_authority_chain_for_budget,
)

# Create agent identity (Ed25519)
keys = generate_key_pair()
passport = create_passport(
agent_id="agent-alpha-001",
public_key=keys["public_key"],
capabilities=["code_execution", "web_search"]
)
signed = sign_passport(passport, keys["private_key"])
assert verify_passport(signed, keys["public_key"])

# Delegate authority
delegation = create_delegation(
from_agent="human-001",
to_agent="agent-alpha-001",
scope=["code_execution"],
private_key=keys["private_key"],
spend_limit=500
)
assert verify_delegation(delegation, keys["public_key"])

# Record work as signed receipt
receipt = create_action_receipt(
agent_id="agent-alpha-001",
delegation_id=delegation["id"],
action="code_execution",
scope_used="code_execution",
private_key=keys["private_key"],
spend=50,
result="success",
description="Implemented feature X"
from agent_passport.v2.authority_delegation import issue_authority_delegation, verify_authority_delegation
from agent_passport.v2.authority_revocation import (
InMemoryAuthorityRevocationStore, create_authority_revocation_resolver,
issue_authority_revocation, record_authority_revocation,
)

# Merkle proofs for attribution
hashes = [receipt["receipt_hash"]]
root = build_merkle_root(hashes)
proof = get_merkle_proof(hashes, hashes[0])
assert verify_merkle_proof(hashes[0], proof, root)
principal = generate_key_pair()
PRINCIPAL, PRINCIPAL_VM = "did:example:principal", "did:example:principal#key-1"

grant = issue_authority_delegation({
"record_type": "aps:authority-delegation:v1", "version": "1.0", "parent_delegation_id": None,
"issuer": PRINCIPAL, "subject": "did:example:agent", "verification_method": PRINCIPAL_VM,
"issued_at": "2026-10-28T09:00:00.000Z", "nonce": "00000000000000000000000000000001",
"authority": {
"scope": {"profile": "aps-hierarchical-v1", "grants": ["notes:read:*"]},
"spend": {"mode": "bounded", "unit": "example:credit", "per_action": "5", "cumulative": "10"},
"depth": {"remaining": 0},
"time": {"not_before": "2026-10-28T09:00:00.000Z", "not_after": "2026-10-28T17:00:00.000Z"},
"reputation": {"profile": "aps-score-0-100-v1", "ceiling": 100},
"values": {"profile": "aps-values-identifiers-v1", "required": []},
"reversibility": {"profile": "aps-tci-v1", "ceiling": "compensable"},
},
}, principal["privateKey"])

def resolve_key(issuer, verification_method, issued_at):
if issuer == PRINCIPAL and verification_method == PRINCIPAL_VM:
return principal["publicKey"]
return {"outcome": "not_found"}

store = InMemoryAuthorityRevocationStore()
store.track(grant["delegation_id"])
resolve_revocation = create_authority_revocation_resolver(store, resolve_verification_key=resolve_key)

def check(now):
r = verify_authority_delegation(grant, now=now, resolve_verification_key=resolve_key,
trust_root=lambda root: root["issuer"] == PRINCIPAL, resolve_revocation=resolve_revocation)
return r.state, [f.code for f in r.failures]

print("check at 10:00", check("2026-10-28T10:00:00.000Z"))
print("check at 18:00", check("2026-10-28T18:00:00.000Z"))
# Budget reservations take a handle from the ledger's own verifier.
def reserve(now, action_ref):
verifier = create_authority_chain_verifier(AuthorityVerifierConfig(
"example-policy", "in-memory", lambda: now, resolve_key,
lambda root: root["issuer"] == PRINCIPAL, resolve_revocation))
checked = verify_authority_chain_for_budget([grant], verifier)
if not checked.ok:
return "no handle", [f.code for f in checked.result.failures]
ledger = InMemoryAuthorityBudgetLedger(verifier, now=lambda: now)
return ledger.reserve(checked.chain, action_ref, "example:credit", "5").code

print("reserve at 10:00", reserve("2026-10-28T10:00:00.000Z", "a" * 64))
revocation = issue_authority_revocation(grant, now="2026-10-28T10:05:00.000Z", revoker=PRINCIPAL,
verification_method=PRINCIPAL_VM, reason_code="task_complete",
nonce="000000000000000000000000000000aa", private_key=principal["privateKey"])
recorded = record_authority_revocation(store, grant, revocation, resolve_verification_key=resolve_key)
print("revocation recorded", recorded.recorded, recorded.verification.state)
print("check at 10:10", check("2026-10-28T10:10:00.000Z"))
print("reserve at 10:10", reserve("2026-10-28T10:10:00.000Z", "b" * 64))
```

```text
check at 10:00 ('valid', [])
check at 18:00 ('invalid', ['EXPIRED'])
reserve at 10:00 RESERVED
revocation recorded True valid
check at 10:10 ('invalid', ['REVOKED'])
reserve at 10:10 ('no handle', ['REVOKED'])
```

A verified handle records one verification. A handle obtained before a revocation still reserves until its validity window ends, unless the ledger is given `max_verification_age_ms`, so verify current authority again before dispatch. See [MIGRATION.md](MIGRATION.md) for the 5.0.0 budget API.

## What's Included

| Module | Layer | What It Does |
Expand Down
Loading