PRD 18 of 19

Regulatory Compliance
& Audit Trail Framework

Production-grade regulatory defensibility layer: human attribution, cryptographically-chained immutable audit storage, evidence packages, data subject rights routing, model risk documentation, and incident response for NAIC, SOX, GDPR/EU AI Act, NY DFS Part 500, SOC 2, ISO 27001, and GLBA.

1. Problem Statement

The existing 17-PRD platform provides strong internal governance — append-only audit bus, NHI lifecycle, constitutional contracts, Gemini validation. But this was designed for engineering accountability, not regulatory defensibility.

Regulated environments (insurance, financial services, healthcare) require more than logs. They require per-human-user attribution threading through every agent action, cryptographically tamper-evident storage, structured evidence packages examiners can audit without reconstruction, and human decision records at every governance gate. Without this layer, the platform cannot be deployed under NAIC Model Bulletin on AI, SOX §302/404, GDPR Articles 15–22, EU AI Act, NY DFS Part 500, SOC 2 Trust Service Criteria, ISO 27001 ISMS, or the GLBA Safeguards Rule.

Not a Replacement — An Extension

This PRD sits above the existing governance infrastructure and consumes its outputs to produce regulator-ready artifacts. It does not replace PRD 5 (Governance) — it makes PRD 5's outputs defensible under examiner review.

2. Architecture Overview

Human Attribution Thread

Every session anchored to an authenticated human identity (MFA verified for confidential/restricted data). Named responsible person (NAIC requirement). Lawful basis recorded (GDPR). SOX control reference. All agent actions inherit human_user_id as foreign key.

Immutable Audit Storage

Append-only PostgreSQL with cryptographic hash chaining — each row stores SHA-256 of the previous row's hash plus its own content. Sequence numbers prevent reordering. 7-year retention minimum. Replaces SQLite WAL which cannot survive an examiner who understands databases.

Human Gate Decision Records

When a governance gate fires, the decision is captured with full context: what evidence was shown, who decided, when, rationale, MFA verification, and whether this is SOX control evidence. Signed and immutable.

Evidence Package Generator

On demand, produce a complete signed package: session record, audit trail, Gemini validations, gate decisions, artifacts, lineage, cost report, model cards, adverse action log. Ed25519-signed. Versioned — amendments create new versions, never modify originals.

Data Subject Rights Router

GDPR Articles 15–22. Access, erasure, portability, rectification, objection. 30-day SLA tracked automatically. Erasure cascades deletion across Qdrant, Postgres, n8n, vector memory — every deletion itself logged.

Model Risk Documentation

Per NAIC / SR 11-7: model cards for every AI system (Claude, Gemini, Ollama). Intended use, prohibited uses, validation method, known limitations, bias assessment, third-party risk tier, annual review schedule, named responsible person.

3. Regulatory Framework Mapping

