GRID Safety layer and Cognitive Privacy Shield: real-time safety enforcement, PII detection, masking, and compliance presets (GDPR, HIPAA, PCI-DSS) for AI inference.
Project description
grid-safety
GRID Safety layer and Cognitive Privacy Shield: real-time safety enforcement, PII detection, masking, and compliance presets (GDPR, HIPAA, PCI-DSS) for AI inference.
Install
pip install grid-safety
Minimal usage
Cognitive Privacy Shield (library)
from safety.privacy import get_privacy_engine, PrivacyPreset, AsyncPIIDetector
# Get engine with a compliance preset
engine = get_privacy_engine(preset=PrivacyPreset.BALANCED)
# Detect PII
detections = await engine.detect("Contact me at user@example.com")
# Process (detect + mask/block/ask)
result = await engine.process("My SSN is 123-45-6789")
print(result.processed_text) # Masked or blocked per preset
print(result.detections)
Run the Safety API server
safety-api
Runs the FastAPI app (auth, rate limiting, pre-check, Privacy Shield middleware, inference queue). Configure via environment variables:
| Variable | Default | Description |
|---|---|---|
SAFETY_API_HOST |
0.0.0.0 |
Bind host |
SAFETY_API_PORT |
8000 |
Bind port |
SAFETY_API_RELOAD |
(off) | Set to 1, true, or yes to enable reload |
Endpoints include:
POST /infer— Submit inference (enqueued to Redis)POST /privacy/detect— Detect PII in textPOST /privacy/mask— Mask or block PIIPOST /privacy/batch— Batch PII detection/masking (up to 100 texts)GET /health,GET /metrics
Set SAFETY_DEGRADED_MODE=true to run without Redis (e.g. for tests).
Architecture
The Cognitive Privacy Shield is GRID's core safety and privacy API. For pipeline details, integration points, and key files, see:
- Safety Layer & Cognitive Privacy Shield — Architecture (in the GRID repo)
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grid_safety-1.0.0.tar.gz.
File metadata
- Download URL: grid_safety-1.0.0.tar.gz
- Upload date:
- Size: 127.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29eba5c787b0a9d875968c7c1781e81e3d2c44b9de11486bd6408a1818ac2072
|
|
| MD5 |
89a0737523bed1b07ab25ab6d4c78523
|
|
| BLAKE2b-256 |
e49aa073d7a682a6e66c329cbff01616786da01154b6a865b327550dc71c3f88
|
File details
Details for the file grid_safety-1.0.0-py3-none-any.whl.
File metadata
- Download URL: grid_safety-1.0.0-py3-none-any.whl
- Upload date:
- Size: 172.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea2555622197f86cc6104dd7523ca4dbafb89fdb13ba5a531a49dd6620ba554
|
|
| MD5 |
e6d1e3d6e6fb276a77db1c5d366c6c40
|
|
| BLAKE2b-256 |
a6fbe7dd29080f739e76b2333970b70dae1ab6db30a8361aee94a43a0381bdd9
|