comply54 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.
- comply54-0.2.0/PKG-INFO +365 -0
- comply54-0.2.0/README.md +320 -0
- comply54-0.2.0/comply54/__init__.py +108 -0
- comply54-0.2.0/comply54/autogen/__init__.py +0 -0
- comply54-0.2.0/comply54/autogen/adapter.py +68 -0
- comply54-0.2.0/comply54/core/__init__.py +12 -0
- comply54-0.2.0/comply54/core/engine.py +185 -0
- comply54-0.2.0/comply54/core/models.py +200 -0
- comply54-0.2.0/comply54/core/packs.py +296 -0
- comply54-0.2.0/comply54/crewai/__init__.py +0 -0
- comply54-0.2.0/comply54/crewai/adapter.py +87 -0
- comply54-0.2.0/comply54/langchain/__init__.py +3 -0
- comply54-0.2.0/comply54/langchain/adapter.py +290 -0
- comply54-0.2.0/comply54/packs/__init__.py +0 -0
- comply54-0.2.0/comply54/packs/africa/__init__.py +0 -0
- comply54-0.2.0/comply54/packs/africa/egypt_pdpl.rego +219 -0
- comply54-0.2.0/comply54/packs/africa/ethiopia_pdp.rego +191 -0
- comply54-0.2.0/comply54/packs/africa/ghana_dpa.rego +183 -0
- comply54-0.2.0/comply54/packs/africa/kdpa.rego +189 -0
- comply54-0.2.0/comply54/packs/africa/mauritius_dpa.rego +272 -0
- comply54-0.2.0/comply54/packs/africa/popia.rego +163 -0
- comply54-0.2.0/comply54/packs/africa/rwanda_dpa.rego +197 -0
- comply54-0.2.0/comply54/packs/africa/tanzania_pdpa.rego +178 -0
- comply54-0.2.0/comply54/packs/africa/uganda_dppa.rego +183 -0
- comply54-0.2.0/comply54/packs/nigeria/__init__.py +0 -0
- comply54-0.2.0/comply54/packs/nigeria/bvn_nin.rego +142 -0
- comply54-0.2.0/comply54/packs/nigeria/cbn.rego +165 -0
- comply54-0.2.0/comply54/packs/nigeria/naicom.rego +224 -0
- comply54-0.2.0/comply54/packs/nigeria/ndpa.rego +174 -0
- comply54-0.2.0/comply54/packs/nigeria/nfiu_aml.rego +154 -0
- comply54-0.2.0/comply54/packs/nigeria/nha.rego +188 -0
- comply54-0.2.0/comply54/packs/universal/__init__.py +0 -0
- comply54-0.2.0/comply54/packs/universal/human_approval.rego +122 -0
- comply54-0.2.0/comply54/packs/universal/model_routing.rego +151 -0
- comply54-0.2.0/comply54/packs/universal/pii_leakage.rego +166 -0
- comply54-0.2.0/comply54/packs/universal/prompt_injection.rego +111 -0
- comply54-0.2.0/comply54/packs/universal/tool_permissions.rego +98 -0
- comply54-0.2.0/comply54/sectors/__init__.py +15 -0
- comply54-0.2.0/comply54/sectors/_base.py +131 -0
- comply54-0.2.0/comply54/sectors/kenya_fintech.py +54 -0
- comply54-0.2.0/comply54/sectors/nigeria_fintech.py +75 -0
- comply54-0.2.0/comply54/sectors/nigeria_health.py +77 -0
- comply54-0.2.0/comply54/sectors/nigeria_insurance.py +78 -0
- comply54-0.2.0/comply54/sectors/pan_african.py +91 -0
- comply54-0.2.0/comply54.egg-info/PKG-INFO +365 -0
- comply54-0.2.0/comply54.egg-info/SOURCES.txt +52 -0
- comply54-0.2.0/comply54.egg-info/dependency_links.txt +1 -0
- comply54-0.2.0/comply54.egg-info/requires.txt +29 -0
- comply54-0.2.0/comply54.egg-info/top_level.txt +1 -0
- comply54-0.2.0/pyproject.toml +88 -0
- comply54-0.2.0/setup.cfg +4 -0
- comply54-0.2.0/tests/test_certificate.py +136 -0
- comply54-0.2.0/tests/test_engine.py +158 -0
- comply54-0.2.0/tests/test_sectors.py +135 -0
comply54-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comply54
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: African AI governance compliance — enforcement engine and sector packs for NDPA, CBN, NHA, NAICOM, KDPA, POPIA and 15+ African regulatory frameworks. LangGraph-native guard node included.
|
|
5
|
+
Author-email: Oluwajuwon Omotayo <ginuxtechacademy@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://comply54.io
|
|
8
|
+
Project-URL: Repository, https://github.com/comply54/comply54
|
|
9
|
+
Project-URL: Issues, https://github.com/comply54/comply54/issues
|
|
10
|
+
Keywords: comply54,africa,compliance,ai-governance,ndpa,cbn,kdpa,popia,rego,opa,fintech,data-protection,nigeria,kenya
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Security
|
|
14
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: regopy>=1.4.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Provides-Extra: langchain
|
|
25
|
+
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
|
|
26
|
+
Provides-Extra: langgraph
|
|
27
|
+
Requires-Dist: langchain-core>=0.1.0; extra == "langgraph"
|
|
28
|
+
Requires-Dist: langgraph>=0.2.0; extra == "langgraph"
|
|
29
|
+
Requires-Dist: langchain-anthropic>=0.2.0; extra == "langgraph"
|
|
30
|
+
Provides-Extra: crewai
|
|
31
|
+
Requires-Dist: crewai>=0.28.0; extra == "crewai"
|
|
32
|
+
Provides-Extra: autogen
|
|
33
|
+
Requires-Dist: pyautogen>=0.2.0; extra == "autogen"
|
|
34
|
+
Provides-Extra: all
|
|
35
|
+
Requires-Dist: langchain-core>=0.1.0; extra == "all"
|
|
36
|
+
Requires-Dist: langgraph>=0.2.0; extra == "all"
|
|
37
|
+
Requires-Dist: langchain-anthropic>=0.2.0; extra == "all"
|
|
38
|
+
Requires-Dist: crewai>=0.28.0; extra == "all"
|
|
39
|
+
Requires-Dist: pyautogen>=0.2.0; extra == "all"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
43
|
+
Requires-Dist: ruff; extra == "dev"
|
|
44
|
+
Requires-Dist: pyright; extra == "dev"
|
|
45
|
+
|
|
46
|
+
# Comply54
|
|
47
|
+
|
|
48
|
+
**Open-source AI governance enforcement for African regulatory compliance.**
|
|
49
|
+
|
|
50
|
+
[](https://github.com/comply54/comply54/actions/workflows/ci.yml)
|
|
51
|
+
[](https://codecov.io/gh/comply54/comply54)
|
|
52
|
+
[](https://pypi.org/project/comply54)
|
|
53
|
+
[](https://www.npmjs.com/package/@comply54/core)
|
|
54
|
+
[](https://pypi.org/project/comply54)
|
|
55
|
+
[](LICENSE)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## What it does
|
|
60
|
+
|
|
61
|
+
Comply54 intercepts AI agent tool calls and evaluates them against African regulatory frameworks — CBN, NDPA, NHA, NAICOM, KDPA, POPIA, and more — **before execution**. Blocked calls never reach the tool.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
Agent decides to call transfer_funds(amount=15_000_000)
|
|
65
|
+
│
|
|
66
|
+
▼
|
|
67
|
+
comply54 guard ──► CBN NIP cap exceeded ──► ToolMessage error returned
|
|
68
|
+
│ Agent explains to user
|
|
69
|
+
✗ tool never executes
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
No OPA binary required. No subprocess. Works in serverless environments.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## How it relates to agt-policies-nigeria
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
kingztech2019/agt-policies-nigeria comply54
|
|
80
|
+
────────────────────────────────── ────────────────────────────────────
|
|
81
|
+
The policy SOURCE. The enforcement and tooling LAYER.
|
|
82
|
+
|
|
83
|
+
• Rego policy packs (NDPA, CBN, ...) ──▶ • PackSpec registry indexes them
|
|
84
|
+
• Cited in Microsoft AGT main ──▶ • Sector classes compose them
|
|
85
|
+
• OPA tests (306 passing) ──▶ • LangGraph / CrewAI / AutoGen adapters
|
|
86
|
+
• Stays at kingztech2019 forever ──▶ • regopy evaluates in-process (no binary)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`agt-policies-nigeria` is where the policy files live — permanently cited in
|
|
90
|
+
[Microsoft Agent-OS](https://github.com/microsoft/agent-governance-toolkit).
|
|
91
|
+
|
|
92
|
+
`comply54` is where the ecosystem lives — the enforcement engine, sector compositions,
|
|
93
|
+
framework adapters, and CI tooling that make those policies consumable from LangChain,
|
|
94
|
+
LangGraph, CrewAI, AutoGen, and any OPA pipeline.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Quick Start
|
|
99
|
+
|
|
100
|
+
### Install
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Core (no framework)
|
|
104
|
+
pip install comply54
|
|
105
|
+
|
|
106
|
+
# With LangGraph / LangChain
|
|
107
|
+
pip install "comply54[langgraph]"
|
|
108
|
+
|
|
109
|
+
# With CrewAI
|
|
110
|
+
pip install "comply54[crewai]"
|
|
111
|
+
|
|
112
|
+
# Everything
|
|
113
|
+
pip install "comply54[all]"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Nigerian Fintech Agent (LangGraph)
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from comply54.sectors import NigeriaFintechCompliance
|
|
120
|
+
from comply54.langchain import Comply54Guard, comply54_route
|
|
121
|
+
from langgraph.graph import END, StateGraph
|
|
122
|
+
from langgraph.prebuilt import ToolNode
|
|
123
|
+
|
|
124
|
+
compliance = NigeriaFintechCompliance()
|
|
125
|
+
guard = Comply54Guard(compliance, context={"kyc_tier": 3})
|
|
126
|
+
|
|
127
|
+
graph = StateGraph(AgentState)
|
|
128
|
+
graph.add_node("agent", call_model)
|
|
129
|
+
graph.add_node("comply54_guard", guard) # intercepts before tools run
|
|
130
|
+
graph.add_node("tools", ToolNode(tools))
|
|
131
|
+
|
|
132
|
+
graph.add_conditional_edges("agent", should_continue,
|
|
133
|
+
{"comply54_guard": "comply54_guard", END: END})
|
|
134
|
+
graph.add_conditional_edges("comply54_guard", comply54_route,
|
|
135
|
+
{"tools": "tools", "agent": "agent"}) # blocked → agent, clear → tools
|
|
136
|
+
graph.add_edge("tools", "agent")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Direct check (no framework)
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from comply54.sectors import NigeriaFintechCompliance
|
|
143
|
+
|
|
144
|
+
compliance = NigeriaFintechCompliance()
|
|
145
|
+
|
|
146
|
+
result = compliance.check(
|
|
147
|
+
action="transfer_funds",
|
|
148
|
+
params={"amount": 15_000_000, "currency": "NGN"},
|
|
149
|
+
context={"kyc_tier": 3},
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
print(result.overall) # "deny"
|
|
153
|
+
print(result.primary_violation.messages[0]) # "CBN NIP Framework: ..."
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Compliance certificate (for auditors)
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
cert = compliance.certificate(
|
|
160
|
+
action="transfer_funds",
|
|
161
|
+
params={"amount": 5_000_000, "currency": "NGN"},
|
|
162
|
+
context={"kyc_tier": 3},
|
|
163
|
+
)
|
|
164
|
+
print(cert.to_json()) # tamper-evident JSON with SHA-256 integrity hash
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Sector Packs
|
|
170
|
+
|
|
171
|
+
Sector packs are the main entry point. One import wires up all relevant regulatory frameworks for your use case.
|
|
172
|
+
|
|
173
|
+
### Nigerian Sector Packs
|
|
174
|
+
|
|
175
|
+
| Sector class | Regulations covered | Use case |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| `NigeriaFintechCompliance` | NDPA + CBN + BVN/NIN + NFIU AML + OWASP | Payment agents, digital banking |
|
|
178
|
+
| `NigeriaHealthcareCompliance` | NHA 2014 + NDPA (special-category) + FMOH AI Policy + OWASP | EHR agents, clinical decision support |
|
|
179
|
+
| `NigeriaInsuranceCompliance` | Insurance Act 2003 + NAICOM Guidelines + NFIU AML + NDPA + OWASP | Claims processing, underwriting |
|
|
180
|
+
|
|
181
|
+
### Other Sector Packs
|
|
182
|
+
|
|
183
|
+
| Sector class | Jurisdictions | Use case |
|
|
184
|
+
|---|---|---|
|
|
185
|
+
| `KenyaFintechCompliance` | KE | Kenyan payment agents |
|
|
186
|
+
| `PanAfricanFintechCompliance` | NG, KE, ZA, GH, RW, EG, ET, MU, TZ, UG | Multi-market agents |
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from comply54.sectors import (
|
|
190
|
+
NigeriaFintechCompliance,
|
|
191
|
+
NigeriaHealthcareCompliance,
|
|
192
|
+
NigeriaInsuranceCompliance,
|
|
193
|
+
KenyaFintechCompliance,
|
|
194
|
+
PanAfricanFintechCompliance,
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Policy Packs
|
|
201
|
+
|
|
202
|
+
All packs use in-process Rego evaluation via `regopy` — no OPA binary required.
|
|
203
|
+
|
|
204
|
+
### Universal Agent Safety Controls
|
|
205
|
+
|
|
206
|
+
| Pack ID | Regulation | OWASP Ref |
|
|
207
|
+
|---|---|---|
|
|
208
|
+
| `universal/prompt-injection` | OWASP Agentic AI — LLM01/ASI01 | LLM01 |
|
|
209
|
+
| `universal/pii-leakage` | OWASP LLM06 — Sensitive Information Disclosure | LLM06 |
|
|
210
|
+
| `universal/tool-permissions` | OWASP LLM08 — Excessive Agency | LLM08 |
|
|
211
|
+
| `universal/human-approval` | OWASP LLM09 — Overreliance | LLM09 |
|
|
212
|
+
| `universal/model-routing` | OWASP LLM03/LLM05 — Model Selection Controls | LLM03/LLM05 |
|
|
213
|
+
|
|
214
|
+
### Nigerian Regulatory Packs
|
|
215
|
+
|
|
216
|
+
| Pack ID | Regulation | Authority |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| `nigeria/ndpa` | Nigeria Data Protection Act 2023 | NDPC |
|
|
219
|
+
| `nigeria/cbn` | CBN Transaction Limits & Tiered KYC (FPR/DIR/GEN/CIR/07/003) | CBN |
|
|
220
|
+
| `nigeria/bvn-nin` | CBN BVN Framework & NIBSS Scheme Rules | CBN / NIBSS |
|
|
221
|
+
| `nigeria/nfiu-aml` | MLPPA 2022 / NFIU AML Guidelines | NFIU |
|
|
222
|
+
| `nigeria/nha` | Nigeria National Health Act 2014 / FMOH AI Policy | FMOH / MDCN |
|
|
223
|
+
| `nigeria/naicom` | Insurance Act 2003 / NAICOM Operational Guidelines 2021 / Market Conduct 2023 | NAICOM |
|
|
224
|
+
|
|
225
|
+
### East Africa
|
|
226
|
+
|
|
227
|
+
| Pack ID | Regulation | Authority |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| `kenya/kdpa` | Kenya Data Protection Act 2019 | ODPC |
|
|
230
|
+
| `mauritius/dpa` | Mauritius Data Protection Act 2017 | DPC Mauritius |
|
|
231
|
+
| `tanzania/pdpa` | Tanzania Personal Data Protection Act 2022 | PDPC Tanzania |
|
|
232
|
+
| `uganda/dppa` | Uganda Data Protection and Privacy Act 2019 | PDPO Uganda |
|
|
233
|
+
| `ethiopia/pdp` | Ethiopia Personal Data Protection Proclamation 1321/2024 | ECA |
|
|
234
|
+
| `rwanda/dpa` | Rwanda Law No. 058/2021 on Personal Data Protection | RISA |
|
|
235
|
+
|
|
236
|
+
### Southern Africa
|
|
237
|
+
|
|
238
|
+
| Pack ID | Regulation | Authority |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `south-africa/popia` | Protection of Personal Information Act 4 of 2013 | Information Regulator ZA |
|
|
241
|
+
|
|
242
|
+
### West Africa
|
|
243
|
+
|
|
244
|
+
| Pack ID | Regulation | Authority |
|
|
245
|
+
|---|---|---|
|
|
246
|
+
| `ghana/dpa` | Ghana Data Protection Act 843 of 2012 | DPC Ghana |
|
|
247
|
+
|
|
248
|
+
### North Africa
|
|
249
|
+
|
|
250
|
+
| Pack ID | Regulation | Authority |
|
|
251
|
+
|---|---|---|
|
|
252
|
+
| `egypt/pdpl` | Egypt Personal Data Protection Law No. 151/2020 | PDPRL Egypt |
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## Framework Adapters
|
|
257
|
+
|
|
258
|
+
### LangGraph (recommended)
|
|
259
|
+
|
|
260
|
+
```python
|
|
261
|
+
from comply54.langchain import Comply54Guard, comply54_route
|
|
262
|
+
|
|
263
|
+
# Comply54Guard is a callable LangGraph node.
|
|
264
|
+
# It reads AIMessage.tool_calls, evaluates each via comply54,
|
|
265
|
+
# and injects ToolMessage errors for any blocked calls.
|
|
266
|
+
|
|
267
|
+
guard = Comply54Guard(
|
|
268
|
+
NigeriaFintechCompliance(),
|
|
269
|
+
context={"kyc_tier": 3},
|
|
270
|
+
block_on_escalate=False, # True = escalate decisions also block
|
|
271
|
+
)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### LangChain StructuredTool
|
|
275
|
+
|
|
276
|
+
```python
|
|
277
|
+
from comply54.langchain import comply54_tool
|
|
278
|
+
|
|
279
|
+
# Exposes comply54 as a tool the agent can call to self-check
|
|
280
|
+
tool = comply54_tool(NigeriaFintechCompliance())
|
|
281
|
+
agent = create_react_agent(llm, tools=[*my_tools, tool])
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### CrewAI
|
|
285
|
+
|
|
286
|
+
```python
|
|
287
|
+
from comply54.crewai import build_compliance_tools
|
|
288
|
+
|
|
289
|
+
tools = build_compliance_tools(NigeriaFintechCompliance())
|
|
290
|
+
agent = Agent(role="Fintech Agent", tools=tools, ...)
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### AutoGen
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from comply54.autogen import ComplianceMiddleware
|
|
297
|
+
|
|
298
|
+
middleware = ComplianceMiddleware(NigeriaFintechCompliance())
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Direct OPA (from agt-policies-nigeria)
|
|
302
|
+
|
|
303
|
+
```bash
|
|
304
|
+
git clone https://github.com/kingztech2019/agt-policies-nigeria
|
|
305
|
+
cd agt-policies-nigeria
|
|
306
|
+
opa test policies/rego/ -v # 306 tests
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Example Agents
|
|
312
|
+
|
|
313
|
+
Three complete LangGraph demo agents are in `examples/`:
|
|
314
|
+
|
|
315
|
+
| Example | Sector | Regulations demonstrated |
|
|
316
|
+
|---|---|---|
|
|
317
|
+
| `examples/nigeria_fintech_agent/` | Fintech | CBN NIP cap, Tier KYC limits, Maker-Checker, NFIU AML |
|
|
318
|
+
| `examples/nigeria_health_agent/` | Healthcare | NHA patient consent, AI diagnosis oversight, NDPA special-category |
|
|
319
|
+
| `examples/nigeria_insurance_agent/` | Insurance | NAICOM auto-denial cap, anti-discrimination, life underwriting, fraud |
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
323
|
+
cd examples/nigeria_fintech_agent && python agent.py
|
|
324
|
+
cd examples/nigeria_health_agent && python agent.py
|
|
325
|
+
cd examples/nigeria_insurance_agent && python agent.py
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Adding a New Pack
|
|
331
|
+
|
|
332
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide. Quick summary:
|
|
333
|
+
|
|
334
|
+
1. Write `comply54/packs/<jurisdiction>/<pack>.rego` with Rego `deny`, `escalate`, `audit`, `allow` rules
|
|
335
|
+
2. Add a `PackSpec` entry in `comply54/core/packs.py`
|
|
336
|
+
3. Compose it into a sector class in `comply54/sectors/`
|
|
337
|
+
4. Add tests in `tests/`
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Validation & CI
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
pip install -e ".[dev]"
|
|
345
|
+
|
|
346
|
+
# Run all tests
|
|
347
|
+
pytest tests/ -v
|
|
348
|
+
|
|
349
|
+
# Validate pack registry
|
|
350
|
+
python tools/validate.py
|
|
351
|
+
|
|
352
|
+
# OPA tests (requires opa binary)
|
|
353
|
+
opa test comply54/packs/ -v
|
|
354
|
+
|
|
355
|
+
# Lint Rego
|
|
356
|
+
regal lint comply54/packs/
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Disclaimer
|
|
362
|
+
|
|
363
|
+
Comply54 policy packs are community-maintained governance **starter templates**, not
|
|
364
|
+
certified legal compliance instruments. Organisations must perform their own assessments
|
|
365
|
+
with qualified legal and regulatory advisors before deploying in regulated environments.
|
comply54-0.2.0/README.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Comply54
|
|
2
|
+
|
|
3
|
+
**Open-source AI governance enforcement for African regulatory compliance.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/comply54/comply54/actions/workflows/ci.yml)
|
|
6
|
+
[](https://codecov.io/gh/comply54/comply54)
|
|
7
|
+
[](https://pypi.org/project/comply54)
|
|
8
|
+
[](https://www.npmjs.com/package/@comply54/core)
|
|
9
|
+
[](https://pypi.org/project/comply54)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
Comply54 intercepts AI agent tool calls and evaluates them against African regulatory frameworks — CBN, NDPA, NHA, NAICOM, KDPA, POPIA, and more — **before execution**. Blocked calls never reach the tool.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Agent decides to call transfer_funds(amount=15_000_000)
|
|
20
|
+
│
|
|
21
|
+
▼
|
|
22
|
+
comply54 guard ──► CBN NIP cap exceeded ──► ToolMessage error returned
|
|
23
|
+
│ Agent explains to user
|
|
24
|
+
✗ tool never executes
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
No OPA binary required. No subprocess. Works in serverless environments.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## How it relates to agt-policies-nigeria
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
kingztech2019/agt-policies-nigeria comply54
|
|
35
|
+
────────────────────────────────── ────────────────────────────────────
|
|
36
|
+
The policy SOURCE. The enforcement and tooling LAYER.
|
|
37
|
+
|
|
38
|
+
• Rego policy packs (NDPA, CBN, ...) ──▶ • PackSpec registry indexes them
|
|
39
|
+
• Cited in Microsoft AGT main ──▶ • Sector classes compose them
|
|
40
|
+
• OPA tests (306 passing) ──▶ • LangGraph / CrewAI / AutoGen adapters
|
|
41
|
+
• Stays at kingztech2019 forever ──▶ • regopy evaluates in-process (no binary)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`agt-policies-nigeria` is where the policy files live — permanently cited in
|
|
45
|
+
[Microsoft Agent-OS](https://github.com/microsoft/agent-governance-toolkit).
|
|
46
|
+
|
|
47
|
+
`comply54` is where the ecosystem lives — the enforcement engine, sector compositions,
|
|
48
|
+
framework adapters, and CI tooling that make those policies consumable from LangChain,
|
|
49
|
+
LangGraph, CrewAI, AutoGen, and any OPA pipeline.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
### Install
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Core (no framework)
|
|
59
|
+
pip install comply54
|
|
60
|
+
|
|
61
|
+
# With LangGraph / LangChain
|
|
62
|
+
pip install "comply54[langgraph]"
|
|
63
|
+
|
|
64
|
+
# With CrewAI
|
|
65
|
+
pip install "comply54[crewai]"
|
|
66
|
+
|
|
67
|
+
# Everything
|
|
68
|
+
pip install "comply54[all]"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Nigerian Fintech Agent (LangGraph)
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from comply54.sectors import NigeriaFintechCompliance
|
|
75
|
+
from comply54.langchain import Comply54Guard, comply54_route
|
|
76
|
+
from langgraph.graph import END, StateGraph
|
|
77
|
+
from langgraph.prebuilt import ToolNode
|
|
78
|
+
|
|
79
|
+
compliance = NigeriaFintechCompliance()
|
|
80
|
+
guard = Comply54Guard(compliance, context={"kyc_tier": 3})
|
|
81
|
+
|
|
82
|
+
graph = StateGraph(AgentState)
|
|
83
|
+
graph.add_node("agent", call_model)
|
|
84
|
+
graph.add_node("comply54_guard", guard) # intercepts before tools run
|
|
85
|
+
graph.add_node("tools", ToolNode(tools))
|
|
86
|
+
|
|
87
|
+
graph.add_conditional_edges("agent", should_continue,
|
|
88
|
+
{"comply54_guard": "comply54_guard", END: END})
|
|
89
|
+
graph.add_conditional_edges("comply54_guard", comply54_route,
|
|
90
|
+
{"tools": "tools", "agent": "agent"}) # blocked → agent, clear → tools
|
|
91
|
+
graph.add_edge("tools", "agent")
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Direct check (no framework)
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from comply54.sectors import NigeriaFintechCompliance
|
|
98
|
+
|
|
99
|
+
compliance = NigeriaFintechCompliance()
|
|
100
|
+
|
|
101
|
+
result = compliance.check(
|
|
102
|
+
action="transfer_funds",
|
|
103
|
+
params={"amount": 15_000_000, "currency": "NGN"},
|
|
104
|
+
context={"kyc_tier": 3},
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
print(result.overall) # "deny"
|
|
108
|
+
print(result.primary_violation.messages[0]) # "CBN NIP Framework: ..."
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Compliance certificate (for auditors)
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
cert = compliance.certificate(
|
|
115
|
+
action="transfer_funds",
|
|
116
|
+
params={"amount": 5_000_000, "currency": "NGN"},
|
|
117
|
+
context={"kyc_tier": 3},
|
|
118
|
+
)
|
|
119
|
+
print(cert.to_json()) # tamper-evident JSON with SHA-256 integrity hash
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Sector Packs
|
|
125
|
+
|
|
126
|
+
Sector packs are the main entry point. One import wires up all relevant regulatory frameworks for your use case.
|
|
127
|
+
|
|
128
|
+
### Nigerian Sector Packs
|
|
129
|
+
|
|
130
|
+
| Sector class | Regulations covered | Use case |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| `NigeriaFintechCompliance` | NDPA + CBN + BVN/NIN + NFIU AML + OWASP | Payment agents, digital banking |
|
|
133
|
+
| `NigeriaHealthcareCompliance` | NHA 2014 + NDPA (special-category) + FMOH AI Policy + OWASP | EHR agents, clinical decision support |
|
|
134
|
+
| `NigeriaInsuranceCompliance` | Insurance Act 2003 + NAICOM Guidelines + NFIU AML + NDPA + OWASP | Claims processing, underwriting |
|
|
135
|
+
|
|
136
|
+
### Other Sector Packs
|
|
137
|
+
|
|
138
|
+
| Sector class | Jurisdictions | Use case |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `KenyaFintechCompliance` | KE | Kenyan payment agents |
|
|
141
|
+
| `PanAfricanFintechCompliance` | NG, KE, ZA, GH, RW, EG, ET, MU, TZ, UG | Multi-market agents |
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from comply54.sectors import (
|
|
145
|
+
NigeriaFintechCompliance,
|
|
146
|
+
NigeriaHealthcareCompliance,
|
|
147
|
+
NigeriaInsuranceCompliance,
|
|
148
|
+
KenyaFintechCompliance,
|
|
149
|
+
PanAfricanFintechCompliance,
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Policy Packs
|
|
156
|
+
|
|
157
|
+
All packs use in-process Rego evaluation via `regopy` — no OPA binary required.
|
|
158
|
+
|
|
159
|
+
### Universal Agent Safety Controls
|
|
160
|
+
|
|
161
|
+
| Pack ID | Regulation | OWASP Ref |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| `universal/prompt-injection` | OWASP Agentic AI — LLM01/ASI01 | LLM01 |
|
|
164
|
+
| `universal/pii-leakage` | OWASP LLM06 — Sensitive Information Disclosure | LLM06 |
|
|
165
|
+
| `universal/tool-permissions` | OWASP LLM08 — Excessive Agency | LLM08 |
|
|
166
|
+
| `universal/human-approval` | OWASP LLM09 — Overreliance | LLM09 |
|
|
167
|
+
| `universal/model-routing` | OWASP LLM03/LLM05 — Model Selection Controls | LLM03/LLM05 |
|
|
168
|
+
|
|
169
|
+
### Nigerian Regulatory Packs
|
|
170
|
+
|
|
171
|
+
| Pack ID | Regulation | Authority |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `nigeria/ndpa` | Nigeria Data Protection Act 2023 | NDPC |
|
|
174
|
+
| `nigeria/cbn` | CBN Transaction Limits & Tiered KYC (FPR/DIR/GEN/CIR/07/003) | CBN |
|
|
175
|
+
| `nigeria/bvn-nin` | CBN BVN Framework & NIBSS Scheme Rules | CBN / NIBSS |
|
|
176
|
+
| `nigeria/nfiu-aml` | MLPPA 2022 / NFIU AML Guidelines | NFIU |
|
|
177
|
+
| `nigeria/nha` | Nigeria National Health Act 2014 / FMOH AI Policy | FMOH / MDCN |
|
|
178
|
+
| `nigeria/naicom` | Insurance Act 2003 / NAICOM Operational Guidelines 2021 / Market Conduct 2023 | NAICOM |
|
|
179
|
+
|
|
180
|
+
### East Africa
|
|
181
|
+
|
|
182
|
+
| Pack ID | Regulation | Authority |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| `kenya/kdpa` | Kenya Data Protection Act 2019 | ODPC |
|
|
185
|
+
| `mauritius/dpa` | Mauritius Data Protection Act 2017 | DPC Mauritius |
|
|
186
|
+
| `tanzania/pdpa` | Tanzania Personal Data Protection Act 2022 | PDPC Tanzania |
|
|
187
|
+
| `uganda/dppa` | Uganda Data Protection and Privacy Act 2019 | PDPO Uganda |
|
|
188
|
+
| `ethiopia/pdp` | Ethiopia Personal Data Protection Proclamation 1321/2024 | ECA |
|
|
189
|
+
| `rwanda/dpa` | Rwanda Law No. 058/2021 on Personal Data Protection | RISA |
|
|
190
|
+
|
|
191
|
+
### Southern Africa
|
|
192
|
+
|
|
193
|
+
| Pack ID | Regulation | Authority |
|
|
194
|
+
|---|---|---|
|
|
195
|
+
| `south-africa/popia` | Protection of Personal Information Act 4 of 2013 | Information Regulator ZA |
|
|
196
|
+
|
|
197
|
+
### West Africa
|
|
198
|
+
|
|
199
|
+
| Pack ID | Regulation | Authority |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `ghana/dpa` | Ghana Data Protection Act 843 of 2012 | DPC Ghana |
|
|
202
|
+
|
|
203
|
+
### North Africa
|
|
204
|
+
|
|
205
|
+
| Pack ID | Regulation | Authority |
|
|
206
|
+
|---|---|---|
|
|
207
|
+
| `egypt/pdpl` | Egypt Personal Data Protection Law No. 151/2020 | PDPRL Egypt |
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Framework Adapters
|
|
212
|
+
|
|
213
|
+
### LangGraph (recommended)
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from comply54.langchain import Comply54Guard, comply54_route
|
|
217
|
+
|
|
218
|
+
# Comply54Guard is a callable LangGraph node.
|
|
219
|
+
# It reads AIMessage.tool_calls, evaluates each via comply54,
|
|
220
|
+
# and injects ToolMessage errors for any blocked calls.
|
|
221
|
+
|
|
222
|
+
guard = Comply54Guard(
|
|
223
|
+
NigeriaFintechCompliance(),
|
|
224
|
+
context={"kyc_tier": 3},
|
|
225
|
+
block_on_escalate=False, # True = escalate decisions also block
|
|
226
|
+
)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### LangChain StructuredTool
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
from comply54.langchain import comply54_tool
|
|
233
|
+
|
|
234
|
+
# Exposes comply54 as a tool the agent can call to self-check
|
|
235
|
+
tool = comply54_tool(NigeriaFintechCompliance())
|
|
236
|
+
agent = create_react_agent(llm, tools=[*my_tools, tool])
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### CrewAI
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from comply54.crewai import build_compliance_tools
|
|
243
|
+
|
|
244
|
+
tools = build_compliance_tools(NigeriaFintechCompliance())
|
|
245
|
+
agent = Agent(role="Fintech Agent", tools=tools, ...)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### AutoGen
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from comply54.autogen import ComplianceMiddleware
|
|
252
|
+
|
|
253
|
+
middleware = ComplianceMiddleware(NigeriaFintechCompliance())
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Direct OPA (from agt-policies-nigeria)
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
git clone https://github.com/kingztech2019/agt-policies-nigeria
|
|
260
|
+
cd agt-policies-nigeria
|
|
261
|
+
opa test policies/rego/ -v # 306 tests
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Example Agents
|
|
267
|
+
|
|
268
|
+
Three complete LangGraph demo agents are in `examples/`:
|
|
269
|
+
|
|
270
|
+
| Example | Sector | Regulations demonstrated |
|
|
271
|
+
|---|---|---|
|
|
272
|
+
| `examples/nigeria_fintech_agent/` | Fintech | CBN NIP cap, Tier KYC limits, Maker-Checker, NFIU AML |
|
|
273
|
+
| `examples/nigeria_health_agent/` | Healthcare | NHA patient consent, AI diagnosis oversight, NDPA special-category |
|
|
274
|
+
| `examples/nigeria_insurance_agent/` | Insurance | NAICOM auto-denial cap, anti-discrimination, life underwriting, fraud |
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
278
|
+
cd examples/nigeria_fintech_agent && python agent.py
|
|
279
|
+
cd examples/nigeria_health_agent && python agent.py
|
|
280
|
+
cd examples/nigeria_insurance_agent && python agent.py
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Adding a New Pack
|
|
286
|
+
|
|
287
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide. Quick summary:
|
|
288
|
+
|
|
289
|
+
1. Write `comply54/packs/<jurisdiction>/<pack>.rego` with Rego `deny`, `escalate`, `audit`, `allow` rules
|
|
290
|
+
2. Add a `PackSpec` entry in `comply54/core/packs.py`
|
|
291
|
+
3. Compose it into a sector class in `comply54/sectors/`
|
|
292
|
+
4. Add tests in `tests/`
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Validation & CI
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
pip install -e ".[dev]"
|
|
300
|
+
|
|
301
|
+
# Run all tests
|
|
302
|
+
pytest tests/ -v
|
|
303
|
+
|
|
304
|
+
# Validate pack registry
|
|
305
|
+
python tools/validate.py
|
|
306
|
+
|
|
307
|
+
# OPA tests (requires opa binary)
|
|
308
|
+
opa test comply54/packs/ -v
|
|
309
|
+
|
|
310
|
+
# Lint Rego
|
|
311
|
+
regal lint comply54/packs/
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Disclaimer
|
|
317
|
+
|
|
318
|
+
Comply54 policy packs are community-maintained governance **starter templates**, not
|
|
319
|
+
certified legal compliance instruments. Organisations must perform their own assessments
|
|
320
|
+
with qualified legal and regulatory advisors before deploying in regulated environments.
|