Adam BlansettSenior Full-Stack & AI Engineer
DevOps & Security
12 min read
Adam Blansett

Engineering a Self-Hosted AI Compliance Auditor: 18 SOC 2/HIPAA/GDPR Controls, Signed ZIP Bundles, and 409 Legal Holds

Inside ai-compliance-auditor: 18-control SOC 2/HIPAA/GDPR registry, 20 deterministic CFG/ENC/LOG/RBAC/SOP scanners, HMAC-signed ZIP/PDF evidence bundles with offline verify_bundle.py, Policy RAG, and 409 legal-hold DSARs.

SOC 2HIPAAGDPRDSARPolicy RAGEvidence BundlesFastAPI

Compliance programs fail engineers when evidence lives in static screenshots, policy documents drift out of sync with live infrastructure, and statutory 30-day DSAR deletion workflows accidentally purge records locked under litigation holds.

AI Compliance & Regulatory Auditor Platform (source on GitHub) replaces manual audit spreadsheets with a Phase 2 FastAPI, async SQLAlchemy 2.0 (17 tables across 2 Alembic migrations), PostgreSQL (`pgvector`), and 8-tab React 18 TypeScript console.

18-Control Registry & 20 Deterministic Configuration/TLS Scanners#

Under `controls/` and `scanners/`, an 18-control baseline maps SOC 2 Trust Services Criteria, HIPAA Safeguards, and GDPR Articles alongside custom controls and HITL risk waivers. Twenty deterministic collectors (`CFG-001..004`, `ENC-001..004`, `LOG-001..004`, `RBAC-001..004`, `SOP-001..004`) evaluate inline text, uploaded artifacts, full repository trees, SSRF-guarded HTTP/TLS probes (`/scanners/probe-url`), and scheduled drift checks.

Signed ZIP/PDF Evidence Bundles & Zero-Dependency Offline Verifier#

Every state change appends to a SHA-256 hash-chained `audit_events` ledger under `evidence/`. Compilers generate HMAC-SHA256 signed JSON bundles, multi-page executive PDF attestations (`/report.pdf`), and downloadable ZIP archives (`/export-zip`) containing a standalone `verify_bundle.py` CLI so auditors can verify manifest signatures offline.

Policy indexing and privacy enforcement work together rather than operating in silos:

dsar_legal_hold_check.py
active_holds = await privacy_repo.find_active_holds(subject_email=dsar.subject_email)
if active_holds and dsar.request_type == "erasure":
    raise HTTPException(
        status_code=409,
        detail="Erasure blocked: subject is covered by an active Legal Hold",
    )
  • Policy RAG (`rag/`): Chunks handbooks by heading, scrubs PII/PHI before persistence, indexes `384`-dim or Ollama embeddings, maps citations to control codes, and answers compliance questions with explicit evidence links.
  • DSAR & Retention Workflows (`privacy/`): Tracks 30-day DSAR SLAs, blocks held erasures with `409 Conflict` until hold release, verifies retention ceilings, and gates time-bounded retention exceptions.
  • Drift Alerting & Separation of Duties (`alerts/`, `core/`): Dispatches control-regression, expiring-waiver, and DSAR SLA alerts to HMAC-signed webhooks while enforcing PBKDF2 + JWT RBAC (`viewer`, `auditor`, `compliance_officer`, `admin`), optional Separation of Duties, rate limiting, and OpenTelemetry.
Interactive Testing: Seeding demo data (`POST /api/v1/seed/demo`) creates SOC 2 / HIPAA / GDPR sample controls, RBAC demo users (`compliance_officer`, `auditor`, `viewer`), tamper-simulation controls, and downloadable ZIP/PDF bundles.

Preparing for SOC 2, HIPAA, or GDPR automation without exposing sensitive evidence to external SaaS tools? Explore Software Architecture or book a consultation.

Applied Architecture

Production Case Studies & Capabilities

Explore how these engineering patterns are deployed in production systems and available through client engagements.

Case Study

AI Compliance & Regulatory Auditor Platform

An open-source Python 3.12 (FastAPI), async SQLAlchemy 2.0 + PostgreSQL/pgvector, and React 18 compliance operations console implementing 18 SOC 2/HIPAA/GDPR controls, deterministic repo/URL/config scanners, HMAC-SHA256 signed evidence ZIP & PDF bundles with offline verification, Policy RAG, and 30-day DSAR workflows.

Read Case Study
Related Engineering Service

Software Architecture & System Design

Fast-moving teams frequently accrue hidden architectural liabilities: tangled domain logic, unmaintainable monoliths, or over-engineered microservices that paralyze development.

Related Engineering Service

AI Engineering & LLM Integration

Many AI initiatives fail in production due to prompt fragility, high token latency, hallucination risks, and lack of structured evaluation. I bridge the gap between experimental LLM prompts and deterministic software engineering.

Frequently Asked Questions

How can external auditors verify evidence bundles exported from ai-compliance-auditor without trusting the live server?
Each signed ZIP export (/api/v1/evidence/bundles/{id}/export-zip) packages the SHA-256 hash-chained audit events, HMAC-SHA256 bundle manifest, and a zero-dependency verify_bundle.py script so assessors can verify cryptographic integrity offline.
What happens when a GDPR deletion DSAR targets records covered by an active Legal Hold?
The /api/v1/privacy/dsars endpoints enforce automatic legal-hold erasure blocking, returning HTTP 409 Conflict whenever a matching hold is active and dynamically unblocking fulfillment only after the hold is explicitly released.
Which deterministic scanners run before any LLM policy synthesis?
The scanners module runs 20 deterministic collectors across config (CFG-001..004), encryption (ENC-001..004), logging (LOG-001..004), RBAC (RBAC-001..004), and SOPs (SOP-001..004) over inline text, file uploads, full repositories, SSRF-guarded HTTP/TLS probes, and recurring schedules.
Share this technical guide

Need Help Solving This in Your Application?

I partner with founders, executives, and engineering leaders to design architectures, resolve production bottlenecks, and deliver resilient software.

Related Technical Articles

DevOps & Security
12 min read

Automating Compliance, Data Governance, QA, and IT Operations with Guarded Self-Hosted AI

How deterministic policy scanners, legal-hold DSAR blocks, HKDF/Fernet PII tokenization, SCIM 2.0 dry-run diffs, and OpenAPI E2E test synthesis power internal governance and release engineering safely.

SOC 2 ComplianceData GovernanceSCIM 2.0Release EngineeringPII TokenizationDSARSecurity Scanners
Read Article