FrameworkKey RequirementHow This PRD Addresses It
NAIC Model Bulletin on AINamed responsible person per AI systemhuman_sessions.responsible_party + model_cards.naic_responsible_person
NAIC Model Bulletin on AIAdverse action explanationsEvidence packages include adverse_action_log with explanation text
SOX §302/404Segregation of dutiesGemini validation (independent) + human gate decisions (documented SOD control)
SOX §302/404Change management audit trailAll identity card changes logged with before/after, author, approver
GDPR Article 15Data subject access within 30 daysDSR router with SLA deadline tracking, filtered evidence package generation
GDPR Article 17Right to erasureCascade deletion across all subsystems, confirmation artifact, audit log of deletion
EU AI ActConformity assessment documentationModel cards + evidence packages provide conformity assessment artifact
NY DFS Part 5005-year audit retention7-year retention floor (exceeds requirement) across all regulatory artifacts
NY DFS Part 50072-hour breach notificationIncident records with automatic 72-hour clock from detection
SOC 2 (Security TSC)Logical access controls with MFAhuman_sessions.mfa_verified gating + data_classification_ceiling enforcement
SOC 2 (Availability TSC)System uptime monitoring and SLA trackingIntegration with PRD 11 observability + incident records with notification SLA
SOC 2 (Processing Integrity)Complete, accurate, valid processingimmutable_audit_events chain + reconciliation engine (PRD 9) + Gemini validation
SOC 2 (Confidentiality TSC)Encryption of confidential informationdata_classification_ceiling + policy engine encryption requirements + Ed25519 package signing
SOC 2 (Privacy TSC)Privacy notice, consent, data minimizationdsr_requests router + lawful_basis field + purpose-scoped TTL retention
SOC 2 Type II6–12 month operational evidenceEvidence packages aggregated across reporting period; 7-year retention of all inputs
ISO 27001 (Clause 6)Information security risk assessmentRisk register linked to model_cards.third_party_risk_tier + incident records
ISO 27001 (Annex A.5)Information security policiesConstitutional contracts (PRD 5) + Statement of Applicability artifact
ISO 27001 (Annex A.8)Asset managementAsset inventory with data_classification tags across all subsystems
ISO 27001 (Annex A.9)Access controlpolicy_decision + policy_rationale per audit event + RBAC on all endpoints
ISO 27001 (Annex A.15)Supplier relationshipsmodel_cards serve as third-party risk assessment for foundation model vendors
ISO 27001 (Clause 9.3)Management reviewAnnual model reviews + outcome measurement metrics (PRD 15) feed management review
GLBA (Safeguards Rule)Written Information Security Program (WISP)WISP artifact generated from governance configuration + control documentation
GLBA (Safeguards Rule)Nonpublic Personal Information (NPI) protectionNPI classification tags + encryption + access controls + continuous classification (PRD 9)
GLBA (Safeguards Rule)Annual risk assessmentScheduled risk assessment with findings tracked in incident records
GLBA (Privacy Rule)Privacy notice to consumersPrivacy notice generator with lawful_basis documentation
GLBA (Pretexting Rule)Protection from social engineeringMFA verification + Guardian behavioral anomaly detection (PRD 11)
GLBA §501(b)Third-party service provider oversightmodel_cards third_party_risk_tier assessment + supplier review workflows

4. Requirements (50 Total)

Human Attribution (REQ-RCA-001 to 004)

REQ-RCA-001 Every session shall be anchored to an authenticated human user identity before any agent is spawned.
REQ-RCA-002 MFA verification shall be recorded for sessions touching confidential or restricted data.
REQ-RCA-003 All NHI audit events shall include human_user_id as a non-nullable foreign key.
REQ-RCA-004 A named responsible person (NAIC) shall be designated per session and per system deployment.

Immutable Audit Storage (REQ-RCA-005 to 008)

REQ-RCA-005 Audit events shall be stored in an append-only, cryptographically chained store with row-level integrity verification.
REQ-RCA-006 Hourly Merkle roots shall be published to an external write-once endpoint.
REQ-RCA-007 Audit storage shall be inaccessible to write/modify by any agent identity (NHI), only by the audit service account.
REQ-RCA-008 Audit events shall be retained for 7 years minimum.

Human Gate Documentation (REQ-RCA-009 to 011)

REQ-RCA-009 Every human gate firing shall produce a structured decision record including what evidence was presented, who decided, when, and the decision rationale.
REQ-RCA-010 Human gate decisions shall be signed and immutable once recorded.
REQ-RCA-011 Human gate decisions shall be included in evidence packages as first-class artifacts.

Evidence Packages (REQ-RCA-012 to 015)

REQ-RCA-012 The system shall generate a complete evidence package for any session on demand, without manual reconstruction.
REQ-RCA-013 Evidence packages shall be Ed25519-signed and include integrity hashes for all constituent files.
REQ-RCA-014 Evidence packages shall be immutable once generated; amendments create new versions.
REQ-RCA-015 Evidence package generation shall complete within 60 seconds for sessions up to 8 hours.

Data Retention (REQ-RCA-016 to 019)

REQ-RCA-016 Retention policy shall be unified across all subsystems: Qdrant, Postgres, n8n, vector memory, audit bus.
REQ-RCA-017 Audit events, human gate decisions, and evidence packages shall be retained for 7 years.
REQ-RCA-018 Legal hold shall pause retention-based deletion for flagged sessions.
REQ-RCA-019 All deletions shall themselves be logged to the immutable audit trail.

Data Subject Rights GDPR (REQ-RCA-020 to 022)

REQ-RCA-020 Data subject access requests shall produce a complete filtered evidence package within 30 days.
REQ-RCA-021 Erasure requests shall cascade deletion across all subsystems and produce a deletion confirmation artifact.
REQ-RCA-022 Automated decision objections (Art. 22) shall pause agent processing on the affected data subject pending human review.

Model Risk NAIC/SR 11-7 (REQ-RCA-023 to 025)

