Refactor code structure for improved readability and maintainability; optimize performance in key functions.
This commit is contained in:
54
src/__Libraries/StellaOps.Replay/Models/ReplayModels.cs
Normal file
54
src/__Libraries/StellaOps.Replay/Models/ReplayModels.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Immutable;
|
||||
using StellaOps.Evidence.Models;
|
||||
|
||||
namespace StellaOps.Replay.Models;
|
||||
|
||||
public sealed record ReplayResult
|
||||
{
|
||||
public required string RunId { get; init; }
|
||||
public bool Success { get; init; }
|
||||
public string? VerdictJson { get; init; }
|
||||
public string? VerdictDigest { get; init; }
|
||||
public EvidenceIndex? EvidenceIndex { get; init; }
|
||||
public DateTimeOffset ExecutedAt { get; init; }
|
||||
public long DurationMs { get; init; }
|
||||
public IReadOnlyList<string>? Errors { get; init; }
|
||||
|
||||
public static ReplayResult Failed(string runId, string message, IReadOnlyList<string> errors) =>
|
||||
new()
|
||||
{
|
||||
RunId = runId,
|
||||
Success = false,
|
||||
Errors = errors.Prepend(message).ToList(),
|
||||
ExecutedAt = DateTimeOffset.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
public sealed record DeterminismCheckResult
|
||||
{
|
||||
public bool IsDeterministic { get; init; }
|
||||
public string? DigestA { get; init; }
|
||||
public string? DigestB { get; init; }
|
||||
public IReadOnlyList<JsonDifference> Differences { get; init; } = [];
|
||||
}
|
||||
|
||||
public sealed record JsonDifference(string Path, string Description);
|
||||
|
||||
public sealed record ReplayOptions
|
||||
{
|
||||
public bool UseFrozenTime { get; init; } = true;
|
||||
public bool VerifyDigests { get; init; } = true;
|
||||
public bool CaptureEvidence { get; init; } = true;
|
||||
}
|
||||
|
||||
public sealed record ValidationResult(bool IsValid, IReadOnlyList<string> Errors);
|
||||
|
||||
public sealed record LoadResult<T>
|
||||
{
|
||||
public bool Success { get; init; }
|
||||
public T? Value { get; init; }
|
||||
public string? Error { get; init; }
|
||||
|
||||
public static LoadResult<T> Ok(T value) => new() { Success = true, Value = value };
|
||||
public static LoadResult<T> Fail(string error) => new() { Success = false, Error = error };
|
||||
}
|
||||
19
src/__Libraries/StellaOps.Replay/Models/ScanModels.cs
Normal file
19
src/__Libraries/StellaOps.Replay/Models/ScanModels.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using StellaOps.Evidence.Models;
|
||||
using StellaOps.Testing.Manifests.Models;
|
||||
|
||||
namespace StellaOps.Replay.Models;
|
||||
|
||||
public sealed record ScanResult(
|
||||
object Verdict,
|
||||
EvidenceIndex? EvidenceIndex,
|
||||
long DurationMs);
|
||||
|
||||
public sealed record ScannerOptions
|
||||
{
|
||||
public required FeedSnapshot FeedSnapshot { get; init; }
|
||||
public required PolicySnapshot PolicySnapshot { get; init; }
|
||||
public required CryptoProfile CryptoProfile { get; init; }
|
||||
public long? PrngSeed { get; init; }
|
||||
public DateTimeOffset? FrozenTime { get; init; }
|
||||
public required string CanonicalizationVersion { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user