namespace Hc900Crawler.Core.Application.Feedforward;

public interface IFeedforwardConfigStore
{
    Task<IReadOnlyList<ColumnConfig>> LoadAllAsync(CancellationToken ct = default);
    Task<int>  SaveColumnAsync(ColumnConfig cfg, CancellationToken ct = default);
    Task       DeleteColumnAsync(int columnId, CancellationToken ct = default);
}

public interface IFeedforwardAdvisoryStore
{
    void Set(AdvisoryResult result);
    AdvisoryResult? Get(int columnId);
    IReadOnlyCollection<AdvisoryResult> GetAll();
}

// Phase II: WriteGuard — SP 쓰기 전 안전 검증
public sealed record WriteCheckResult(bool Allowed, string? Reason);

public interface IFeedforwardWriteGuard
{
    WriteCheckResult Check(ColumnConfig cfg, StreamAdvisory adv, StreamConfig sc, AdvisoryResult column);
}

// Phase II: 감사 로그 서비스
public sealed record FfActionLogEntry(
    int ColumnId, string ActionType,
    string? StreamKey = null, double? SpValue = null,
    string? NodeId = null, string? Result = null,
    string? WriteguardReason = null, string? OperatorName = null);

public interface IFeedforwardAuditService
{
    Task LogAsync(FfActionLogEntry entry, CancellationToken ct = default);
    Task<IReadOnlyList<dynamic>> QueryAsync(int? columnId = null, int limit = 50, CancellationToken ct = default);
}
