Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
oas-ci / oas-validate (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
sm-remote-ci / build-and-test (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
api-governance / spectral-lint (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
namespace StellaOps.Audit.ReplayToken;
|
|
|
|
/// <summary>
|
|
/// Generates CLI snippets for one-click reproduce functionality.
|
|
/// </summary>
|
|
public sealed class ReplayCliSnippetGenerator
|
|
{
|
|
/// <summary>
|
|
/// Generates a CLI command to reproduce a decision.
|
|
/// </summary>
|
|
public string GenerateDecisionReplay(
|
|
ReplayToken token,
|
|
string alertId,
|
|
string? feedManifestUri = null,
|
|
string? policyVersion = null)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(token);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(alertId);
|
|
|
|
var parts = new List<string>
|
|
{
|
|
"stellaops",
|
|
"replay",
|
|
"decision",
|
|
$"--token {token.Value}",
|
|
$"--alert-id {alertId}"
|
|
};
|
|
|
|
if (!string.IsNullOrWhiteSpace(feedManifestUri))
|
|
{
|
|
parts.Add($"--feed-manifest {feedManifestUri.Trim()}");
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(policyVersion))
|
|
{
|
|
parts.Add($"--policy-version {policyVersion.Trim()}");
|
|
}
|
|
|
|
return string.Join(" \\\n+ ", parts);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generates a CLI command to reproduce unknowns scoring.
|
|
/// </summary>
|
|
public string GenerateScoringReplay(
|
|
ReplayToken token,
|
|
string subjectKey,
|
|
string? configVersion = null)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(token);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(subjectKey);
|
|
|
|
var parts = new List<string>
|
|
{
|
|
"stellaops",
|
|
"replay",
|
|
"scoring",
|
|
$"--token {token.Value}",
|
|
$"--subject {subjectKey}"
|
|
};
|
|
|
|
if (!string.IsNullOrWhiteSpace(configVersion))
|
|
{
|
|
parts.Add($"--config-version {configVersion.Trim()}");
|
|
}
|
|
|
|
return string.Join(" \\\n+ ", parts);
|
|
}
|
|
}
|