federated-agent-audit 0.2.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 (103) hide show
  1. federated_agent_audit-0.2.0/LICENSE +189 -0
  2. federated_agent_audit-0.2.0/PKG-INFO +359 -0
  3. federated_agent_audit-0.2.0/README.md +310 -0
  4. federated_agent_audit-0.2.0/pyproject.toml +69 -0
  5. federated_agent_audit-0.2.0/setup.cfg +4 -0
  6. federated_agent_audit-0.2.0/src/federated_agent_audit/__init__.py +158 -0
  7. federated_agent_audit-0.2.0/src/federated_agent_audit/access_control.py +199 -0
  8. federated_agent_audit-0.2.0/src/federated_agent_audit/blame.py +179 -0
  9. federated_agent_audit-0.2.0/src/federated_agent_audit/cascade_detector.py +281 -0
  10. federated_agent_audit-0.2.0/src/federated_agent_audit/channel_auditor.py +286 -0
  11. federated_agent_audit-0.2.0/src/federated_agent_audit/cli.py +287 -0
  12. federated_agent_audit-0.2.0/src/federated_agent_audit/commit_reveal.py +97 -0
  13. federated_agent_audit-0.2.0/src/federated_agent_audit/compositional_leak.py +296 -0
  14. federated_agent_audit-0.2.0/src/federated_agent_audit/compound_attack.py +380 -0
  15. federated_agent_audit-0.2.0/src/federated_agent_audit/config.py +166 -0
  16. federated_agent_audit-0.2.0/src/federated_agent_audit/cross_container.py +301 -0
  17. federated_agent_audit-0.2.0/src/federated_agent_audit/cross_platform_denanon.py +310 -0
  18. federated_agent_audit-0.2.0/src/federated_agent_audit/desensitizer.py +469 -0
  19. federated_agent_audit-0.2.0/src/federated_agent_audit/dp_mechanism.py +180 -0
  20. federated_agent_audit-0.2.0/src/federated_agent_audit/embeddings.py +107 -0
  21. federated_agent_audit-0.2.0/src/federated_agent_audit/epoch_chain.py +531 -0
  22. federated_agent_audit-0.2.0/src/federated_agent_audit/injection_detector.py +428 -0
  23. federated_agent_audit-0.2.0/src/federated_agent_audit/integrity.py +114 -0
  24. federated_agent_audit-0.2.0/src/federated_agent_audit/lifecycle.py +262 -0
  25. federated_agent_audit-0.2.0/src/federated_agent_audit/llm_judge.py +527 -0
  26. federated_agent_audit-0.2.0/src/federated_agent_audit/local_auditor.py +350 -0
  27. federated_agent_audit-0.2.0/src/federated_agent_audit/memory_audit.py +351 -0
  28. federated_agent_audit-0.2.0/src/federated_agent_audit/merkle.py +70 -0
  29. federated_agent_audit-0.2.0/src/federated_agent_audit/negative_inference.py +246 -0
  30. federated_agent_audit-0.2.0/src/federated_agent_audit/network_auditor.py +489 -0
  31. federated_agent_audit-0.2.0/src/federated_agent_audit/privacy_gate.py +171 -0
  32. federated_agent_audit-0.2.0/src/federated_agent_audit/privacy_loss.py +362 -0
  33. federated_agent_audit-0.2.0/src/federated_agent_audit/py.typed +0 -0
  34. federated_agent_audit-0.2.0/src/federated_agent_audit/regulatory_compliance.py +520 -0
  35. federated_agent_audit-0.2.0/src/federated_agent_audit/reporting/__init__.py +5 -0
  36. federated_agent_audit-0.2.0/src/federated_agent_audit/reporting/html_report.py +1130 -0
  37. federated_agent_audit-0.2.0/src/federated_agent_audit/risk_aggregator.py +358 -0
  38. federated_agent_audit-0.2.0/src/federated_agent_audit/scenario_classifier.py +134 -0
  39. federated_agent_audit-0.2.0/src/federated_agent_audit/schemas.py +261 -0
  40. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/__init__.py +54 -0
  41. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/_entry_builder.py +131 -0
  42. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/_facade.py +185 -0
  43. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/crewai.py +246 -0
  44. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/generic.py +93 -0
  45. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/intercept.py +547 -0
  46. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/langchain.py +261 -0
  47. federated_agent_audit-0.2.0/src/federated_agent_audit/sdk/multiagent.py +269 -0
  48. federated_agent_audit-0.2.0/src/federated_agent_audit/semantic_detector.py +405 -0
  49. federated_agent_audit-0.2.0/src/federated_agent_audit/session_identity.py +277 -0
  50. federated_agent_audit-0.2.0/src/federated_agent_audit/taint_tracker.py +154 -0
  51. federated_agent_audit-0.2.0/src/federated_agent_audit/topology.py +283 -0
  52. federated_agent_audit-0.2.0/src/federated_agent_audit/transport/__init__.py +7 -0
  53. federated_agent_audit-0.2.0/src/federated_agent_audit/transport/client.py +163 -0
  54. federated_agent_audit-0.2.0/src/federated_agent_audit/transport/server.py +144 -0
  55. federated_agent_audit-0.2.0/src/federated_agent_audit/transport/wire.py +62 -0
  56. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/PKG-INFO +359 -0
  57. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/SOURCES.txt +101 -0
  58. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/dependency_links.txt +1 -0
  59. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/entry_points.txt +2 -0
  60. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/requires.txt +32 -0
  61. federated_agent_audit-0.2.0/src/federated_agent_audit.egg-info/top_level.txt +1 -0
  62. federated_agent_audit-0.2.0/tests/test_access_control.py +178 -0
  63. federated_agent_audit-0.2.0/tests/test_blame.py +143 -0
  64. federated_agent_audit-0.2.0/tests/test_cascade_detector.py +166 -0
  65. federated_agent_audit-0.2.0/tests/test_channel_auditor.py +123 -0
  66. federated_agent_audit-0.2.0/tests/test_commit_reveal.py +88 -0
  67. federated_agent_audit-0.2.0/tests/test_compositional_leak.py +211 -0
  68. federated_agent_audit-0.2.0/tests/test_compound_attack.py +124 -0
  69. federated_agent_audit-0.2.0/tests/test_crewai_integration.py +144 -0
  70. federated_agent_audit-0.2.0/tests/test_cross_container.py +204 -0
  71. federated_agent_audit-0.2.0/tests/test_cross_platform_denanon.py +172 -0
  72. federated_agent_audit-0.2.0/tests/test_desensitizer.py +378 -0
  73. federated_agent_audit-0.2.0/tests/test_detection_benchmark.py +80 -0
  74. federated_agent_audit-0.2.0/tests/test_dp_mechanism.py +170 -0
  75. federated_agent_audit-0.2.0/tests/test_embeddings.py +110 -0
  76. federated_agent_audit-0.2.0/tests/test_epoch_chain.py +577 -0
  77. federated_agent_audit-0.2.0/tests/test_html_report.py +206 -0
  78. federated_agent_audit-0.2.0/tests/test_injection_detector.py +151 -0
  79. federated_agent_audit-0.2.0/tests/test_integrity.py +91 -0
  80. federated_agent_audit-0.2.0/tests/test_intercept.py +266 -0
  81. federated_agent_audit-0.2.0/tests/test_langchain_integration.py +131 -0
  82. federated_agent_audit-0.2.0/tests/test_langgraph_live.py +84 -0
  83. federated_agent_audit-0.2.0/tests/test_lifecycle.py +161 -0
  84. federated_agent_audit-0.2.0/tests/test_llm_judge.py +392 -0
  85. federated_agent_audit-0.2.0/tests/test_memory_audit.py +243 -0
  86. federated_agent_audit-0.2.0/tests/test_multiagent_tracer.py +150 -0
  87. federated_agent_audit-0.2.0/tests/test_negative_inference.py +112 -0
  88. federated_agent_audit-0.2.0/tests/test_privacy_gate.py +72 -0
  89. federated_agent_audit-0.2.0/tests/test_privacy_loss.py +163 -0
  90. federated_agent_audit-0.2.0/tests/test_real_world_scenarios.py +525 -0
  91. federated_agent_audit-0.2.0/tests/test_regulatory_compliance.py +259 -0
  92. federated_agent_audit-0.2.0/tests/test_risk_aggregator.py +269 -0
  93. federated_agent_audit-0.2.0/tests/test_scenario_classifier.py +138 -0
  94. federated_agent_audit-0.2.0/tests/test_sdk_entry_builder.py +112 -0
  95. federated_agent_audit-0.2.0/tests/test_sdk_facade.py +163 -0
  96. federated_agent_audit-0.2.0/tests/test_sdk_generic.py +102 -0
  97. federated_agent_audit-0.2.0/tests/test_semantic_detector.py +164 -0
  98. federated_agent_audit-0.2.0/tests/test_session_identity.py +221 -0
  99. federated_agent_audit-0.2.0/tests/test_taint_tracker.py +145 -0
  100. federated_agent_audit-0.2.0/tests/test_topology.py +145 -0
  101. federated_agent_audit-0.2.0/tests/test_transport_server.py +149 -0
  102. federated_agent_audit-0.2.0/tests/test_transport_wire.py +103 -0
  103. federated_agent_audit-0.2.0/tests/test_two_phase.py +326 -0
