using ZB.MOM.WW.ScadaBridge.Commons.Entities.Audit;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;
namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Management;
public record QueryAuditLogCommand(
string? User = null, string? EntityType = null, string? Action = null,
DateTimeOffset? From = null, DateTimeOffset? To = null,
int Page = 1, int PageSize = 50);
///
/// Result wrapper for .
///
///
/// This record exists specifically so the handler does not return the repository's
/// (IReadOnlyList<AuditLogEntry> Entries, int TotalCount) ValueTuple directly.
/// A ValueTuple exposes Item1/Item2 as public fields, and
/// serializes only properties unless
/// JsonSerializerOptions.IncludeFields is set — so a tuple result serialized to
/// the literal string {} and every audit-config query looked empty no
/// matter how many rows the query matched (deferred-work register row 46). Mirrors the
/// SecuredWriteListResult shape used by the other paged management query.
///
/// The page of configuration-change audit entries.
/// Total number of rows matching the filters (unpaged).
public record AuditLogQueryResult(IReadOnlyList Entries, int TotalCount);
///
/// Verifies the central AuditLog hash chain for one UTC calendar month (audit roadmap T1,
/// ScadaBridge#41). Read-only; gated on the OperationalAudit roles and refused for a
/// site-scoped caller, because a month's chain spans every site.
///
/// The month to verify, YYYY-MM.
public record VerifyAuditChainCommand(string Month);
///
/// Checks AuditLog chain heads exported off-box (AuditLog:HashChain:HeadExport,
/// ScadaBridge#107 item 1) against the database chain: does the database still carry each
/// exported hash at its exported sequence? Read-only; same gate as
/// . The CLI reads the records from the export files.
///
/// The exported head records (at most 50,000; duplicates are collapsed).
public record VerifyAuditChainHeadsCommand(IReadOnlyList Records);
///
/// Lists the AuditLog Parquet cold archives under the configured archive directory (audit
/// roadmap T2, ScadaBridge#42). Read-only; OperationalAudit roles, refused for a site-scoped
/// caller because an archive holds every site's rows.
///
public record ListAuditArchivesCommand;
///
/// Verifies one AuditLog Parquet archive (ScadaBridge#42): file integrity against its
/// manifest, the hash chain recomputed over the archived rows, and the chain end against the
/// checkpoint anchor the partition purge left. Read-only; same gate as
/// .
///
/// The archive name, as audit archive list reports it.
public record VerifyAuditArchiveCommand(string Name);
///
/// Runs the AuditLog archive cleanup (ScadaBridge#109) now: deletes superseded stale archives
/// a retried purge left behind and archives past AuditLog:Archive:RetentionDays — or,
/// with , only reports what it would delete. The purge actor runs the
/// same pass after every purge tick. Administrator only (it deletes files).
///
/// Report only; delete nothing.
public record CleanupAuditArchivesCommand(bool DryRun);