namespace ZB.MOM.WW.ScadaBridge.Commons.Messages.Instance;

/// <summary>
/// Command to set a static attribute value on an Instance Actor.
/// Updates in-memory state and persists the override to SQLite.
/// </summary>
/// <param name="CorrelationId">Per-operation correlation id.</param>
/// <param name="InstanceUniqueName">Unique name of the target instance.</param>
/// <param name="AttributeName">Canonical name of the attribute to write.</param>
/// <param name="Value">Canonical string form of the new value.</param>
/// <param name="Timestamp">UTC timestamp of the command.</param>
/// <param name="SourceExecutionId">
/// Audit Log #23 (ParentExecutionId tag-cascade): the <c>ExecutionId</c> of the
/// execution issuing this write — a site script run
/// (<c>ScriptRuntimeContext.SetAttribute</c>) or the inbound API request behind a
/// <c>Route.To(...).SetAttributes(...)</c>. Additive and nullable; <c>null</c>
/// when the write has no audited originating execution (central Test Run,
/// deployment tooling, tests). The Instance Actor stamps it onto the resulting
/// <c>AttributeValueChanged</c> so an alarm the write trips can record it as the
/// on-trigger script run's <c>ParentExecutionId</c>.
/// </param>
public record SetStaticAttributeCommand(
    string CorrelationId,
    string InstanceUniqueName,
    string AttributeName,
    string Value,
    DateTimeOffset Timestamp,
    Guid? SourceExecutionId = null);

/// <summary>
/// Response confirming that a static attribute was set.
/// </summary>
public record SetStaticAttributeResponse(
    string CorrelationId,
    string InstanceUniqueName,
    string AttributeName,
    bool Success,
    string? ErrorMessage,
    DateTimeOffset Timestamp);
