bidirectional privacy filter that sits between the CoReason platform and the external world
Project description
coreason-aegis
A bidirectional privacy filter that sits between the CoReason platform and the external world.
coreason-aegis implements a "Tokenize & Detokenize" strategy. Before any text leaves the secure perimeter (e.g., to OpenAI), Aegis scans it for sensitive entities (Names, MRNs, SSNs, Emails) and replaces them with consistent, context-aware tokens. When the LLM responds using these tokens, Aegis intercepts the message and re-injects the real data only for the authorized user's eyes.
Features
- Async-Native with Sync Facade: Designed for high-performance async environments with a convenient synchronous wrapper.
- Scan-Mask-Map-Reveal Loop: Deterministic tokenization ensures LLM reasoning consistency.
- The "Vault" of Identity: Ephemeral, encrypted mapping tables.
- Context Preservation: Uses tokens like
[PATIENT_A]instead of[REDACTED]. - Custom Recognizers: Supports custom entities like MRNs, Protocol IDs, and Lot Numbers.
For detailed documentation, see:
Installation
pip install coreason-aegis
Or using Poetry:
poetry add coreason-aegis
Note: You may need to download the Spacy model manually if not handled by the package installer:
python -m spacy download en_core_web_lg
Usage
from coreason_aegis.main import Aegis
from coreason_aegis.models import AegisPolicy, RedactionMode
from coreason_identity.models import UserContext
from coreason_identity.types import SecretStr
# Initialize Aegis
aegis = Aegis()
# Create User Context (Required)
context = UserContext(
user_id=SecretStr("user_123"),
roles=["analyst"]
)
# Define a policy
policy = AegisPolicy(
allow_list=["Tylenol"],
entity_types=["PERSON", "EMAIL", "PHONE_NUMBER"],
mode=RedactionMode.REPLACE,
confidence_score=0.7
)
# Sanitize user prompt
user_prompt = "Patient John Doe (DOB: 12/01/1980) has a rash."
session_id = "session_123"
sanitized_prompt, deid_map = aegis.sanitize(
text=user_prompt,
session_id=session_id,
context=context,
policy=policy
)
print(f"Sanitized: {sanitized_prompt}")
# Output: "Patient [PATIENT_A] (DOB: [DATE_B]) has a rash."
# ... Send to LLM ...
llm_response = "For [PATIENT_A], considering the rash..."
# Desanitize LLM response
final_response = aegis.desanitize(
text=llm_response,
session_id=session_id,
context=context,
authorized=True
)
print(f"Final: {final_response}")
# Output: "For John Doe, considering the rash..."
For more examples, see the Usage Guide.
Project details
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 coreason_aegis-0.4.0.tar.gz.
File metadata
- Download URL: coreason_aegis-0.4.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df96d5bfc214fcd9f241871e3536fb597e9cd6cb9e10caddfb30764e292addbf
|
|
| MD5 |
14a2b3604fcfc46830b9e334cacbaa01
|
|
| BLAKE2b-256 |
de4cc7edbc8ee0d6b559c51bd1006d1c8f5abcedfecb6eab678003bee5d5ba3f
|
Provenance
The following attestation bundles were made for coreason_aegis-0.4.0.tar.gz:
Publisher:
publish.yml on CoReason-AI/coreason-aegis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_aegis-0.4.0.tar.gz -
Subject digest:
df96d5bfc214fcd9f241871e3536fb597e9cd6cb9e10caddfb30764e292addbf - Sigstore transparency entry: 872227156
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-aegis@2ee1c812f5dcfa198000de1680cd4df2a1d627c4 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ee1c812f5dcfa198000de1680cd4df2a1d627c4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file coreason_aegis-0.4.0-py3-none-any.whl.
File metadata
- Download URL: coreason_aegis-0.4.0-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51081a27c62b6d0b5d67088755ef1f42c312cdde16d159cd289d96d410224665
|
|
| MD5 |
f730094ef66215e457ea410883335fb1
|
|
| BLAKE2b-256 |
289419d05e29bff2de60261fe1a0de149a8edd93f1f1a5015c4689512cb5276a
|
Provenance
The following attestation bundles were made for coreason_aegis-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on CoReason-AI/coreason-aegis
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_aegis-0.4.0-py3-none-any.whl -
Subject digest:
51081a27c62b6d0b5d67088755ef1f42c312cdde16d159cd289d96d410224665 - Sigstore transparency entry: 872227165
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-aegis@2ee1c812f5dcfa198000de1680cd4df2a1d627c4 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2ee1c812f5dcfa198000de1680cd4df2a1d627c4 -
Trigger Event:
release
-
Statement type: