Safe Artificial Intelligence for Reliable Environments
Open-source medical AI hardening toolkit for defensive deployment. Safire wraps any inference endpoint with multi-layer adversarial defenses, immutable audit trails, and standards-based compliance artifacts — offline-first and zero offensive code.
Maturity: Deployable prototype. Not a certified clinical product. See Reality Boundaries.
Lineage: Safire is the rebrand of the toolkit previously published as
praeses-med. Existing imports and environment variables continue to work via non-breaking aliases (see Security Notes).
Safe Artificial Intelligence for Reliable Environments.
Medical inference endpoints fail in ways that ordinary ML observability misses: adversarial prompts, steganographic payloads, behavioral drift, and untracked audit gaps. Safire is a defensive wrapper that sits in front of any model and gives operators the controls, telemetry, and compliance artifacts they need to deploy with confidence in environments where reliability is non-negotiable.
- Multi-layer hardening pipeline
- Prompt shield (pattern + intent + plugin hooks)
- Entropy stego detector (Shannon + bigram)
- Hybrid behavioral drift monitor (vector + TF-IDF)
- Adversarial robustness wrapper
- Kinetic dry-run response hooks — quarantine, re-auth challenge, escalation logging
- PID safety gate for multimodal payloads
- Digital-twin risk score per inference
- RBAC API key roles (
admin,clinical,observer) - Immutable HMAC-signed audit events for every inference
- Automated robustness harness and benchmark suite
- Live Streamlit dashboard + FastAPI service
- NIST AI RMF + MITRE ATLAS defensive mapping
- Dual SBOM generation (CycloneDX + SPDX)
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/macOS
source .venv/bin/activate
pip install -r requirements.txt
# Or install as an editable package
pip install -e .Run the API server:
uvicorn src.api.app:app --host 0.0.0.0 --port 8000Run the Streamlit dashboard:
streamlit run dashboard/app.pyRun the full benchmark + smoke demo:
python scripts/smoke_demo.py
python benchmarks/run_eval.py| Method | Path | Description |
|---|---|---|
| GET | /health |
Liveness check |
| POST | /infer |
Hardened inference |
| POST | /harden |
Run hardening pipeline only |
| GET | /metrics |
JSON metrics snapshot |
| GET | /metrics/prometheus |
Prometheus-format metrics |
| GET | /audit |
Audit log tail |
from src.sdk import SafireClient # PraesesMedClient is kept as an alias
client = SafireClient(base_url="http://localhost:8000", api_key="...")
result = client.infer({"text": "patient presents with..."})safire/
├── src/
│ ├── api/ # FastAPI application
│ ├── core/ # Hardening pipeline, audit, RBAC
│ └── sdk/ # Python client SDK (SafireClient)
├── dashboard/ # Streamlit telemetry dashboard
├── benchmarks/ # Evaluation harness and results
├── tests/ # Regression + smoke tests
├── scripts/ # CLI utilities (eval, SBOM, compliance)
├── docs/ # Architecture, API, deployment, compliance docs
├── deploy/ # Helm chart
├── validation_data/ # Labeled adversarial sample sets
└── notebooks/ # Exploratory analysis
python scripts/check_branch_name.py
python scripts/run_tests.py
python scripts/smoke_demo.py
python scripts/release_check.py
python scripts/calibrate_thresholds.py
python scripts/generate_synthetic_corpus.py
python scripts/export_compliance_report.py
python scripts/export_openapi.py
python scripts/run_security_scans.py| Artifact | Location |
|---|---|
| NIST AI RMF mapping | docs/NIST_RMF_MAPPING.md |
| MITRE ATLAS coverage | docs/MITRE_ATLAS_MATRIX.md |
| Architecture overview | docs/ARCHITECTURE.md |
| OpenAPI spec | docs/openapi.json |
| Helm chart | deploy/helm/praeses-med (directory name retained for backward compatibility) |
| Whitepaper | docs/WHITEPAPER.md / .pdf |
| CycloneDX SBOM | sbom.cdx.json |
| SPDX SBOM | sbom.spdx.json |
| Brand guide | docs/BRAND.md |
- Set
SAFIRE_HMAC_SECRETto a strong secret in production. The legacyROBUSTMED_HMAC_SECRETvariable is still honored as a fallback. - Keep audit logs in append-only storage.
- Run containers with a read-only filesystem and seccomp policy.
- See SECURITY.md for vulnerability disclosure.
This toolkit provides production-style controls and deployment artifacts but does not include:
- Regulatory approval or certification (FDA, CE, etc.)
- Formal SOC2/HIPAA attestation packages
- Enterprise SLAs, billing, or multi-tenant production controls
- Large-scale clinical model training or hospital system deployment
See docs/REALITY_CHECK.md for full details.
Contributions are welcome! See CONTRIBUTING.md for guidelines and CODE_OF_CONDUCT.md for community standards.
Apache License 2.0 — © Safire contributors (FratresMedAI)