97444c932f
- 2 audit query endpoints: GET /audit/events (filtered), GET /audit/events/{id}
- 1 GDPR endpoint: POST /compliance/gdpr-request (right-to-be-forgotten)
- Immutable INSERT-only audit_events table with correlation_id
- GDPR redaction (soft delete): anonymize personal data, keep audit trail
- Regulatory compliance: FSS 7-year retention, GDPR Article 17, PCI-DSS logging
- Integration: Event subscribers for all model operations
- Schema: Append-only with PIT tracking, evidence links (S3 artifacts)
- Tests: 6+ integration scenarios (insert, query, GDPR redaction)
- AGENTS.md v16.0 13/13 compliance ✅
Closes workstream I (Phase 2 implementation, compliance layer).
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
56 lines
2.4 KiB
C#
56 lines
2.4 KiB
C#
namespace KArtSell.Modules.ModelOperations.Compliance;
|
|
|
|
/// <summary>
|
|
/// Immutable audit event for compliance trail (INSERT-only, no UPDATE/DELETE).
|
|
/// Links to model operations, approvals, sell decisions, and trades.
|
|
/// </summary>
|
|
public class AuditEvent
|
|
{
|
|
public Guid Id { get; set; }
|
|
public string EventType { get; set; } // MODEL_CREATED, APPROVAL_PROPOSED, APPROVAL_APPROVED, MODEL_ACTIVATED, SELL_DECISION_MADE, SELL_EXECUTED, BACKTEST_COMPLETED, DATA_CORRECTION
|
|
public string EntityType { get; set; } // MODEL, APPROVAL, SELL_DECISION, TRADE_EXECUTION
|
|
public Guid EntityId { get; set; }
|
|
public string ActorEmail { get; set; }
|
|
public string? ActorRole { get; set; } // MAKER, CHECKER, SRE, SYSTEM
|
|
public DateTime EventAt { get; set; }
|
|
public string Result { get; set; } // SUCCESS, FAILURE, PARTIAL
|
|
public string? ErrorMessage { get; set; }
|
|
public Dictionary<string, object>? Details { get; set; } // Event-specific metadata
|
|
public string[]? EvidenceLinks { get; set; } // S3 artifact URLs
|
|
public string? IpAddress { get; set; }
|
|
public string? UserAgent { get; set; }
|
|
public DateTime PublishedAt { get; set; }
|
|
public Guid CorrelationId { get; set; } // Links related events in audit trail
|
|
public int Revision { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event type enumeration (reference data).
|
|
/// </summary>
|
|
public static class AuditEventTypes
|
|
{
|
|
public const string ModelCreated = "MODEL_CREATED";
|
|
public const string ModelArchived = "MODEL_ARCHIVED";
|
|
public const string ApprovalProposed = "APPROVAL_PROPOSED";
|
|
public const string ApprovalApproved = "APPROVAL_APPROVED";
|
|
public const string ApprovalRejected = "APPROVAL_REJECTED";
|
|
public const string ModelActivated = "MODEL_ACTIVATED";
|
|
public const string ModelDeactivated = "MODEL_DEACTIVATED";
|
|
public const string SellDecisionMade = "SELL_DECISION_MADE";
|
|
public const string SellExecuted = "SELL_EXECUTED";
|
|
public const string BacktestCompleted = "BACKTEST_COMPLETED";
|
|
public const string DataCorrection = "DATA_CORRECTION";
|
|
public const string ComplianceAudit = "COMPLIANCE_AUDIT";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Entity types for audit events.
|
|
/// </summary>
|
|
public static class AuditEntityTypes
|
|
{
|
|
public const string Model = "MODEL";
|
|
public const string Approval = "APPROVAL";
|
|
public const string SellDecision = "SELL_DECISION";
|
|
public const string TradeExecution = "TRADE_EXECUTION";
|
|
}
|