@@ -0,0 +1,189 @@
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
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including
48
+ the original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to the Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including but not limited to
55
+ communication on electronic mailing lists, source code control systems,
56
+ and issue tracking systems that are managed by, or on behalf of, the
57
+ Licensor for the purpose of discussing and improving the Work, but
58
+ excluding communication that is conspicuously marked or otherwise
59
+ designated in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by the Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity (including a
82
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
83
+ or a Contribution incorporated within the Work constitutes direct
84
+ or contributory patent infringement, then any patent licenses
85
+ granted to You under this License for that Work shall terminate
86
+ as of the date such litigation is filed.
87
+
88
+ 4. Redistribution. You may reproduce and distribute copies of the
89
+ Work or Derivative Works thereof in any medium, with or without
90
+ modifications, and in Source or Object form, provided that You
91
+ meet the following conditions:
92
+
93
+ (a) You must give any other recipients of the Work or
94
+ Derivative Works a copy of this License; and
95
+
96
+ (b) You must cause any modified files to carry prominent notices
97
+ stating that You changed the files; and
98
+
99
+ (c) You must retain, in the Source form of any Derivative Works
100
+ that You distribute, all copyright, patent, trademark, and
101
+ attribution notices from the Source form of the Work,
102
+ excluding those notices that do not pertain to any part of
103
+ the Derivative Works; and
104
+
105
+ (d) If the Work includes a "NOTICE" text file as part of its
106
+ distribution, then any Derivative Works that You distribute must
107
+ include a readable copy of the attribution notices contained
108
+ within such NOTICE file, excluding any notices that do not
109
+ pertain to any part of the Derivative Works, in at least one
110
+ of the following places: within a NOTICE text file distributed
111
+ as part of the Derivative Works; within the Source form or
112
+ documentation, if provided along with the Derivative Works; or,
113
+ within a display generated by the Derivative Works, if and
114
+ wherever such third-party notices normally appear. The contents
115
+ of the NOTICE file are for informational purposes only and
116
+ do not modify the License. You may add Your own attribution
117
+ notices within Derivative Works that You distribute, alongside
118
+ or as an addendum to the NOTICE text from the Work, provided
119
+ that such additional attribution notices cannot be construed
120
+ as modifying the License.
121
+
122
+ You may add Your own copyright statement to Your modifications and
123
+ may provide additional or different license terms and conditions
124
+ for use, reproduction, or distribution of Your modifications, or
125
+ for any such Derivative Works as a whole, provided Your use,
126
+ reproduction, and distribution of the Work otherwise complies with
127
+ the conditions stated in this License.
128
+
129
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
130
+ any Contribution intentionally submitted for inclusion in the Work
131
+ by You to the Licensor shall be under the terms and conditions of
132
+ this License, without any additional terms or conditions.
133
+ Notwithstanding the above, nothing herein shall supersede or modify
134
+ the terms of any separate license agreement you may have executed
135
+ with Licensor regarding such Contributions.
136
+
137
+ 6. Trademarks. This License does not grant permission to use the trade
138
+ names, trademarks, service marks, or product names of the Licensor,
139
+ except as required for reasonable and customary use in describing the
140
+ origin of the Work and reproducing the content of the NOTICE file.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work (and each
144
+ Contributor provides its Contributions) on an "AS IS" BASIS,
145
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
146
+ implied, including, without limitation, any warranties or conditions
147
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
148
+ PARTICULAR PURPOSE. You are solely responsible for determining the
149
+ appropriateness of using or redistributing the Work and assume any
150
+ risks associated with Your exercise of permissions under this License.
151
+
152
+ 8. Limitation of Liability. In no event and under no legal theory,
153
+ whether in tort (including negligence), contract, or otherwise,
154
+ unless required by applicable law (such as deliberate and grossly
155
+ negligent acts) or agreed to in writing, shall any Contributor be
156
+ liable to You for damages, including any direct, indirect, special,
157
+ incidental, or consequential damages of any character arising as a
158
+ result of this License or out of the use or inability to use the
159
+ Work (including but not limited to damages for loss of goodwill,
160
+ work stoppage, computer failure or malfunction, or any and all
161
+ other commercial damages or losses), even if such Contributor
162
+ has been advised of the possibility of such damages.
163
+
164
+ 9. Accepting Warranty or Additional Liability. While redistributing
165
+ the Work or Derivative Works thereof, You may choose to offer,
166
+ and charge a fee for, acceptance of support, warranty, indemnity,
167
+ or other liability obligations and/or rights consistent with this
168
+ License. However, in accepting such obligations, You may act only
169
+ on Your own behalf and on Your sole responsibility, not on behalf
170
+ of any other Contributor, and only if You agree to indemnify,
171
+ defend, and hold each Contributor harmless for any liability
172
+ incurred by, or claims asserted against, such Contributor by reason
173
+ of your accepting any such warranty or additional liability.
174
+
175
+ END OF TERMS AND CONDITIONS
176
+
177
+ Copyright 2024-2026 Justin Yuan
178
+
179
+ Licensed under the Apache License, Version 2.0 (the "License");
180
+ you may not use this file except in compliance with the License.
181
+ You may obtain a copy of the License at
182
+
183
+ http://www.apache.org/licenses/LICENSE-2.0
184
+
185
+ Unless required by applicable law or agreed to in writing, software
186
+ distributed under the License is distributed on an "AS IS" BASIS,
187
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
+ See the License for the specific language governing permissions and
189
+ limitations under the License.
@@ -0,0 +1,359 @@
1
+ Metadata-Version: 2.4
2
+ Name: federated-agent-audit
3
+ Version: 0.2.0
4
+ Summary: Privacy-preserving audit framework for multi-agent AI systems. Detects cross-agent data leaks, inference attacks, and compliance violations — without accessing raw content.
5
+ Author-email: Justin Yuan <aojieyua@usc.edu>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Justin0504/federated-agent-audit
8
+ Project-URL: Repository, https://github.com/Justin0504/federated-agent-audit
9
+ Project-URL: Issues, https://github.com/Justin0504/federated-agent-audit/issues
10
+ Keywords: audit,privacy,multi-agent,federated,llm,compliance,gdpr,ai-safety,agent,security
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pydantic>=2.0
25
+ Requires-Dist: cryptography>=41.0
26
+ Requires-Dist: numpy>=1.24
27
+ Requires-Dist: networkx>=3.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0; extra == "dev"
30
+ Requires-Dist: ruff>=0.1; extra == "dev"
31
+ Provides-Extra: langchain
32
+ Requires-Dist: langchain-core>=0.2; extra == "langchain"
33
+ Provides-Extra: langgraph
34
+ Requires-Dist: langgraph>=0.2; extra == "langgraph"
35
+ Requires-Dist: langchain-core>=0.2; extra == "langgraph"
36
+ Provides-Extra: crewai
37
+ Requires-Dist: crewai>=0.50; extra == "crewai"
38
+ Provides-Extra: embeddings
39
+ Requires-Dist: sentence-transformers>=2.2; extra == "embeddings"
40
+ Provides-Extra: transport
41
+ Requires-Dist: httpx>=0.25; extra == "transport"
42
+ Requires-Dist: fastapi>=0.100; extra == "transport"
43
+ Requires-Dist: uvicorn>=0.20; extra == "transport"
44
+ Provides-Extra: yaml
45
+ Requires-Dist: pyyaml>=6.0; extra == "yaml"
46
+ Provides-Extra: all
47
+ Requires-Dist: federated-agent-audit[crewai,embeddings,langchain,langgraph,transport,yaml]; extra == "all"
48
+ Dynamic: license-file
49
+
50
+ # Federated Agent Audit
51
+
52
+ **Privacy audit for multi-agent AI systems — without touching raw data.**
53
+
54
+ ```
55
+ pip install federated-agent-audit
56
+ ```
57
+
58
+ [![CI](https://github.com/Justin0504/federated-agent-audit/actions/workflows/ci.yml/badge.svg)](https://github.com/Justin0504/federated-agent-audit/actions/workflows/ci.yml)
59
+ [![PyPI version](https://img.shields.io/pypi/v/federated-agent-audit.svg)](https://pypi.org/project/federated-agent-audit/)
60
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
61
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green.svg)](LICENSE)
62
+ [![Tests](https://img.shields.io/badge/tests-649%20passing-brightgreen.svg)](tests/)
63
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
64
+
65
+ > Audit multi-agent systems (CrewAI · LangGraph · AutoGen) for compositional privacy leaks the central auditor can never see the raw data behind.
66
+
67
+ ---
68
+
69
+ ## 30-Second Quick Start
70
+
71
+ Scan any text for sensitive content:
72
+
73
+ ```python
74
+ from federated_agent_audit import scan
75
+
76
+ result = scan("Zhang Wei's SSN is 123-45-6789, salary $185,000")
77
+ print(result["clean"]) # False
78
+ print(result["detected"]) # ['SSN', 'salary']
79
+ print(result["text"]) # "Zhang Wei's [REDACTED] is [SSN], [REDACTED] [DOLLAR_AMOUNT]"
80
+ ```
81
+
82
+ Or from the command line:
83
+
84
+ ```bash
85
+ federated-audit scan "My email is john@acme.com"
86
+ # REDACTED Detected: email
87
+ # Output: My [REDACTED] is [EMAIL_ADDRESS]
88
+
89
+ echo "credit card 4532-1234-5678-9012" | federated-audit scan
90
+ # REDACTED Detected: credit card
91
+ ```
92
+
93
+ ## Protect Your LLM Calls
94
+
95
+ Intercept every OpenAI/Anthropic response automatically:
96
+
97
+ ```python
98
+ from federated_agent_audit import firewall
99
+
100
+ fw = firewall(["salary", "SSN", "diagnosis"])
101
+ fw.patch_openai() # done — every response is now checked
102
+
103
+ # Normal usage — firewall is invisible
104
+ response = client.chat.completions.create(model="gpt-4o", messages=[...])
105
+ # Sensitive content in response is already redacted
106
+ ```
107
+
108
+ ## The Problem
109
+
110
+ Multi-agent systems (CrewAI, LangGraph, AutoGen) create **compound privacy risks** that single-agent tools can't detect:
111
+
112
+ - Agent A shares salary data with Agent B (allowed by A's policy)
113
+ - Agent B forwards a "summary" to an external partner (allowed by B's policy)
114
+ - **Result**: salary leaked outside the company — neither agent broke its own rules
115
+
116
+ Existing observability tools (LangSmith, Langfuse) require uploading raw prompts to their servers. This framework audits agent interactions **without the central auditor ever seeing raw content**.
117
+
118
+ ```
119
+ +---------------+
120
+ | Central | Phase 2: Network audit
121
+ | Auditor | (desensitized metadata only)
122
+ +-------+-------+
123
+ |
124
+ +---------------+---------------+
125
+ | | |
126
+ +------+------+ +----+----+ +--------+------+
127
+ | Local Audit | | Local | | Local Audit | Phase 1
128
+ | (Agent A) | | (Agt B) | | (Agent C) |
129
+ +-------------+ +---------+ +---------------+
130
+ raw content raw content raw content
131
+ stays here stays here stays here
132
+ ```
133
+
134
+ ## Full Pipeline Example
135
+
136
+ ```python
137
+ from federated_agent_audit import (
138
+ FederatedAudit, PrivacyPolicy, NetworkAuditor,
139
+ RiskAggregator, ComplianceEngine,
140
+ )
141
+
142
+ # 1. Define policies
143
+ policy_hr = PrivacyPolicy(agent_id="hr_bot", must_not_share=["salary", "SSN"])
144
+ policy_ext = PrivacyPolicy(agent_id="notify_bot", must_not_share=["salary", "SSN", "email"])
145
+
146
+ # 2. Record interactions (each agent audits locally)
147
+ audit_hr = FederatedAudit(policy=policy_hr)
148
+ audit_hr.record_outgoing("Zhang Wei earns $185k", to_agent="summary_bot")
149
+
150
+ audit_ext = FederatedAudit(policy=policy_ext)
151
+ audit_ext.record_outgoing("Candidate update sent", to_agent="external")
152
+
153
+ # 3. Central audit (only sees desensitized metadata — never raw text)
154
+ net = NetworkAuditor()
155
+ net.ingest_report(audit_hr.get_report())
156
+ net.ingest_report(audit_ext.get_report())
157
+ result = net.audit()
158
+
159
+ # 4. Compliance check
160
+ compliance = ComplianceEngine(eu_users=True).evaluate(result)
161
+ print(f"Compliance: {compliance.overall_score:.0%} — {compliance.status.value}")
162
+ for gap in compliance.gaps():
163
+ print(f" {gap.regulation} {gap.article}: {gap.title}")
164
+ ```
165
+
166
+ ## What It Detects
167
+
168
+ | Risk | What happens | How we catch it |
169
+ |------|-------------|-----------------|
170
+ | **Cross-domain leak** | Health data reaches social media agent | Domain boundary analysis on metadata |
171
+ | **Compositional inference** | Agent collects health + identity = reidentification | Quasi-identifier assembly detection |
172
+ | **Aggregation attack** | 3 agents each share a fragment → hub reconstructs full profile | Multi-source convergence analysis |
173
+ | **Cascading injection** | Prompt injection propagates agent-to-agent like a worm | Infection tree + patient-zero attribution |
174
+ | **Behavioral drift** | Agent suddenly changes behavior (possible compromise) | Cross-session z-score monitoring |
175
+ | **Negative inference** | "I can't share that" confirms the data exists | Refusal pattern detection |
176
+ | **Regulatory gap** | EU AI Act / GDPR / COPPA requirements unmet | Per-article compliance scoring |
177
+
178
+ ## CLI
179
+
180
+ ```bash
181
+ # Scan text for sensitive content
182
+ federated-audit scan "Patient SSN is 123-45-6789"
183
+ echo "salary: $200k" | federated-audit scan --protect salary
184
+
185
+ # Validate policy files
186
+ federated-audit validate policies/*.yaml
187
+
188
+ # Run a demo
189
+ federated-audit demo
190
+
191
+ # Start the central audit server
192
+ federated-audit server --port 8000
193
+ ```
194
+
195
+ ## YAML Policies
196
+
197
+ ```yaml
198
+ # policies/hr_bot.yaml
199
+ agent_id: hr_bot
200
+ must_not_share:
201
+ - salary
202
+ - SSN
203
+ - performance review
204
+ acceptable_abstractions:
205
+ salary: compensation level
206
+ SSN: employee identifier
207
+ sensitivity_threshold: 3
208
+ ```
209
+
210
+ ```python
211
+ from federated_agent_audit import load_policy
212
+ policy = load_policy("policies/hr_bot.yaml")
213
+ ```
214
+
215
+ ## Compliance Engine
216
+
217
+ Built-in regulatory mapping for EU AI Act, GDPR, CA SB 243, and COPPA:
218
+
219
+ ```python
220
+ from federated_agent_audit import ComplianceEngine
221
+
222
+ engine = ComplianceEngine(eu_users=True, california_users=True, involves_children=False)
223
+ report = engine.evaluate(audit_result)
224
+
225
+ print(report.overall_score) # 0.0 - 1.0
226
+ print(report.status) # compliant / partial / non_compliant
227
+ for gap in report.gaps():
228
+ print(f"{gap.regulation} {gap.article}: {gap.remediation}")
229
+ ```
230
+
231
+ ## Multi-Agent Trace Capture
232
+
233
+ The integrations capture the **real agent-to-agent interaction graph** — who
234
+ sent what to whom — which is exactly what the compositional / cascade /
235
+ cross-domain detectors analyze. Everything is built on `MultiAgentTracer`,
236
+ which works with any framework (or none):
237
+
238
+ ```python
239
+ from federated_agent_audit import MultiAgentTracer, PrivacyPolicy
240
+
241
+ tracer = MultiAgentTracer()
242
+ tracer.register_agent("hr_bot", PrivacyPolicy(agent_id="hr_bot", must_not_share=["salary"]))
243
+
244
+ # Each call is a real directed edge; taint (domains, sensitivity, origin,
245
+ # hop count) propagates across hops automatically.
246
+ tracer.record_handoff("hr_bot", "summary_bot", "Zhang Wei earns $185k", origin="zhang_wei")
247
+ tracer.record_handoff("summary_bot", "external_bot", "candidate compensation summary")
248
+
249
+ result = tracer.network_audit() # Phase-2 central audit
250
+ incidents = tracer.aggregated() # denoised, actionable alerts
251
+ ```
252
+
253
+ It catches the compound leak no single agent's policy can see — and the central
254
+ auditor still never touched the raw data (`python examples/multiagent_trace_demo.py`):
255
+
256
+ ```
257
+ Incidents: 5 alert_summary={'critical': 3, 'high': 2}
258
+ [CRITICAL] cross_domain_leak — Sensitive health data reaches social domain via 2-agent chain
259
+ [CRITICAL] cross_domain_leak — Sensitive finance data reaches social domain via 2-agent chain
260
+ [CRITICAL] taint_spreading — Data from origin 'zhang_wei' spread to 4 agents across the network
261
+ [HIGH] inference_accumulation — external_bot accumulated high inference risk (77%)
262
+ [HIGH] compound_scope_escalation — 3 agent pairs exceed authorized scope
263
+
264
+ Privacy verification (central reports): hr_bot → clean health_bot → clean summary_bot → clean
265
+ ```
266
+
267
+ ## Framework Integrations
268
+
269
+ ```python
270
+ # CrewAI — captures agent delegation (Delegate/Ask coworker) as A→B edges
271
+ from federated_agent_audit.sdk import crew_audit
272
+ crew = crew_audit(crew, default_policy=policy) # or policies={role: policy}
273
+ crew.kickoff()
274
+ result = crew._federated_tracer.network_audit()
275
+
276
+ # LangChain / LangGraph — per-node identity + node-to-node hand-offs
277
+ from federated_agent_audit.sdk import langchain_callback
278
+ handler = langchain_callback(default_policy=policy) # asynchronous=True for async graphs
279
+ graph.invoke(input, config={"callbacks": [handler]})
280
+ result = handler.tracer.network_audit()
281
+
282
+ # Generic Python — single-agent decorator
283
+ from federated_agent_audit import audited
284
+ @audited(policy, to_agent="downstream")
285
+ def my_agent(input_text: str) -> str:
286
+ return process(input_text)
287
+ ```
288
+
289
+ The LLM firewall hardens this for production — fail-open (audit never crashes
290
+ the app), streaming responses blocked the moment a violation accumulates, and
291
+ sensitive content inspected inside tool-call arguments:
292
+
293
+ ```python
294
+ from federated_agent_audit import firewall
295
+ fw = firewall(["salary", "SSN"]); fw.patch_openai() # streaming + tool calls covered
296
+ ```
297
+
298
+ ## Installation
299
+
300
+ ```bash
301
+ pip install federated-agent-audit # core
302
+ pip install "federated-agent-audit[transport]" # + audit server
303
+ pip install "federated-agent-audit[yaml]" # + YAML policies
304
+ pip install "federated-agent-audit[langchain]" # + LangChain
305
+ pip install "federated-agent-audit[all]" # everything
306
+ ```
307
+
308
+ ## How It Works
309
+
310
+ ```
311
+ 48 modules · 597 tests · 0 external API calls required
312
+
313
+ Local (Phase 1): Network (Phase 2):
314
+ PrivacyGate (regex + PII) Cross-domain flow detection
315
+ SemanticDetector (4-tier) Compositional leak detection
316
+ TaintTracker (info flow) Cascade infection tracking
317
+ Desensitizer (6-layer) Topology analysis
318
+ MemoryAuditor (write audit) Blame attribution
319
+ Compliance engine
320
+ ```
321
+
322
+ **Privacy guarantee**: The central auditor architecturally cannot see raw content. Data is hashed, pseudonymized, and DP-noised before leaving local agents. Merkle tree commitments ensure tamper-proof audit trails without revealing entries.
323
+
324
+ ## Detection Effectiveness
325
+
326
+ A labeled benchmark of multi-agent scenarios (real compositional leaks vs.
327
+ benign traffic) measures detection quality, not just speed:
328
+
329
+ ```bash
330
+ python benchmarks/detection_eval.py # precision / recall / F1
331
+ python benchmarks/detection_eval.py --sweep # threshold robustness
332
+ ```
333
+
334
+ On the current scenario set (13 leak + 11 benign, incl. adversarial cases:
335
+ noise-buried leaks, diamond multi-path, partial-shared-origin hubs, same-domain
336
+ laundering, high-volume benign hubs, cross-subject convergence) the pipeline
337
+ reaches **precision 1.0 / recall 1.0 / F1 1.0** with **zero raw-content
338
+ leakage** into central reports, stable across thresholds 0.3–0.8. Pure structural signals
339
+ (topology, timing, behavioral) are reported separately and not counted as
340
+ privacy-leak detections. The harness is the place to add adversarial scenarios;
341
+ `tests/test_detection_benchmark.py` locks the metrics as a regression gate.
342
+
343
+ Validated live against **LangGraph** (free, in-suite) and **CrewAI** + **OpenAI
344
+ streaming** (opt-in examples, need an API key).
345
+
346
+ ## Development
347
+
348
+ ```bash
349
+ git clone https://github.com/Justin0504/federated-agent-audit
350
+ cd federated-agent-audit
351
+ pip install -e ".[dev,transport,yaml]"
352
+ pytest # 597 tests
353
+ ruff check src/ tests/ # lint
354
+ python examples/crewai_audit_demo.py # run the demo
355
+ ```
356
+
357
+ ## License
358
+
359
+ Apache 2.0