feat: DEBT-014 + DEBT-029 Audit Infrastructure (Duplicate Detection & Event Logging)
DEBT-014: Duplicate detection & reconciliation tracking - Create operation_audit_trail migration (0011) - Hook OutboxPollerJob to detect and log duplicates - Implement MetricsSql queries for duplicate/reconciliation metrics DEBT-029: Audit trail consumer integration - Create AuditTrailConsumer for event-driven audit logging - Map 12+ event types to compliance.operation_audit_trail - Register consumer in Program.cs DI and OutboxPollerJob AGENTS.md v16.0 Compliance: ✅ Necessity: Both DEBT items from registry (2+3 pts) ✅ Simplicity: Event-driven via Outbox pattern (existing infra) ✅ Pattern: Vertical Slice consumer + SQL queries (established) ✅ Traceability: All event types documented and mapped ✅ Safety: Idempotent logging via ON CONFLICT DO NOTHING ✅ Maturity: Framework ready before feature implementation Impact: Medium/High (5 pts total, Q3 target 4 pts exceeded) Status: Code ready, awaiting SSH tunnel for migration test Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
-- DEBT-014: Operation Audit Trail for Duplicate & Reconciliation Tracking
|
||||
|
||||
CREATE SCHEMA IF NOT EXISTS compliance;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS compliance.operation_audit_trail (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
event_type VARCHAR(50) NOT NULL,
|
||||
correlation_id UUID NOT NULL,
|
||||
entity_type VARCHAR(50) NOT NULL,
|
||||
entity_id UUID NOT NULL,
|
||||
details JSONB,
|
||||
detected_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
resolved_by UUID,
|
||||
resolved_at TIMESTAMP,
|
||||
published_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
revision INT NOT NULL DEFAULT 1,
|
||||
|
||||
CONSTRAINT fk_compliance_audit_trail_resolver
|
||||
FOREIGN KEY (resolved_by) REFERENCES model_operations.approvers(id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_audit_trail_event_type ON compliance.operation_audit_trail(event_type, detected_at DESC);
|
||||
CREATE INDEX idx_audit_trail_correlation ON compliance.operation_audit_trail(correlation_id);
|
||||
CREATE INDEX idx_audit_trail_entity ON compliance.operation_audit_trail(entity_type, entity_id);
|
||||
Reference in New Issue
Block a user