agent-alignment-protocol 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aap/__init__.py +158 -0
- aap/cli/__init__.py +12 -0
- aap/cli/main.py +635 -0
- aap/py.typed +0 -0
- aap/schemas/__init__.py +127 -0
- aap/schemas/alignment_card.py +306 -0
- aap/schemas/ap_trace.py +280 -0
- aap/schemas/value_coherence.py +336 -0
- aap/tracing.py +734 -0
- aap/verification/__init__.py +112 -0
- aap/verification/api.py +500 -0
- aap/verification/constants.py +61 -0
- aap/verification/divergence.py +337 -0
- aap/verification/features.py +405 -0
- aap/verification/models.py +260 -0
- aap/verification/ssm.py +179 -0
- agent_alignment_protocol-0.1.0.dist-info/METADATA +373 -0
- agent_alignment_protocol-0.1.0.dist-info/RECORD +21 -0
- agent_alignment_protocol-0.1.0.dist-info/WHEEL +4 -0
- agent_alignment_protocol-0.1.0.dist-info/entry_points.txt +2 -0
- agent_alignment_protocol-0.1.0.dist-info/licenses/LICENSE +191 -0
aap/__init__.py
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""Agent Alignment Protocol (AAP) — The missing alignment layer for the agent protocol stack.
|
|
2
|
+
|
|
3
|
+
AAP provides three core capabilities:
|
|
4
|
+
1. Alignment Card: Declare alignment posture (values, autonomy, audit commitment)
|
|
5
|
+
2. AP-Trace: Audit agent decisions (alternatives, reasoning, escalation)
|
|
6
|
+
3. Verification: Verify behavior against declarations, detect drift
|
|
7
|
+
|
|
8
|
+
Quick Start:
|
|
9
|
+
from aap import AlignmentCard, APTrace, verify_trace, detect_drift
|
|
10
|
+
|
|
11
|
+
# Verify a trace against a card
|
|
12
|
+
result = verify_trace(trace_dict, card_dict)
|
|
13
|
+
if not result.verified:
|
|
14
|
+
for violation in result.violations:
|
|
15
|
+
print(f"VIOLATION: {violation.type}")
|
|
16
|
+
|
|
17
|
+
# Check coherence between two agents
|
|
18
|
+
from aap import check_coherence
|
|
19
|
+
coherence = check_coherence(my_card_dict, their_card_dict)
|
|
20
|
+
if coherence.proceed:
|
|
21
|
+
# Safe to coordinate
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
# Detect drift over time
|
|
25
|
+
alerts = detect_drift(card_dict, list_of_traces)
|
|
26
|
+
for alert in alerts:
|
|
27
|
+
print(f"DRIFT: {alert.analysis.drift_direction}")
|
|
28
|
+
|
|
29
|
+
# Instrument your agent with automatic tracing
|
|
30
|
+
from aap import trace_decision, TracedResult
|
|
31
|
+
|
|
32
|
+
@trace_decision(card_path="alignment-card.json")
|
|
33
|
+
def recommend_product(query: str) -> Product:
|
|
34
|
+
return find_best_product(query)
|
|
35
|
+
|
|
36
|
+
See docs/SPEC.md for the full protocol specification.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
__version__ = "0.1.0"
|
|
40
|
+
|
|
41
|
+
# Core verification API
|
|
42
|
+
# Schema models
|
|
43
|
+
from aap.schemas import (
|
|
44
|
+
# AP-Trace
|
|
45
|
+
Action,
|
|
46
|
+
ActionCategory,
|
|
47
|
+
ActionType,
|
|
48
|
+
# Alignment Card
|
|
49
|
+
AlignmentCard,
|
|
50
|
+
# Value Coherence Handshake
|
|
51
|
+
AlignmentCardRequest,
|
|
52
|
+
AlignmentCardResponse,
|
|
53
|
+
Alternative,
|
|
54
|
+
APTrace,
|
|
55
|
+
AuditCommitment,
|
|
56
|
+
AutonomyEnvelope,
|
|
57
|
+
CoherenceResultMessage,
|
|
58
|
+
Decision,
|
|
59
|
+
Escalation,
|
|
60
|
+
EscalationTrigger,
|
|
61
|
+
Principal,
|
|
62
|
+
PrincipalType,
|
|
63
|
+
ProposedCollaboration,
|
|
64
|
+
RelationshipType,
|
|
65
|
+
TraceContext,
|
|
66
|
+
TriggerAction,
|
|
67
|
+
ValueCoherenceCheck,
|
|
68
|
+
Values,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Tracing decorators
|
|
72
|
+
from aap.tracing import (
|
|
73
|
+
AlignmentViolationError,
|
|
74
|
+
TraceConfig,
|
|
75
|
+
TracedResult,
|
|
76
|
+
TraceHandler,
|
|
77
|
+
clear_trace_store,
|
|
78
|
+
get_trace_store,
|
|
79
|
+
mcp_traced,
|
|
80
|
+
trace_decision,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# Verification result models
|
|
84
|
+
from aap.verification import (
|
|
85
|
+
CoherenceResult,
|
|
86
|
+
DriftAlert,
|
|
87
|
+
DriftAnalysis,
|
|
88
|
+
DriftDirection,
|
|
89
|
+
DriftIndicator,
|
|
90
|
+
Severity,
|
|
91
|
+
ValueAlignment,
|
|
92
|
+
ValueConflict,
|
|
93
|
+
VerificationMetadata,
|
|
94
|
+
VerificationResult,
|
|
95
|
+
Violation,
|
|
96
|
+
ViolationType,
|
|
97
|
+
Warning,
|
|
98
|
+
check_coherence,
|
|
99
|
+
detect_drift,
|
|
100
|
+
verify_trace,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
__all__ = [
|
|
104
|
+
# Version
|
|
105
|
+
"__version__",
|
|
106
|
+
# Core API
|
|
107
|
+
"verify_trace",
|
|
108
|
+
"check_coherence",
|
|
109
|
+
"detect_drift",
|
|
110
|
+
# Tracing Decorators
|
|
111
|
+
"trace_decision",
|
|
112
|
+
"mcp_traced",
|
|
113
|
+
"TracedResult",
|
|
114
|
+
"TraceConfig",
|
|
115
|
+
"TraceHandler",
|
|
116
|
+
"AlignmentViolationError",
|
|
117
|
+
"get_trace_store",
|
|
118
|
+
"clear_trace_store",
|
|
119
|
+
# Verification Results
|
|
120
|
+
"VerificationResult",
|
|
121
|
+
"Violation",
|
|
122
|
+
"ViolationType",
|
|
123
|
+
"Warning",
|
|
124
|
+
"Severity",
|
|
125
|
+
"VerificationMetadata",
|
|
126
|
+
"CoherenceResult",
|
|
127
|
+
"ValueAlignment",
|
|
128
|
+
"ValueConflict",
|
|
129
|
+
"DriftAlert",
|
|
130
|
+
"DriftAnalysis",
|
|
131
|
+
"DriftDirection",
|
|
132
|
+
"DriftIndicator",
|
|
133
|
+
# Alignment Card
|
|
134
|
+
"AlignmentCard",
|
|
135
|
+
"Principal",
|
|
136
|
+
"PrincipalType",
|
|
137
|
+
"RelationshipType",
|
|
138
|
+
"Values",
|
|
139
|
+
"AutonomyEnvelope",
|
|
140
|
+
"EscalationTrigger",
|
|
141
|
+
"TriggerAction",
|
|
142
|
+
"AuditCommitment",
|
|
143
|
+
# AP-Trace
|
|
144
|
+
"APTrace",
|
|
145
|
+
"Action",
|
|
146
|
+
"ActionType",
|
|
147
|
+
"ActionCategory",
|
|
148
|
+
"Alternative",
|
|
149
|
+
"Decision",
|
|
150
|
+
"Escalation",
|
|
151
|
+
"TraceContext",
|
|
152
|
+
# Value Coherence
|
|
153
|
+
"AlignmentCardRequest",
|
|
154
|
+
"AlignmentCardResponse",
|
|
155
|
+
"ValueCoherenceCheck",
|
|
156
|
+
"CoherenceResultMessage",
|
|
157
|
+
"ProposedCollaboration",
|
|
158
|
+
]
|
aap/cli/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""AAP Command Line Interface.
|
|
2
|
+
|
|
3
|
+
Provides CLI tools for working with the Agent Alignment Protocol:
|
|
4
|
+
- aap init: Create a new Alignment Card
|
|
5
|
+
- aap verify: Verify traces against an Alignment Card
|
|
6
|
+
- aap check-coherence: Check compatibility between two Alignment Cards
|
|
7
|
+
- aap drift: Detect behavioral drift from declared alignment
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from aap.cli.main import main
|
|
11
|
+
|
|
12
|
+
__all__ = ["main"]
|