agent-alignment-protocol 0.1.0__tar.gz

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.
Files changed (24) hide show
  1. agent_alignment_protocol-0.1.0/.gitignore +64 -0
  2. agent_alignment_protocol-0.1.0/LICENSE +191 -0
  3. agent_alignment_protocol-0.1.0/PKG-INFO +373 -0
  4. agent_alignment_protocol-0.1.0/README.md +333 -0
  5. agent_alignment_protocol-0.1.0/pyproject.toml +103 -0
  6. agent_alignment_protocol-0.1.0/schemas/alignment-card.schema.json +475 -0
  7. agent_alignment_protocol-0.1.0/schemas/ap-trace.schema.json +526 -0
  8. agent_alignment_protocol-0.1.0/schemas/value-coherence.schema.json +545 -0
  9. agent_alignment_protocol-0.1.0/src/aap/__init__.py +158 -0
  10. agent_alignment_protocol-0.1.0/src/aap/cli/__init__.py +12 -0
  11. agent_alignment_protocol-0.1.0/src/aap/cli/main.py +635 -0
  12. agent_alignment_protocol-0.1.0/src/aap/py.typed +0 -0
  13. agent_alignment_protocol-0.1.0/src/aap/schemas/__init__.py +127 -0
  14. agent_alignment_protocol-0.1.0/src/aap/schemas/alignment_card.py +306 -0
  15. agent_alignment_protocol-0.1.0/src/aap/schemas/ap_trace.py +280 -0
  16. agent_alignment_protocol-0.1.0/src/aap/schemas/value_coherence.py +336 -0
  17. agent_alignment_protocol-0.1.0/src/aap/tracing.py +734 -0
  18. agent_alignment_protocol-0.1.0/src/aap/verification/__init__.py +112 -0
  19. agent_alignment_protocol-0.1.0/src/aap/verification/api.py +500 -0
  20. agent_alignment_protocol-0.1.0/src/aap/verification/constants.py +61 -0
  21. agent_alignment_protocol-0.1.0/src/aap/verification/divergence.py +337 -0
  22. agent_alignment_protocol-0.1.0/src/aap/verification/features.py +405 -0
  23. agent_alignment_protocol-0.1.0/src/aap/verification/models.py +260 -0
  24. agent_alignment_protocol-0.1.0/src/aap/verification/ssm.py +179 -0
