clinicalguard
Constitutional AI governance for clinical decision support — an A2A agent that validates proposed clinical actions against a 20-rule Healthcare AI Constitution.
ClinicalGuard is a Starlette-based A2A (Agent-to-Agent) JSON-RPC service. It exposes three skills: clinical action validation (LLM reasoning + constitutional enforcement), HIPAA compliance checking, and tamper-evident audit log queries. Every decision is cryptographically logged in a hash-chained audit trail.
Installation
pip install clinicalguard
ClinicalGuard is a service, not a library. Install then run with
uvicorn(see below). LLM-backed clinical reasoning also requires an LLM provider:pip install "clinicalguard[anthropic]" # or [openai]
Requires Python 3.11+ and acgs-lite 4.x (>=4,<5). acgs-lite 3.0.1 is not supported: its rule engine skipped HC-003 for some MRN inputs (see the CHANGELOG).
Docker quickstart
The image installs the package from this repository (pip install ".[anthropic]"), runs as a non-root user, and keeps the audit log on the /data volume.
docker build -t clinicalguard .
docker run --rm -p 8080:8080 -v clinicalguard_data:/data clinicalguard
curl -s http://localhost:8080/health
Optional environment variables for docker run:
-e ANTHROPIC_API_KEY=...enables LLM clinical reasoning. The image includes theanthropicextra for this. Without a key the service starts normally and answers from the constitutional rules only (llm_available: false, never a bareAPPROVED).-e CLINICALGUARD_API_KEY=...requiresX-API-Keyon every request.
The container writes the audit log to /data/clinicalguard_audit.json (CLINICALGUARD_AUDIT_LOG). A named volume works as shown. A bind mount must be writable by the container user, otherwise startup fails with a clear "not writable" error. The /health endpoint backs the image HEALTHCHECK.
Running the Service
uvicorn clinicalguard.main:app --host 0.0.0.0 --port 8080
Or with the module entry point:
python -m clinicalguard.main
Environment Variables
| Variable | Default | Description |
|---|---|---|
CLINICALGUARD_API_KEY |
(unset) | When set, all requests require X-API-Key: <key> header |
CLINICALGUARD_AUDIT_LOG |
$XDG_STATE_HOME/clinicalguard/clinicalguard_audit.json (~/.local/state/... if unset); /data/clinicalguard_audit.json in the Docker image |
Path for persisting the audit log (made absolute). The service creates a missing directory (mode 0700) and log file (mode 0600) at startup, and refuses to start if this path cannot be written. There is no fallback to /tmp |
CLINICALGUARD_URL |
http://localhost:8080 |
Public URL reported in the agent card |
ANTHROPIC_API_KEY or OPENAI_API_KEY |
(unset) | LLM credentials for clinical reasoning skill |
Calling the Agent
ClinicalGuard speaks the A2A JSON-RPC protocol. All requests are POST / with Content-Type: application/json. The only supported method is tasks/send.
Validate a clinical action
curl -s http://localhost:8080/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "tasks/send",
"params": {
"id": "task-001",
"message": {
"role": "user",
"parts": [{"type": "text",
"text": "validate_clinical_action: Patient on Warfarin. Propose Aspirin 325mg daily."}]
}
}
}'
Example response without an LLM provider (rule-only; the complete response captured from a clean install of the 1.1.0 wheel; audit_id and timestamp vary):
{"jsonrpc":"2.0","id":"1","result":{"id":"task-001","status":"completed","result":{"decision":"CONDITIONALLY_APPROVED","confidence":0.55,"risk_tier":"MEDIUM","reasoning":"LLM reasoning unavailable — constitutional rules only.","llm_available":false,"evidence_tier":"UNKNOWN","drug_interactions":[],"violations":[],"conditions":[],"audit_id":"HC-20261115-47B28EAFF3","constitutional_hash":"8494a847758c08dc","maci_role":"validator","timestamp":"2026-11-15T21:56:47.788352+00:00","appeal_path":"Contact your governance administrator with audit_id=HC-20261115-47B28EAFF3"}}}
Response fields: decision (APPROVED / CONDITIONALLY_APPROVED / REJECTED), risk_tier (LOW / MEDIUM / HIGH / CRITICAL), reasoning, drug_interactions, conditions, audit_id, plus llm_available, violations, constitutional_hash, maci_role, timestamp and appeal_path.
Check HIPAA compliance
curl -s http://localhost:8080/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "2",
"method": "tasks/send",
"params": {
"id": "task-002",
"message": {
"role": "user",
"parts": [{"type": "text",
"text": "check_hipaa_compliance: Agent processes synthetic patient records, maintains MACI audit log, uses TLS in transit."}]
}
}
}'
Response fields: compliant (bool), items_checked, items_passing, items_failing, checklist (list with status + MACI-mapped mitigations), constitutional_hash.
Query audit trail
Pass the audit_id returned by a validation call. With no input (query_audit_trail:) the log is listed instead.
curl -s http://localhost:8080/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "3",
"method": "tasks/send",
"params": {
"id": "task-003",
"message": {
"role": "user",
"parts": [{"type": "text", "text": "query_audit_trail: HC-20261115-D854D910B3"}]
}
}
}'
Skill name can also be provided in the skill field of the first message part instead of as a text prefix.
Key Features
validate_clinical_action— two-layer architecture: LLM clinical reasoning (evidence tier, drug interactions, step therapy) +GovernanceEngineconstitutional enforcement (MACI, keyword/pattern rules, audit)check_hipaa_compliance— runsacgs_lite.compliance.hipaa_ai.HIPAAAIFrameworkagainst an agent description; maps each checklist item to its MACI role mitigationquery_audit_trail— tamper-evident audit trail query; returns entries from the hash-chainedAuditLog- Healthcare AI Constitution — bundled 20-rule
constitution/healthcare_v1.yaml; covers medication safety, PII/PHI, MACI enforcement, EHR access controls - PHI detection —
phi_detectorcustom validator catches 10 of 18 HIPAA Safe Harbor identifiers (SSN, MRN, DOB, phone, email, insurance ID, IP, account #, device/UDI, license #) - Clinical decision audit —
clinical_decision_auditorcustom validator logs every clinical decision as a governance event - Security —
X-API-Keyauth (whenCLINICALGUARD_API_KEYis set), 64 KB request body limit, 10 K char text limit, input Unicode normalisation - A2A agent card —
GET /.well-known/agent.jsonreturns the agent card for discovery
Skill Reference
| Skill ID | Prefix / skill field |
Description |
|---|---|---|
validate_clinical_action |
validate_clinical_action: <text> |
Clinical action validation with LLM + constitutional rules |
check_hipaa_compliance |
check_hipaa_compliance: <text> |
HIPAA compliance checklist against an agent description |
query_audit_trail |
query_audit_trail: <query> |
Query the tamper-evident audit log |
Package Structure
| Module | Description |
|---|---|
clinicalguard.agent |
create_app() — builds the Starlette app with all routes and validators |
clinicalguard.main |
app — ASGI app; entry point for uvicorn |
clinicalguard.skills.validate_clinical |
validate_clinical_action(text, engine, audit_log) |
clinicalguard.skills.hipaa_checker |
check_hipaa_compliance(agent_description) |
clinicalguard.skills.healthcare_validators |
phi_detector, clinical_decision_auditor, adverse_event_logger custom validators |
constitution/healthcare_v1.yaml |
Bundled 20-rule Healthcare AI Constitution |
Runtime dependencies
acgs-lite>=4,<5starlette>=0.37uvicorn[standard]>=0.29pyyaml>=6.0httpx>=0.27pydantic>=2.0
License
AGPL-3.0-or-later.
Links
Metadata
Release files for clinicalguard 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clinicalguard-1.1.0.tar.gz | 45.5 kB | With provenance | Details for clinicalguard-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clinicalguard-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for clinicalguard-1.1.0-py3-none-any.whl |
Total release size: 74.2 kB
Release files / clinicalguard-1.1.0.tar.gz
| Download URL | clinicalguard-1.1.0.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7235fe1b2f9eb20ef791b951766197deea3e07d16974ae5e04a5808e7c00620b
|
|
BLAKE2b-256 checksum How to use checksums |
f615ffad4be0ea1926c88d73eb52cde7e14cc9c783c92d36464523407e8d56ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / clinicalguard-1.1.0-py3-none-any.whl
| Download URL | clinicalguard-1.1.0-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5600e628284905bf98084247104ca7dbd5566ca92d334cc75118610f949818d8
|
|
BLAKE2b-256 checksum How to use checksums |
29deceb8751b19bc5f35a96f30bd16d7c1f6703abcc56839d1ac530da7415db3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for clinicalguard 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for clinicalguard-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.