REQ-RCA-023 A model card shall exist for every AI model used in the platform.
REQ-RCA-024 Third-party model providers shall be assessed as third-party service providers per NY DFS Part 500.
REQ-RCA-025 Annual model reviews shall be scheduled, tracked, and their completion recorded.

Incident Response NY DFS Part 500 (REQ-RCA-026 to 028)

REQ-RCA-026 Guardian TERMINATE events on confidential/restricted sessions shall automatically open incident records.
REQ-RCA-027 The system shall track the 72-hour notification clock from incident detection to completion.
REQ-RCA-028 Post-incident reports shall be generated as evidence package variants.

Regulatory Reporting (REQ-RCA-029 to 032)

REQ-RCA-029 The system shall generate an annual SOX management attestation report covering AI controls in scope.
REQ-RCA-030 The system shall generate a NY DFS annual certification artifact.
REQ-RCA-031 EU AI Act conformity assessment documentation shall be maintained and updated on model version changes.
REQ-RCA-032 NAIC adverse action logs shall include explanation text sufficient for examination.

SOC 2 Trust Service Criteria (REQ-RCA-033 to 038)

REQ-RCA-033 Security TSC: Logical access controls shall enforce MFA for administrative operations and any session accessing confidential or restricted data; failed access attempts shall be logged as audit events.
REQ-RCA-034 Availability TSC: System uptime, SLA adherence, and capacity metrics shall be continuously monitored; availability breaches shall trigger incident records with notification SLA tracking.
REQ-RCA-035 Processing Integrity TSC: Every data transformation shall be complete, accurate, and valid; reconciliation manifests (PRD 9) and immutable audit chain shall provide processing integrity evidence.
REQ-RCA-036 Confidentiality TSC: Confidential and restricted data shall be encrypted at rest (AES-256) and in transit (TLS 1.3); encryption failure shall block the operation and generate an audit event.
REQ-RCA-037 Privacy TSC: Privacy notices, consent records, and data minimization controls shall be maintained per processing activity with purpose-scoped TTL enforcement.
REQ-RCA-038 SOC 2 Type II: Operational evidence for each Trust Service Criterion shall be aggregated across the reporting period (typically 6–12 months) and exportable as a SOC 2 evidence package.

ISO 27001 ISMS (REQ-RCA-039 to 044)

REQ-RCA-039 A risk register shall track information security risks with threat source, vulnerability, asset impact, likelihood, current controls, and treatment plan per ISO 27001 Clause 6.1.
REQ-RCA-040 A Statement of Applicability (SoA) artifact shall document which of the 93 Annex A controls apply, their implementation status, and justification for any exclusions.
REQ-RCA-041 An asset inventory shall enumerate every data asset with classification, owner, location, and retention class; the inventory shall cascade into evidence packages.
REQ-RCA-042 Access control decisions (policy_decision + policy_rationale) shall be recorded on every audit event in conformance with Annex A.9 access control requirements.
REQ-RCA-043 Supplier relationships (foundation model vendors, cloud providers) shall be assessed as ISO 27001 Annex A.15 suppliers with documented risk tier, contractual controls, and ongoing monitoring.
REQ-RCA-044 Management review (Clause 9.3) shall occur at least annually with inputs from audit findings, outcome metrics, incident history, and model reviews; decisions and corrective actions shall be recorded.

GLBA Safeguards / Privacy / Pretexting (REQ-RCA-045 to 050)

REQ-RCA-045 A Written Information Security Program (WISP) artifact shall be generated from the governance configuration, documenting administrative, technical, and physical safeguards per the GLBA Safeguards Rule.
REQ-RCA-046 Nonpublic Personal Information (NPI) — as defined in 16 CFR 314.2 — shall be identified, tagged, and tracked through the continuous classification engine (PRD 9); NPI access shall require elevated authorization.
REQ-RCA-047 An annual risk assessment focused on reasonably foreseeable internal and external risks to NPI shall be conducted and documented; findings shall drive remediation tracked in incident records.
REQ-RCA-048 Privacy notices compliant with the GLBA Privacy Rule (16 CFR 313) shall be generated for consumers including information-sharing practices, opt-out mechanisms, and lawful basis.
REQ-RCA-049 Pretexting protections — MFA verification, behavioral anomaly detection (PRD 11 Guardian), and session-level risk scoring — shall block unauthorized NPI access attempts via social engineering.
REQ-RCA-050 Third-party service providers accessing NPI (foundation model vendors, data processors) shall have documented oversight per GLBA §501(b) including contractual safeguards, due diligence, and ongoing monitoring recorded in model_cards.

