Record Class RedactionAuditEvent

java.lang.Object
java.lang.Record
com.tnsai.quality.redaction.RedactionAuditEvent
Record Components:
eventId - stable id for cross-system correlation
timestamp - when redaction completed (UTC)
scope - which sink fired this — LOG_ATTR, MEMORY_WRITE, etc.
eventContext - framework correlation context at call time; carries tenantId, sessionId, agentId, traceId
patternCounts - patternName → match count (e.g. "email" → 3, "credit_card" → 1)
highestSeverity - max severity across all findings; lets a notifier hop straight to "is this CRITICAL?" without walking the counts map
totalFindings - sum across patternCounts — pre-computed so dashboards can plot it without aggregation

public record RedactionAuditEvent(String eventId, Instant timestamp, RedactionScope scope, com.tnsai.observability.events.EventContext eventContext, Map<String,Integer> patternCounts, Severity highestSeverity, int totalFindings) extends Record
Audit record for one redaction call (issue #80).

Emitted by AuditingRedactor whenever the wrapped redactor returns at least one RedactionFinding. Operators get the compliance audit trail ("we redacted 3 credit-card matches in tenant acme today") without the audit log itself becoming a leak vector — the redacted content never appears here, only metadata.

Why a flat Map<patternName, count>: cardinality is bounded by the pattern catalog (~14 patterns by default), and counts are aggregate-friendly for downstream metrics (Prometheus counter labels, Datadog facets).

Since:
0.9.0 (issue #80)
  • Constructor Details

    • RedactionAuditEvent

      public RedactionAuditEvent(String eventId, Instant timestamp, RedactionScope scope, com.tnsai.observability.events.EventContext eventContext, Map<String,Integer> patternCounts, Severity highestSeverity, int totalFindings)
      Creates an instance of a RedactionAuditEvent record class.
      Parameters:
      eventId - the value for the eventId record component
      timestamp - the value for the timestamp record component
      scope - the value for the scope record component
      eventContext - the value for the eventContext record component
      patternCounts - the value for the patternCounts record component
      highestSeverity - the value for the highestSeverity record component
      totalFindings - the value for the totalFindings record component
  • Method Details

    • from

      public static RedactionAuditEvent from(List<RedactionFinding> findings, RedactionContext ctx)
      Build an audit event from the findings produced by a redactor call. Aggregates counts per pattern and computes the highest severity in a single pass.
      Throws:
      IllegalArgumentException - if findings is empty — audit events should only be emitted when something actually got redacted
    • isCritical

      public boolean isCritical()
      Severity-tier shorthand — handy for if (event.isCritical()) gates that decide whether to fire the OnNotification hook.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • eventId

      public String eventId()
      Returns the value of the eventId record component.
      Returns:
      the value of the eventId record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • scope

      public RedactionScope scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • eventContext

      public com.tnsai.observability.events.EventContext eventContext()
      Returns the value of the eventContext record component.
      Returns:
      the value of the eventContext record component
    • patternCounts

      public Map<String,Integer> patternCounts()
      Returns the value of the patternCounts record component.
      Returns:
      the value of the patternCounts record component
    • highestSeverity

      public Severity highestSeverity()
      Returns the value of the highestSeverity record component.
      Returns:
      the value of the highestSeverity record component
    • totalFindings

      public int totalFindings()
      Returns the value of the totalFindings record component.
      Returns:
      the value of the totalFindings record component