@@ -0,0 +1,64 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ !docs/playground/wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+
24
+ # Virtual environments
25
+ .venv/
26
+ venv/
27
+ ENV/
28
+ env/
29
+
30
+ # IDE
31
+ .idea/
32
+ .vscode/
33
+ *.swp
34
+ *.swo
35
+ *~
36
+
37
+ # Testing
38
+ .tox/
39
+ .nox/
40
+ .coverage
41
+ .coverage.*
42
+ htmlcov/
43
+ .pytest_cache/
44
+ .hypothesis/
45
+
46
+ # Type checking
47
+ .mypy_cache/
48
+ .dmypy.json
49
+ dmypy.json
50
+ .pytype/
51
+
52
+ # Docs
53
+ docs/_build/
54
+ site/
55
+
56
+ # OS
57
+ .DS_Store
58
+ Thumbs.db
59
+
60
+ # Environment
61
+ .env
62
+ .env.*
63
+ *.pem
64
+ *.key
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright
52
+ owner or by an individual or Legal Entity authorized to submit on
53
+ behalf of the copyright owner. For the purposes of this definition,
54
+ "submitted" means any form of electronic, verbal, or written
55
+ communication sent to the Licensor or its representatives, including
56
+ but not limited to communication on electronic mailing lists, source
57
+ code control systems, and issue tracking systems that are managed by,
58
+ or on behalf of, the Licensor for the purpose of discussing and
59
+ improving the Work, but excluding communication that is conspicuously
60
+ marked or otherwise designated in writing by the copyright owner as
61
+ "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 Mnemom LLC
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,373 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-alignment-protocol
3
+ Version: 0.1.0
4
+ Summary: Agent Alignment Protocol - The missing alignment layer for the agent protocol stack
5
+ Project-URL: Homepage, https://github.com/mnemom/aap
6
+ Project-URL: Documentation, https://github.com/mnemom/aap#readme
7
+ Project-URL: Repository, https://github.com/mnemom/aap.git
8
+ Project-URL: Issues, https://github.com/mnemom/aap/issues
9
+ Project-URL: Changelog, https://github.com/mnemom/aap/blob/main/CHANGELOG.md
10
+ Author-email: Alex Garden <alex@example.com>
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: a2a,agents,ai,alignment,audit,mcp,protocol,transparency
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.10
25
+ Requires-Dist: click>=8.0
26
+ Requires-Dist: jsonschema>=4.0
27
+ Requires-Dist: pydantic>=2.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: mypy>=1.8; extra == 'dev'
30
+ Requires-Dist: pre-commit>=3.6; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
32
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
33
+ Requires-Dist: pytest>=8.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.2; extra == 'dev'
35
+ Provides-Extra: docs
36
+ Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
37
+ Requires-Dist: mkdocs>=1.5; extra == 'docs'
38
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == 'docs'
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Agent Alignment Protocol (AAP)
42
+
43
+ [![CI](https://github.com/mnemom/aap/actions/workflows/ci.yml/badge.svg)](https://github.com/mnemom/aap/actions/workflows/ci.yml)
44
+ [![CodeQL](https://github.com/mnemom/aap/actions/workflows/codeql.yml/badge.svg)](https://github.com/mnemom/aap/actions/workflows/codeql.yml)
45
+ [![codecov](https://codecov.io/gh/mnemom/aap/graph/badge.svg?token=9KCOCI5SC5)](https://codecov.io/gh/mnemom/aap)
46
+ [![PyPI](https://img.shields.io/pypi/v/agent-alignment-protocol.svg)](https://pypi.org/project/agent-alignment-protocol/)
47
+ [![npm](https://img.shields.io/npm/v/agent-alignment-protocol.svg)](https://www.npmjs.com/package/agent-alignment-protocol)
48
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
49
+ [![Spec](https://img.shields.io/badge/spec-v0.1.0-green.svg)](docs/SPEC.md)
50
+
51
+ **A transparency protocol for autonomous agents.**
52
+
53
+ AAP lets agents declare their alignment posture, produce auditable decision traces, and verify value coherence before coordinating with other agents. It extends existing protocols (A2A, MCP) with an alignment layer that makes agent behavior observable.
54
+
55
+ > AAP is a transparency protocol, not a trust protocol. It makes agent behavior more observable, not more guaranteed.
56
+
57
+ ## Quick Start
58
+
59
+ ```bash
60
+ # Install
61
+ pip install agent-alignment-protocol
62
+
63
+ # Generate an Alignment Card
64
+ aap init --values "principal_benefit,transparency,harm_prevention"
65
+ # ✓ Created alignment-card.json
66
+
67
+ # Instrument your agent
68
+ ```
69
+
70
+ ```python
71
+ from aap import trace_decision
72
+
73
+ @trace_decision(card_path="alignment-card.json")
74
+ def recommend_product(user_preferences):
75
+ # Your agent logic here
76
+ # Decisions are automatically traced
77
+ ...
78
+ ```
79
+
80
+ ```bash
81
+ # Verify behavior matches declaration
82
+ aap verify --card alignment-card.json --trace logs/trace.json
83
+ # ✓ Verified [similarity: 0.82]
84
+ # Checks: autonomy, escalation, values, forbidden, behavioral_similarity
85
+ ```
86
+
87
+ ## Why AAP?
88
+
89
+ The agent protocol stack provides capability discovery (A2A), tool integration (MCP), and payment authorization (AP2). None address a fundamental question: **Is this agent serving its principal's interests?**
90
+
91
+ | Protocol | Function | Gap |
92
+ |----------|----------|-----|
93
+ | **MCP** | Agent-to-tool connectivity | No alignment semantics |
94
+ | **A2A** | Task negotiation between agents | No value verification |
95
+ | **AP2** | Payment authorization | No behavioral audit |
96
+
97
+ As agent capabilities become symmetric—equal access to information, equal reasoning power—alignment becomes the primary differentiator. AAP provides the infrastructure to make alignment claims verifiable.
98
+
99
+ ## Three Components
100
+
101
+ ```
102
+ ┌─────────────────┬─────────────────┬─────────────────┐
103
+ │ Alignment Card │ AP-Trace │ Value Coherence │
104
+ │ │ │ Handshake │
105
+ ├─────────────────┼─────────────────┼─────────────────┤
106
+ │ "What I claim │ "What I │ "Can we work │
107
+ │ to be" │ actually did" │ together?" │
108
+ └─────────────────┴─────────────────┴─────────────────┘
109
+ Declaration Audit Coordination
110
+ ```
111
+
112
+ ### Alignment Card
113
+
114
+ A structured declaration of an agent's alignment posture:
115
+
116
+ ```json
117
+ {
118
+ "aap_version": "0.1.0",
119
+ "agent_id": "did:web:my-agent.example.com",
120
+ "principal": {
121
+ "type": "human",
122
+ "relationship": "delegated_authority"
123
+ },
124
+ "values": {
125
+ "declared": ["principal_benefit", "transparency", "minimal_data"],
126
+ "conflicts_with": ["deceptive_marketing", "hidden_fees"]
127
+ },
128
+ "autonomy_envelope": {
129
+ "bounded_actions": ["search", "compare", "recommend"],
130
+ "escalation_triggers": [
131
+ {
132
+ "condition": "purchase_value > 100",
133
+ "action": "escalate",
134
+ "reason": "Exceeds autonomous spending limit"
135
+ }
136
+ ],
137
+ "forbidden_actions": ["share_credentials", "subscribe_to_services"]
138
+ },
139
+ "audit_commitment": {
140
+ "trace_format": "ap-trace-v1",
141
+ "retention_days": 90,
142
+ "queryable": true
143
+ }
144
+ }
145
+ ```
146
+
147
+ ### AP-Trace
148
+
149
+ An audit log entry recording each decision:
150
+
151
+ ```json
152
+ {
153
+ "trace_id": "tr-f47ac10b-58cc-4372",
154
+ "card_id": "ac-f47ac10b-58cc-4372",
155
+ "timestamp": "2026-01-31T12:30:00Z",
156
+ "action": {
157
+ "type": "recommend",
158
+ "name": "product_recommendation",
159
+ "category": "bounded"
160
+ },
161
+ "decision": {
162
+ "alternatives_considered": [
163
+ {"option_id": "A", "score": 0.85, "flags": []},
164
+ {"option_id": "B", "score": 0.72, "flags": ["sponsored_content"]}
165
+ ],
166
+ "selected": "A",
167
+ "selection_reasoning": "Highest score. Option B flagged as sponsored and deprioritized per principal_benefit value.",
168
+ "values_applied": ["principal_benefit", "transparency"]
169
+ },
170
+ "escalation": {
171
+ "evaluated": true,
172
+ "required": false,
173
+ "reason": "Recommendation only, no purchase action"
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### Value Coherence Handshake
179
+
180
+ Pre-coordination compatibility check between agents:
181
+
182
+ ```python
183
+ from aap import check_coherence
184
+
185
+ result = check_coherence(my_card, their_card, task_context)
186
+
187
+ if result.compatible:
188
+ # Proceed with coordination
189
+ proceed_with_task()
190
+ else:
191
+ # Handle conflict
192
+ print(f"Value conflict: {result.conflicts}")
193
+ # Escalate to principals or negotiate scope
194
+ ```
195
+
196
+ ## What AAP Does Not Do
197
+
198
+ This matters. Read it.
199
+
200
+ 1. **AAP does NOT ensure alignment—it provides visibility.** An agent can produce perfect traces while acting against its principal's interests.
201
+
202
+ 2. **Verified does NOT equal safe.** A verified trace means consistency with declared alignment. It doesn't mean the alignment is good or the outcome was beneficial.
203
+
204
+ 3. **AP-Trace is sampled, not complete.** Traces capture decision points, not every computation. Significant reasoning may occur between traces.
205
+
206
+ 4. **Value coherence is relative to declared values.** The handshake checks if declared values are compatible. It doesn't verify agents hold these values or will act on them.
207
+
208
+ 5. **Tested on transformer-based agents.** Other architectures may exhibit behaviors AAP doesn't capture.
209
+
210
+ For the complete limitations disclosure, see [Section 10 of the Specification](docs/SPEC.md#10-limitations).
211
+
212
+ ## Installation
213
+
214
+ ```bash
215
+ # Python
216
+ pip install agent-alignment-protocol
217
+
218
+ # TypeScript
219
+ npm install agent-alignment-protocol
220
+ ```
221
+
222
+ ## Integration
223
+
224
+ ### With A2A Agents
225
+
226
+ AAP extends the A2A Agent Card with an `alignment` block:
227
+
228
+ ```json
229
+ {
230
+ "name": "Shopping Assistant",
231
+ "description": "Helps users find products",
232
+ "url": "https://shopping.example.com",
233
+ "alignment": {
234
+ "$ref": "./alignment-card.json"
235
+ }
236
+ }
237
+ ```
238
+
239
+ See [A2A Migration Guide](docs/a2a-migration.md).
240
+
241
+ ### With MCP Tools
242
+
243
+ AAP can trace tool invocations and verify they match declared alignment:
244
+
245
+ ```python
246
+ from aap import mcp_traced
247
+
248
+ @mcp_traced(card_path="alignment-card.json")
249
+ def my_tool(params):
250
+ ...
251
+ ```
252
+
253
+ See [MCP Migration Guide](docs/mcp-migration.md).
254
+
255
+ ## Verification
256
+
257
+ The verification engine checks whether observed behavior matches declared alignment:
258
+
259
+ ```python
260
+ from aap import verify_trace, detect_drift
261
+
262
+ # Single trace verification
263
+ result = verify_trace(trace, card)
264
+ print(f"Verified: {result.verified}, Similarity: {result.similarity_score:.2f}")
265
+ if not result.verified:
266
+ print(f"Violations: {result.violations}")
267
+ if result.warnings:
268
+ print(f"Warnings: {result.warnings}")
269
+
270
+ # Drift detection over time
271
+ alerts = detect_drift(card, recent_traces)
272
+ for alert in alerts:
273
+ print(f"Drift detected: {alert.analysis.drift_direction}")
274
+ ```
275
+
276
+ **Verification checks:**
277
+ - Autonomy compliance (actions within declared bounds)
278
+ - Escalation compliance (required escalations were performed)
279
+ - Value consistency (applied values match declared values)
280
+ - Forbidden action compliance (no forbidden actions taken)
281
+ - Behavioral similarity (semantic alignment using SSM analysis)
282
+
283
+ **Similarity scoring:** Each verification returns a `similarity_score` (0.0-1.0) measuring semantic similarity between the trace and declared alignment. If a trace passes structural checks but has `similarity_score < 0.50`, a `low_behavioral_similarity` warning is generated.
284
+
285
+ ## Try It
286
+
287
+ **[Interactive Playground](https://mnemom.github.io/aap/playground/)** — Verify traces in your browser with SSM visualization.
288
+
289
+ - Paste your Alignment Card and AP-Trace
290
+ - See verification results with similarity scoring
291
+ - Visualize behavioral patterns with SSM heatmaps
292
+ - Adjust thresholds in real-time
293
+
294
+ No server required — runs entirely client-side via WebAssembly.
295
+
296
+ ## Documentation
297
+
298
+ | Document | Description |
299
+ |----------|-------------|
300
+ | [**SPEC.md**](docs/SPEC.md) | Full protocol specification (IETF-style) |
301
+ | [**QUICKSTART.md**](docs/QUICKSTART.md) | Zero to compliant in 5 minutes |
302
+ | [**LIMITS.md**](docs/LIMITS.md) | What AAP guarantees and doesn't |
303
+ | [**SECURITY.md**](docs/SECURITY.md) | Threat model and security considerations |
304
+ | [**CALIBRATION.md**](docs/CALIBRATION.md) | How verification thresholds were derived |
305
+
306
+ ## Examples
307
+
308
+ | Example | Description |
309
+ |---------|-------------|
310
+ | [`simple-agent/`](examples/simple-agent/) | Minimal AAP implementation |
311
+ | [`a2a-integration/`](examples/a2a-integration/) | A2A agent with AAP |
312
+ | [`mcp-integration/`](examples/mcp-integration/) | MCP tools with alignment |
313
+ | [`alignment-failure/`](examples/alignment-failure/) | Deliberate failure for testing |
314
+
315
+ ## Status
316
+
317
+ **Current Version**: 0.1.1 (Draft)
318
+
319
+ | Component | Status |
320
+ |-----------|--------|
321
+ | Specification | ✅ Complete |
322
+ | JSON Schemas | ✅ Complete |
323
+ | Python SDK | ✅ Complete |
324
+ | TypeScript SDK | ✅ Complete |
325
+ | Verification Engine | ✅ Complete (with similarity scoring) |
326
+ | SSM Visualization | ✅ Complete |
327
+ | Interactive Playground | ✅ Complete |
328
+
329
+ ## API Reference
330
+
331
+ ```python
332
+ # Core API
333
+ from aap import (
334
+ verify_trace, # Verify single trace against card → VerificationResult
335
+ check_coherence, # Check value compatibility between agents → CoherenceResult
336
+ detect_drift, # Detect behavioral drift over time → list[DriftAlert]
337
+ trace_decision, # Decorator for automatic AP-Trace generation
338
+ mcp_traced, # Decorator for MCP tool tracing
339
+ )
340
+
341
+ # Models
342
+ from aap import (
343
+ AlignmentCard,
344
+ APTrace,
345
+ VerificationResult, # .verified, .similarity_score, .violations, .warnings
346
+ CoherenceResult, # .compatible, .score, .value_alignment
347
+ DriftAlert, # .analysis.similarity_score, .analysis.drift_direction
348
+ )
349
+
350
+ # CLI
351
+ # aap init [--values VALUES] [--output FILE]
352
+ # aap verify --card CARD --trace TRACE → Shows [similarity: X.XX]
353
+ # aap check-coherence --my-card MINE --their-card THEIRS
354
+ # aap drift --card CARD --traces TRACES_DIR → Uses SSM analysis
355
+ ```
356
+
357
+ ## Contributing
358
+
359
+ We welcome contributions. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
360
+
361
+ Key areas where we need help:
362
+ - SDK implementations in other languages
363
+ - Integration examples with popular agent frameworks
364
+ - Test vectors for edge cases
365
+ - Documentation improvements
366
+
367
+ ## License
368
+
369
+ Apache 2.0. See [LICENSE](LICENSE) for details.
370
+
371
+ ---
372
+
373
+ *Agent Alignment Protocol — Making agent alignment observable.*