ava-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.
- ava_protocol-0.1.0/.github/workflows/ci.yml +75 -0
- ava_protocol-0.1.0/.github/workflows/publish.yml +39 -0
- ava_protocol-0.1.0/.gitignore +54 -0
- ava_protocol-0.1.0/CHANGELOG.md +46 -0
- ava_protocol-0.1.0/LICENSE +21 -0
- ava_protocol-0.1.0/PKG-INFO +335 -0
- ava_protocol-0.1.0/PUBLISH.md +281 -0
- ava_protocol-0.1.0/README.md +287 -0
- ava_protocol-0.1.0/SETUP.md +279 -0
- ava_protocol-0.1.0/pyproject.toml +94 -0
- ava_protocol-0.1.0/src/ava/__init__.py +23 -0
- ava_protocol-0.1.0/src/ava/client.py +157 -0
- ava_protocol-0.1.0/src/ava/config.py +51 -0
- ava_protocol-0.1.0/src/ava/engines/__init__.py +9 -0
- ava_protocol-0.1.0/src/ava/engines/base.py +42 -0
- ava_protocol-0.1.0/src/ava/engines/presidio.py +113 -0
- ava_protocol-0.1.0/src/ava/gateways/__init__.py +4 -0
- ava_protocol-0.1.0/src/ava/gateways/http.py +46 -0
- ava_protocol-0.1.0/src/ava/protocol/__init__.py +12 -0
- ava_protocol-0.1.0/src/ava/protocol/entities.py +18 -0
- ava_protocol-0.1.0/src/ava/protocol/manifest.py +82 -0
- ava_protocol-0.1.0/src/ava/protocol/token_vault.py +167 -0
- ava_protocol-0.1.0/src/ava/session.py +128 -0
- ava_protocol-0.1.0/test_ava.py +34 -0
- ava_protocol-0.1.0/tests/__init__.py +0 -0
- ava_protocol-0.1.0/tests/test_engines.py +65 -0
- ava_protocol-0.1.0/tests/test_protocol.py +139 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ['3.9', '3.10', '3.11', '3.12']
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
pip install -e ".[dev]"
|
|
29
|
+
|
|
30
|
+
- name: Lint with ruff
|
|
31
|
+
run: |
|
|
32
|
+
ruff check src/ava tests/
|
|
33
|
+
|
|
34
|
+
- name: Format check with black
|
|
35
|
+
run: |
|
|
36
|
+
black --check src/ava tests/
|
|
37
|
+
|
|
38
|
+
- name: Type check with mypy
|
|
39
|
+
run: |
|
|
40
|
+
mypy src/ava
|
|
41
|
+
continue-on-error: true
|
|
42
|
+
|
|
43
|
+
- name: Test with pytest
|
|
44
|
+
run: |
|
|
45
|
+
pytest tests/ -v --tb=short
|
|
46
|
+
|
|
47
|
+
- name: Build package
|
|
48
|
+
run: |
|
|
49
|
+
pip install build
|
|
50
|
+
python -m build
|
|
51
|
+
|
|
52
|
+
publish-test:
|
|
53
|
+
needs: test
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
56
|
+
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v4
|
|
59
|
+
|
|
60
|
+
- name: Set up Python
|
|
61
|
+
uses: actions/setup-python@v5
|
|
62
|
+
with:
|
|
63
|
+
python-version: '3.11'
|
|
64
|
+
|
|
65
|
+
- name: Build package
|
|
66
|
+
run: |
|
|
67
|
+
pip install build
|
|
68
|
+
python -m build
|
|
69
|
+
|
|
70
|
+
- name: Upload to TestPyPI
|
|
71
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
72
|
+
with:
|
|
73
|
+
repository-url: https://test.pypi.org/legacy/
|
|
74
|
+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
75
|
+
continue-on-error: true
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write # OIDC trusted publishing
|
|
13
|
+
|
|
14
|
+
environment:
|
|
15
|
+
name: pypi
|
|
16
|
+
url: https://pypi.org/p/ava-protocol
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: '3.11'
|
|
26
|
+
|
|
27
|
+
- name: Install build tools
|
|
28
|
+
run: |
|
|
29
|
+
pip install build
|
|
30
|
+
|
|
31
|
+
- name: Build package
|
|
32
|
+
run: |
|
|
33
|
+
python -m build
|
|
34
|
+
|
|
35
|
+
- name: Publish to PyPI
|
|
36
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
37
|
+
# Uncomment for API token auth if not using OIDC:
|
|
38
|
+
# with:
|
|
39
|
+
# password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
venv/
|
|
25
|
+
env/
|
|
26
|
+
ENV/
|
|
27
|
+
|
|
28
|
+
# IDE
|
|
29
|
+
.vscode/
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
*~
|
|
34
|
+
|
|
35
|
+
# Testing
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
.coverage
|
|
38
|
+
htmlcov/
|
|
39
|
+
|
|
40
|
+
# MyPy
|
|
41
|
+
.mypy_cache/
|
|
42
|
+
.dmypy_cache/
|
|
43
|
+
|
|
44
|
+
# Environment
|
|
45
|
+
.env
|
|
46
|
+
.env.local
|
|
47
|
+
|
|
48
|
+
# macOS
|
|
49
|
+
.DS_Store
|
|
50
|
+
|
|
51
|
+
# Model files (large)
|
|
52
|
+
*.bin
|
|
53
|
+
*.pkl
|
|
54
|
+
*.h5
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Authors
|
|
4
|
+
|
|
5
|
+
- Gerald Enrique Nelson Mc Kenzie (https://github.com/lordxmen2k)
|
|
6
|
+
|
|
7
|
+
## Date
|
|
8
|
+
|
|
9
|
+
- 3/13/2026
|
|
10
|
+
|
|
11
|
+
All notable changes to the AVA Protocol project will be documented in this file.
|
|
12
|
+
|
|
13
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
14
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
15
|
+
|
|
16
|
+
## [Unreleased]
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- Core protocol layer with AVA Manifest format
|
|
20
|
+
- Pluggable detection engine architecture
|
|
21
|
+
- Microsoft Presidio engine adapter
|
|
22
|
+
- Mock engine for testing
|
|
23
|
+
- Memory-based and SQLite token vaults
|
|
24
|
+
- HTTP gateway client for remote AVA services
|
|
25
|
+
- Configuration management (env, YAML, dict)
|
|
26
|
+
- Context manager session interface
|
|
27
|
+
|
|
28
|
+
### Security
|
|
29
|
+
- Zero-retention token vault with configurable TTL
|
|
30
|
+
- Session-scoped token isolation
|
|
31
|
+
- Hash-only audit trails (no original values in manifests)
|
|
32
|
+
|
|
33
|
+
## [0.1.0] - 2025-03-13
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
- Initial release of AVA Protocol Python library
|
|
37
|
+
- Basic client interface with embedded and gateway modes
|
|
38
|
+
- PyPI package with optional dependencies: `[local]`, `[aws]`, `[all]`
|
|
39
|
+
- Complete documentation: README, PUBLISH guide
|
|
40
|
+
- CI/CD with GitHub Actions (test, build, publish)
|
|
41
|
+
- MIT License
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
[Unreleased]: https://github.com/ava-protocol/ava-protocol/compare/v0.1.0...HEAD
|
|
46
|
+
[0.1.0]: https://github.com/ava-protocol/ava-protocol/releases/tag/v0.1.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AVA Protocol Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ava-protocol
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AVA - AI Visibility Anonymizer Protocol
|
|
5
|
+
Project-URL: Homepage, https://github.com/ava-protocol/ava-protocol
|
|
6
|
+
Project-URL: Documentation, https://ava-protocol.readthedocs.io
|
|
7
|
+
Project-URL: Repository, https://github.com/ava-protocol/ava-protocol
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/ava-protocol/ava-protocol/issues
|
|
9
|
+
Author-email: Gerald Enrique Nelson Mc Kenzie <lordxmen2k@gmail.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,anonymization,data-protection,gdpr,hipaa,llm,pii,presidio,privacy,security
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Text Processing
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: httpx>=0.25.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: boto3>=1.28.0; extra == 'all'
|
|
30
|
+
Requires-Dist: presidio-analyzer>=2.2.0; extra == 'all'
|
|
31
|
+
Requires-Dist: presidio-anonymizer>=2.2.0; extra == 'all'
|
|
32
|
+
Requires-Dist: spacy>=3.7.0; extra == 'all'
|
|
33
|
+
Provides-Extra: aws
|
|
34
|
+
Requires-Dist: boto3>=1.28.0; extra == 'aws'
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: mypy>=1.5.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest>=7.4.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
42
|
+
Requires-Dist: twine>=4.0.0; extra == 'dev'
|
|
43
|
+
Provides-Extra: local
|
|
44
|
+
Requires-Dist: presidio-analyzer>=2.2.0; extra == 'local'
|
|
45
|
+
Requires-Dist: presidio-anonymizer>=2.2.0; extra == 'local'
|
|
46
|
+
Requires-Dist: spacy>=3.7.0; extra == 'local'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# AVA Protocol ๐ก๏ธ
|
|
50
|
+
|
|
51
|
+
**AI Visibility Anonymizer Protocol** โ A protocol-first approach to privacy-preserving AI interactions.
|
|
52
|
+
|
|
53
|
+
## Authors
|
|
54
|
+
|
|
55
|
+
- Gerald Enrique Nelson Mc Kenzie (https://github.com/lordxmen2k)
|
|
56
|
+
|
|
57
|
+
## Date
|
|
58
|
+
|
|
59
|
+
- 3/13/2026
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
[](https://badge.fury.io/py/ava-protocol)
|
|
63
|
+
[](https://www.python.org/downloads/)
|
|
64
|
+
[](https://opensource.org/licenses/MIT)
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
68
|
+
โ AVA LAYER โ
|
|
69
|
+
โ (AI Visibility Anonymizer Protocol) โ
|
|
70
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
71
|
+
โ INGEST โ DETECT โ CLASSIFY โ TRANSFORM โ AUDIT โ AI โ
|
|
72
|
+
โ โ โ โ
|
|
73
|
+
โ Original Data Clean Responseโ
|
|
74
|
+
โ โ โ โ
|
|
75
|
+
โ RESTORE โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ โ
|
|
76
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## ๐ฏ What is AVA?
|
|
80
|
+
|
|
81
|
+
AVA is an **open protocol** and **Python library** for anonymizing sensitive data before sending it to AI/LLM services, with complete audit trails and reversible tokenization.
|
|
82
|
+
|
|
83
|
+
### Core Principles
|
|
84
|
+
|
|
85
|
+
| Principle | Description |
|
|
86
|
+
|-----------|-------------|
|
|
87
|
+
| **Visibility** | Complete audit trail of what was sanitized and why |
|
|
88
|
+
| **Reversibility** | Secure token vault for restoring original data in responses |
|
|
89
|
+
| **Interoperability** | Works with any AI provider (OpenAI, Anthropic, local models) |
|
|
90
|
+
| **Configurability** | Policy-driven sensitivity levels per use case |
|
|
91
|
+
| **Engine Agnostic** | Pluggable detection engines (Presidio, AWS Macie, etc.) |
|
|
92
|
+
|
|
93
|
+
## ๐ Quick Start
|
|
94
|
+
|
|
95
|
+
### Installation
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Core library only (gateway mode)
|
|
99
|
+
pip install ava-protocol
|
|
100
|
+
|
|
101
|
+
# With local detection engine (Presidio)
|
|
102
|
+
pip install ava-protocol[local]
|
|
103
|
+
|
|
104
|
+
# With all optional dependencies
|
|
105
|
+
pip install ava-protocol[all]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Basic Usage
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import ava
|
|
112
|
+
import openai
|
|
113
|
+
|
|
114
|
+
# Initialize client (local Presidio engine)
|
|
115
|
+
client = ava.Client(
|
|
116
|
+
engine="presidio",
|
|
117
|
+
policy="healthcare_strict",
|
|
118
|
+
retention=3600 # Token expiry in seconds
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Sanitize โ AI โ Restore
|
|
122
|
+
with client.session(reversibility=True) as session:
|
|
123
|
+
# 1. Sanitize PII before sending to AI
|
|
124
|
+
clean_prompt = session.sanitize(
|
|
125
|
+
"Patient John Doe (john.doe@email.com) needs prescription refill"
|
|
126
|
+
)
|
|
127
|
+
# Result: "Patient AVA_PERS_7a3f9k2m (AVA_EMAI_x8n4p5qv) needs prescription refill"
|
|
128
|
+
|
|
129
|
+
# 2. Send to AI (AI never sees original PII)
|
|
130
|
+
response = openai.chat.completions.create(
|
|
131
|
+
model="gpt-4",
|
|
132
|
+
messages=[{"role": "user", "content": clean_prompt}]
|
|
133
|
+
)
|
|
134
|
+
ai_output = response.choices[0].message.content
|
|
135
|
+
|
|
136
|
+
# 3. Restore original values in AI response
|
|
137
|
+
original_response = session.restore(ai_output)
|
|
138
|
+
# Result: "John Doe should contact john.doe@email.com..."
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Gateway Mode (Enterprise)
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
import ava
|
|
145
|
+
|
|
146
|
+
# Connect to centralized AVA Gateway
|
|
147
|
+
client = ava.GatewayClient(
|
|
148
|
+
url="https://ava.internal.company.com",
|
|
149
|
+
api_key="your-api-key",
|
|
150
|
+
policy="finance_strict"
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
with client.session() as session:
|
|
154
|
+
clean = session.sanitize("Invoice to Acme Corp...")
|
|
155
|
+
# ... AI call ...
|
|
156
|
+
original = session.restore(ai_response)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## ๐ Supported Entity Types
|
|
160
|
+
|
|
161
|
+
| Category | Entities | Example |
|
|
162
|
+
|----------|----------|---------|
|
|
163
|
+
| Identity | `PERSON_NAME`, `USERNAME` | "John Doe" โ `AVA_PERS_7a3f9k2m` |
|
|
164
|
+
| Contact | `EMAIL_ADDRESS`, `PHONE_NUMBER` | "john@email.com" โ `AVA_EMAI_x8n4p5qv` |
|
|
165
|
+
| Financial | `CREDIT_CARD`, `BANK_ACCOUNT`, `SSN` | "123-45-6789" โ `AVA_SSN_3x8k9n4p` |
|
|
166
|
+
| Location | `LOCATION`, `IP_ADDRESS` | "192.168.1.1" โ `AVA_IPAD_q2m7n5vx` |
|
|
167
|
+
| Medical | `MEDICAL_LICENSE`, `DIAGNOSIS` | Condition-specific detection |
|
|
168
|
+
|
|
169
|
+
## ๐ง Configuration
|
|
170
|
+
|
|
171
|
+
### Environment Variables
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
export AVA_MODE=embedded # or "gateway"
|
|
175
|
+
export AVA_ENGINE=presidio
|
|
176
|
+
export AVA_POLICY=healthcare_strict
|
|
177
|
+
export AVA_RETENTION=3600
|
|
178
|
+
export AVA_GATEWAY_URL=https://ava.internal.company.com
|
|
179
|
+
export AVA_API_KEY=your-api-key
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### YAML Config
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
# ava-config.yaml
|
|
186
|
+
mode: embedded
|
|
187
|
+
engine: presidio
|
|
188
|
+
policy: finance_strict
|
|
189
|
+
retention: 7200
|
|
190
|
+
|
|
191
|
+
# Or gateway mode:
|
|
192
|
+
mode: gateway
|
|
193
|
+
url: https://ava-gateway.company.com
|
|
194
|
+
api_key: ${AVA_API_KEY}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
import ava
|
|
199
|
+
|
|
200
|
+
config = ava.Config.from_yaml("ava-config.yaml")
|
|
201
|
+
client = ava.create_client(config)
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## ๐๏ธ Architecture
|
|
205
|
+
|
|
206
|
+
### Protocol-First Design
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
210
|
+
โ AVA PROTOCOL SPEC โ โ The standard (IETF-bound)
|
|
211
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
212
|
+
โ AVA Python Library (this repo) โ โ Reference implementation
|
|
213
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
214
|
+
โ โ Presidio | AWS Macie โ โ โ Pluggable engines
|
|
215
|
+
โ โ | Azure PII | Custom โ โ
|
|
216
|
+
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
|
|
217
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Manifest Format
|
|
221
|
+
|
|
222
|
+
Every transformation produces an **AVA Manifest** โ a complete audit record:
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"ava_version": "1.0",
|
|
227
|
+
"manifest_id": "ava-a1b2c3d4-001",
|
|
228
|
+
"timestamp": "2025-03-13T15:05:59Z",
|
|
229
|
+
"policy": {
|
|
230
|
+
"domain": "healthcare",
|
|
231
|
+
"strictness": "strict",
|
|
232
|
+
"reversibility": true
|
|
233
|
+
},
|
|
234
|
+
"entities": [
|
|
235
|
+
{
|
|
236
|
+
"type": "PERSON_NAME",
|
|
237
|
+
"value_hash": "sha256:7f83b...",
|
|
238
|
+
"position": [8, 16],
|
|
239
|
+
"confidence": 0.98,
|
|
240
|
+
"action": "pseudonymize",
|
|
241
|
+
"token": "AVA_PERS_7a3f9k2m"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## ๐ Pluggable Engines
|
|
248
|
+
|
|
249
|
+
Swap detection engines without changing your code:
|
|
250
|
+
|
|
251
|
+
| Engine | Installation | Best For |
|
|
252
|
+
|--------|--------------|----------|
|
|
253
|
+
| **Presidio** (default) | `pip install ava-protocol[local]` | Self-hosted, free, customizable |
|
|
254
|
+
| **AWS Macie** | `pip install ava-protocol[aws]` | Enterprise, cloud-native |
|
|
255
|
+
| **Mock** (built-in) | No install | Testing, CI/CD |
|
|
256
|
+
| **Custom** | Extend `DetectionEngine` | Domain-specific needs |
|
|
257
|
+
|
|
258
|
+
## ๐ฆ Project Structure
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
ava-protocol/
|
|
262
|
+
โโโ src/ava/
|
|
263
|
+
โ โโโ __init__.py # Main exports
|
|
264
|
+
โ โโโ client.py # Client & GatewayClient
|
|
265
|
+
โ โโโ session.py # Transaction context
|
|
266
|
+
โ โโโ config.py # Configuration management
|
|
267
|
+
โ โโโ protocol/ # Core protocol types
|
|
268
|
+
โ โ โโโ manifest.py # AVA Manifest
|
|
269
|
+
โ โ โโโ entities.py # DetectedEntity
|
|
270
|
+
โ โ โโโ token_vault.py # Vault implementations
|
|
271
|
+
โ โโโ engines/ # Detection engines
|
|
272
|
+
โ โ โโโ base.py # Abstract interface
|
|
273
|
+
โ โ โโโ presidio.py # Presidio adapter
|
|
274
|
+
โ โโโ gateways/ # Remote gateway clients
|
|
275
|
+
โ โโโ http.py # REST client
|
|
276
|
+
โโโ tests/ # Test suite
|
|
277
|
+
โโโ pyproject.toml # Package config
|
|
278
|
+
โโโ README.md # This file
|
|
279
|
+
โโโ PUBLISH.md # PyPI release guide
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## ๐งช Development
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Clone repo
|
|
286
|
+
git clone https://github.com/ava-protocol/ava-protocol.git
|
|
287
|
+
cd ava-protocol
|
|
288
|
+
|
|
289
|
+
# Create virtual environment
|
|
290
|
+
python -m venv venv
|
|
291
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
292
|
+
|
|
293
|
+
# Install in development mode
|
|
294
|
+
pip install -e ".[all,dev]"
|
|
295
|
+
|
|
296
|
+
# Download Presidio models (if using local)
|
|
297
|
+
python -m spacy download en_core_web_lg
|
|
298
|
+
|
|
299
|
+
# Run tests
|
|
300
|
+
pytest
|
|
301
|
+
|
|
302
|
+
# Lint
|
|
303
|
+
black src/ava tests/
|
|
304
|
+
ruff check src/ava tests/
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## ๐ก๏ธ Security Considerations
|
|
308
|
+
|
|
309
|
+
- **Zero-Retention Mode**: Tokens auto-expire (default: 1 hour)
|
|
310
|
+
- **Vault Isolation**: Session-scoped token storage
|
|
311
|
+
- **Audit Trail**: Every transformation logged in manifest
|
|
312
|
+
- **Hash-Only Storage**: Original values never in manifests (only tokens)
|
|
313
|
+
|
|
314
|
+
## ๐ License
|
|
315
|
+
|
|
316
|
+
MIT License โ see [LICENSE](LICENSE)
|
|
317
|
+
|
|
318
|
+
## ๐ค Contributing
|
|
319
|
+
|
|
320
|
+
1. Fork the repository
|
|
321
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
322
|
+
3. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
323
|
+
4. Push to branch (`git push origin feature/amazing-feature`)
|
|
324
|
+
5. Open a Pull Request
|
|
325
|
+
|
|
326
|
+
## ๐ Links
|
|
327
|
+
|
|
328
|
+
- **Documentation**: https://ava-protocol.readthedocs.io
|
|
329
|
+
- **PyPI**: https://pypi.org/project/ava-protocol/
|
|
330
|
+
- **Repository**: https://github.com/ava-protocol/ava-protocol
|
|
331
|
+
- **Issues**: https://github.com/ava-protocol/ava-protocol/issues
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
**AVA**: Making AI interactions private by default, visible by design.
|