Skip to main content

aap_protocol/
lib.rs

1//! # AAP — Agent Accountability Protocol
2//!
3//! The accountability layer MCP and A2A don't have.
4//!
5//! ```
6//! use aap_protocol::{KeyPair, Identity, Authorization, Level, Provenance, AuditChain, AuditResult};
7//!
8//! # fn main() -> aap_protocol::Result<()> {
9//! let supervisor = KeyPair::generate();
10//! let agent      = KeyPair::generate();
11//!
12//! let identity = Identity::new(
13//!     "aap://acme/worker/bot@1.0.0",
14//!     vec!["write:files".into()],
15//!     &agent, &supervisor,
16//!     "did:key:z6MkSupervisor",
17//! )?;
18//!
19//! let auth = Authorization::new(
20//!     &identity.id,
21//!     Level::Supervised,
22//!     vec!["write:files".into()],
23//!     false, // not physical
24//!     &supervisor,
25//!     "did:key:z6MkSupervisor",
26//! )?;
27//!
28//! assert!(auth.is_valid());
29//! # Ok(())
30//! # }
31//! ```
32//!
33//! ## Physical World Rule
34//!
35//! ```
36//! # use aap_protocol::{KeyPair, Authorization, Level, AAPError};
37//! # let supervisor = KeyPair::generate();
38//! let result = Authorization::new(
39//!     "aap://factory/robot/arm@1.0.0",
40//!     Level::Autonomous,   // Level 4
41//!     vec!["move:arm".into()],
42//!     true,                // physical = true
43//!     &supervisor,
44//!     "did:key:z6Mk",
45//! );
46//! assert!(matches!(result, Err(AAPError::PhysicalWorldViolation { .. })));
47//! ```
48
49mod crypto;
50mod errors;
51mod identity;
52mod authorization;
53mod provenance;
54mod audit;
55
56pub use crypto::{KeyPair, verify_signature, sha256_of};
57pub use errors::{AAPError, Result};
58pub use identity::Identity;
59pub use authorization::{Authorization, Level};
60pub use provenance::Provenance;
61pub use audit::{AuditChain, AuditEntry, AuditResult};