5. Implementation Status

This PRD is implemented as the compliance module in the agentic-data-plane service at port 8099.

Live Endpoints

MethodEndpointPurpose
POST/api/v1/compliance/sessionsInitialize human-attributed session
POST/api/v1/compliance/audit-eventsRecord chained audit event
POST/api/v1/compliance/gate-decisionsRecord human gate decision
POST/api/v1/compliance/evidence-packages/:sessionIdGenerate evidence package
POST/api/v1/compliance/dsrSubmit data subject rights request
PATCH/api/v1/compliance/dsr/:requestIdUpdate DSR status
POST/api/v1/compliance/modelsRegister model card
GET/api/v1/compliance/modelsList all model cards
POST/api/v1/compliance/incidentsOpen incident with 72-hour clock
PATCH/api/v1/compliance/incidents/:incidentIdUpdate incident status

Database Schema

Migration 015_compliance.sql adds 7 tables:

  • human_sessions — per-session human attribution with MFA verification
  • immutable_audit_events — cryptographically chained with prev_event_hash + sequence_number
  • human_gate_decisions — signed decisions with full evidence context
  • evidence_packages — Ed25519-signed, versioned
  • dsr_requests — GDPR Art. 15–22 with 30-day SLA tracking
  • model_cards — NAIC / SR 11-7 model governance
  • incident_records — NY DFS Part 500 with 72-hour notification clock

All tables include retention_until columns defaulting to 7 years.

6. Prompt to Build It

A ready-to-paste Claude Code prompt that generates the regulatory compliance module from scratch against the existing agentic-data-plane project.

Build a Regulatory Compliance & Audit Trail module for a TypeScript/Node.js data-plane service. The module must produce regulator-ready artifacts for NAIC Model Bulletin on AI, SOX §302/404, GDPR Articles 15-22, EU AI Act, NY DFS Part 500, SOC 2 Trust Service Criteria, ISO 27001 ISMS, and GLBA Safeguards/Privacy/Pretexting rules. Target environment: ESM TypeScript (Node 20+), PostgreSQL for persistence, Express REST API, Ed25519 signing, Zod validation, existing EventPublisher integration.

## Module Structure
Create `src/compliance/` with:
- `types.ts` - all type definitions (HumanSessionRecord, ImmutableAuditEvent, HumanGateDecision, EvidencePackage, DataSubjectRightsRequest, ModelCard, IncidentRecord and their input variants)
- `ComplianceEngine.ts` - core engine class with constructor(pool: pg.Pool, publisher: EventPublisher)

## Database Schema (Migration)
Create `src/db/migrations/015_compliance.sql` with 7 tables:
1. human_sessions - session_id PK, human_user_id, authenticated_by enum (mfa_totp/mfa_webauthn/sso_oidc/sso_saml/api_key), role, responsible_party (NAIC), data_classification_ceiling, lawful_basis (GDPR), naic_system_id, sox_control_ref, mfa_verified bool, initiated_at, retention_until DATE default +7 years
2. immutable_audit_events - event_id UUID PK, session_id FK, human_user_id, nhi_agent_id, event_type, tool, data_classification, policy_decision, policy_rationale, gemini_validation_ref, payload JSONB, prev_event_hash VARCHAR(64), this_event_hash VARCHAR(64) UNIQUE, sequence_number INT, timestamp_utc, UNIQUE(session_id, sequence_number)
3. human_gate_decisions - gate_id PK, session_id FK, gate_type enum, presented_to, evidence_shown JSONB, decision enum, decision_rationale, decision_by, mfa_verified, sox_control_evidence, triggered_at, decision_timestamp, signature VARCHAR(64)
4. evidence_packages - package_id PK, session_id FK, generated_at, version INT, file_count, total_size_bytes, signature, manifest_hash, UNIQUE(session_id, version)
5. dsr_requests - request_id PK, subject_id, right_type enum (access/erasure/portability/rectification/objection), status, submitted_at, sla_deadline (submitted_at + 30 days), completed_at, assigned_to, resolution_notes
6. model_cards - model_id PK, model_type, vendor, version, intended_use, prohibited_uses JSONB, validation_date, validated_by, validation_method, known_limitations JSONB, bias_assessment, third_party_risk_tier enum, annual_review_due, naic_responsible_person
7. incident_records - incident_id PK, opened_at, classification, trigger_source, affected_session_ids JSONB, status, notification_deadline (opened_at + 72 hours per NY DFS), notified_at, post_incident_report_ref, resolution

