Open Source · Apache-2.0

Compliance Jobs.

A FastAPI service running four always-on schedulers that publish hourly Merkle-chained roots over audit databases, enforce per-class retention with legal holds, cascade GDPR erasure across stores, and generate Ed25519-signed regulatory reports.

Install

Executed from a clean container against this repository:

git clone https://github.com/bulletproofsoftware-ai/bulletproof-compliance-jobs.git
cd bulletproof-compliance-jobs
pip install -r requirements.txt
cp .env.example .env
Compliance Jobs architecture infographic
Architecture infographic — from bulletproof-compliance-jobs/docs/media/
Domain Regulatory Compliance / Audit
Repository bulletproof-compliance-jobs
Language Python 3.12 · FastAPI
Storage SQLite (WAL) + filesystem artifacts
License Apache-2.0

1Problem Statement

Compliance programs fail at audit time because evidence is assembled retrospectively. Someone exports logs, reconciles them by hand, and asserts that nothing was altered — an assertion the logs themselves cannot support.

Three specific gaps recur. Audit trails have no tamper-evidence, so there is no cryptographic reason to believe a record was not edited. Retention is a policy document rather than an enforced behaviour, so data outlives its lawful basis. And erasure requests are handled in one system while copies persist in vector stores, archives, and workflow histories.

This service makes the evidence continuous and mechanical. Every module maps to numbered requirements — Merkle publishing, Ed25519 signing, retention and legal hold, GDPR cascade, annual attestations, and NAIC adverse-action population — and runs on a schedule rather than on request.

2Architecture

app/main.py is the entrypoint. A lifespan context manager calls ensure_dirs() and db.init(), pre-warms the signing key, then launches four asyncio tasks that are cancelled cleanly on shutdown.

Merkle chain

publish_hourly_root() reads the closed hour's audit events, SHA-256 hashes each canonicalized event into leaves, folds them pairwise (duplicating odd nodes), and links to the previous root as parent_root_hash. Roots are written write-once and chmod 0o444.

Ed25519 signing

app/signing.py uses PyNaCl. canonical_json() is the single canonicalisation source of truth; resolve_public_key() checks the current key then an archive directory by key id, so signatures over historical artifacts stay verifiable across rotation.

Declarative retention

retention.py enforces an archive-then-delete cycle over every declared audit store. Retention periods are configuration rather than hard-coded policy — AUDIT_RETENTION_YEARS and EVIDENCE_RETENTION_YEARS both default to 7 — and a sweep runs every RETENTION_INTERVAL_HOURS (default 24). Records are written to gzipped JSONL before any deletion, and active legal holds suspend deletion for the named scope.

DSR cascade

submit_dsr() records a request with a deadline; execute_erasure() fans out to Qdrant purge, audit reference counting, and file-artifact purge, then writes a deletion-confirmation artifact. Six GDPR request types are accepted.

Report generation

REPORT_TYPES maps four report types — SOX attestation, NY DFS Part 500, EU AI Act Annex VI, and NAIC adverse action — to titles and named control lists. Evidence is gathered from audit counts, chain state, retention runs, and DSR cascades, then signed.

Scheduler Behaviour

3Requirements

Requirement identifiers follow the REQ-RCA series referenced throughout the module docstrings.

IDRequirement
REQ-RCA-006Publish hourly Merkle roots hash-linked to the previous root.
REQ-RCA-013Sign compliance artifacts with Ed25519 and expose public-key verification.
REQ-RCA-016Enforce per-class retention periods across all declared storage kinds.
REQ-RCA-017Archive records to compressed JSONL before deletion.
REQ-RCA-018Honour legal holds that suspend deletion for a named scope.
REQ-RCA-021Cascade GDPR erasure across vector, audit, and file stores with confirmation artifacts.
REQ-RCA-029Generate SOX attestation reports over named ITGC and AI controls.
REQ-RCA-030Generate NY DFS Part 500 and EU AI Act Annex VI reports.
REQ-RCA-031Auto-fire annual attestations covering the prior calendar year.
REQ-RCA-032Populate NAIC adverse-action artifacts idempotently from audit events.

4Interfaces

A REST surface over the four job domains, plus signing and dashboard endpoints. Every scheduled job also has a run-now trigger for operators.

EndpointPurpose
POST /api/merkle/publish-nowPublish a root immediately
GET /api/merkle/rootsList published roots
GET /api/merkle/verify-chainWalk and verify the hash chain
POST /api/retention/run-nowTrigger a retention sweep
POST /api/retention/holdsPlace a legal hold
DELETE /api/retention/holds/{hold_id}Release a legal hold
POST /api/dsr/submitSubmit a data subject request
POST /api/dsr/{request_id}/executeExecute an erasure cascade
POST /api/reports/generateGenerate a regulatory report
GET /signing/public-keyRetrieve the current public key
POST /signing/verifyVerify a signature over an artifact
GET /api/dashboardAggregate status across all job domains

5Integration Points

The service reads from upstream audit stores and writes evidence outward.

6Repository

Application modules are organised one per compliance domain, with policy separated from orchestration.

PathPurpose
app/main.pyFastAPI app, all routes, four schedulers, NAIC scanners
app/merkle.pyRoot computation, write-once persistence, chain verification
app/signing.pyEd25519 keys, canonical JSON, rotation-aware verification
app/retention.pyArchive-then-delete orchestration and legal holds
app/config.pyEnvironment-driven settings — retention horizons, intervals, paths
app/dsr_cascade.pyGDPR request handling and erasure fan-out
app/reports.pyFour report generators and control mappings
app/db.pySQLite schema and additive migrations
tests/Annual scheduler and signing test suites

View source on GitHub

7Implementation Notes

Deployment constraints and one documentation discrepancy worth flagging.