using ScadaLink.Commons.Types.Enums; namespace ScadaLink.Commons.Entities.Audit; /// /// Single source of truth for AuditLog (#23) rows. Central rows leave ForwardState null; /// site rows leave IngestedAtUtc null until ingest. Append-only. /// public sealed record AuditEvent { /// Idempotency key; uniquely identifies one audit lifecycle event. public Guid EventId { get; init; } /// UTC timestamp when the audited action occurred at its source. public DateTime OccurredAtUtc { get; init; } /// UTC timestamp when the row was ingested at central; null on the site hot-path. public DateTime? IngestedAtUtc { get; init; } /// Trust-boundary channel the audited action crossed. public AuditChannel Channel { get; init; } /// Specific event kind within the channel (see alog.md §4). public AuditKind Kind { get; init; } /// Correlation id linking related audit rows (e.g. the cached-op lifecycle). public Guid? CorrelationId { get; init; } /// /// Id of the originating script execution / inbound request — the universal /// per-run correlation value, distinct from (which /// is the per-operation lifecycle id). /// public Guid? ExecutionId { get; init; } /// Site id where the action originated; null for central-direct events. public string? SourceSiteId { get; init; } /// Instance id where the action originated, when applicable. public string? SourceInstanceId { get; init; } /// Script that initiated the action (script trust boundary), when applicable. public string? SourceScript { get; init; } /// Authenticated actor for inbound paths (API key name, user, etc.). public string? Actor { get; init; } /// Target of the action: external system name, db connection name, list name, or inbound method. public string? Target { get; init; } /// Lifecycle status of this row. public AuditStatus Status { get; init; } /// HTTP status code where applicable (outbound API + inbound API). public int? HttpStatus { get; init; } /// Duration of the audited action in milliseconds, when measurable. public int? DurationMs { get; init; } /// Human-readable error summary on failure rows. public string? ErrorMessage { get; init; } /// Verbose error detail (stack/exception) on failure rows. public string? ErrorDetail { get; init; } /// Truncated/redacted request summary; capped per AuditLogOptions. public string? RequestSummary { get; init; } /// Truncated/redacted response summary; capped per AuditLogOptions. public string? ResponseSummary { get; init; } /// True when Request/Response summaries were truncated to the payload cap. public bool PayloadTruncated { get; init; } /// Free-form JSON extension column for channel-specific extras. public string? Extra { get; init; } /// Site-local forwarding state; null on central rows. public AuditForwardState? ForwardState { get; init; } }