All tables include retention_until columns defaulting to 7 years.
Extend lineage_event_chain CHECK constraint to include SESSION_INIT, GATE_DECISION, EVIDENCE_GENERATED, DSR_SUBMITTED, INCIDENT_OPENED.

## ComplianceEngine Methods
- initSession(input, agent) - validates MFA for confidential/restricted, persists session, publishes compliance.session_init event
- recordAuditEvent(input, agent) - fetches prev event hash + sequence, computes SHA-256(content + prev_hash), inserts with incremented sequence
- recordGateDecision(input, agent) - signs decision hash, stores, publishes compliance.gate_decision
- generateEvidencePackage(sessionId, agent) - collects session + audit events + gate decisions, computes manifest hash, signs, stores versioned (amendments create new versions, never modify originals)
- submitDsr(input, agent) - creates request with 30-day SLA deadline
- updateDsrStatus(requestId, status, notes)
- registerModel(card, agent) - UPSERT on model_id
- listModels()
- openIncident(input, agent) - 72-hour notification clock from opened_at
- updateIncidentStatus(incidentId, status, resolution)

## REST Routes
Create `src/api/rest/complianceRoutes.ts` with Zod schemas and requireRole auth:
- POST /compliance/sessions (admin, compliance_officer)
- POST /compliance/audit-events (admin, analyst, compliance_officer)
- POST /compliance/gate-decisions (admin, compliance_officer)
- POST /compliance/evidence-packages/:sessionId (admin, compliance_officer)
- POST /compliance/dsr, PATCH /compliance/dsr/:requestId (admin, compliance_officer)
- POST /compliance/models, GET /compliance/models (admin, viewer, analyst, compliance_officer)
- POST /compliance/incidents, PATCH /compliance/incidents/:incidentId (admin, compliance_officer)

## Event Types
Add to existing events/types.ts:
- 5 event types: compliance.session_init, compliance.gate_decision, compliance.evidence_generated, compliance.dsr_submitted, compliance.incident_opened
- All mapped to EVENT_CATEGORY 'regulatory_compliance'
- PG names: SESSION_INIT, GATE_DECISION, EVIDENCE_GENERATED, DSR_SUBMITTED, INCIDENT_OPENED
- 5 payload interfaces added to EventPayload union

## Integration
Wire into src/index.ts (instantiate ComplianceEngine with pool + publisher) and src/api/server.ts (register routes at /api/v1, add to ServerDependencies).

## Requirements (50 total, REQ-RCA-001 to 050)
Implement all 50 requirements from the PRD: human attribution (1-4), immutable audit (5-8), human gate decisions (9-11), evidence packages (12-15), data retention (16-19), GDPR DSR (20-22), model risk NAIC/SR 11-7 (23-25), incident response NY DFS (26-28), regulatory reporting (29-32), SOC 2 TSC (33-38), ISO 27001 ISMS (39-44), GLBA (45-50).

## Design Principles
- Append-only for corrections (GDPR Art. 16 rectification without modifying originals)
- 7-year retention floor (exceeds NY DFS 5yr, meets SOX 7yr) universally
- Named responsible person per session AND per deployment (NAIC requires both)
- MFA required at session init for confidential+ data classification
- Hash-chained events with sequence_number prevent tampering AND reordering
- Evidence packages are immutable - new versions for amendments, originals preserved

After implementation: run npx tsc --noEmit (clean compile), npm run test:unit (all pass), rebuild Docker container, verify /api/v1/compliance/sessions responds.

7. Integration Points

→ Multi-Agent Orchestration (PRD 2)

Human session record created at session init; human_user_id injected into state schema; human gate decision records added to verification gate events.

→ Agent Governance (PRD 5)

Audit bus upgraded to immutable chained store; 90-day retention extended to 7 years; governance_report extended to produce full evidence packages.

→ Data Plane (PRD 9)

Data lineage records included in evidence packages; personal data classification feeds GDPR rights router.

→ Runtime Security (PRD 11)

Guardian TERMINATE events trigger incident response workflow; behavioral anomalies on personal data sessions flagged for GDPR Art. 22 review.

→ Agent Economics (PRD 10)

Cost reports included in evidence packages for SOX financial controls evidence.

→ Outcome Measurement (PRD 15)

Outcome metrics included in model risk documentation and NAIC model governance reporting.