Skip to main content

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.

License CI Ruff Docs

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

  • 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 requirements, see Product Requirements.

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

# Initialize Aegis
aegis = Aegis()

# 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, mapping_id = aegis.sanitize(user_prompt, policy, session_id)

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(llm_response, session_id, mapping_id)

print(f"Final: {final_response}")
# Output: "For John Doe, considering the rash..."

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

coreason_aegis-0.3.1.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreason_aegis-0.3.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file coreason_aegis-0.3.1.tar.gz.

File metadata

  • Download URL: coreason_aegis-0.3.1.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_aegis-0.3.1.tar.gz
Algorithm Hash digest
SHA256 cf7bbcf7908dafa96a1ca02dba77def76332c457fc41c6b264dcc09b73efdb2b
MD5 28ff0dd9d153d59f1e43d3ecfb39e14f
BLAKE2b-256 5893eb61cf85154b69926d7a9fc3ef6a0a4b5b215be3f8a13e6d48545f395aec

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_aegis-0.3.1.tar.gz:

Publisher: publish.yml on CoReason-AI/coreason-aegis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coreason_aegis-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: coreason_aegis-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_aegis-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dddd8f555f34465b5f2c2a2d2278d8d05d0c2bb2810e9b961515b6cec02f2bb4
MD5 e804bc79bb114a419b91ee9adc70d9ab
BLAKE2b-256 64285a5e4873a8d2ece9424de1266a81e9989c636e6dba45a4c0746fd1ec4b03

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_aegis-0.3.1-py3-none-any.whl:

Publisher: publish.yml on CoReason-AI/coreason-aegis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page