Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Created project for StellaOps.Scanner.Analyzers.Native.Tests with necessary dependencies. - Documented roles and guidelines in AGENTS.md for Scheduler module. - Implemented IResolverJobService interface and InMemoryResolverJobService for handling resolver jobs. - Added ResolverBacklogNotifier and ResolverBacklogService for monitoring job metrics. - Developed API endpoints for managing resolver jobs and retrieving metrics. - Defined models for resolver job requests and responses. - Integrated dependency injection for resolver job services. - Implemented ImpactIndexSnapshot for persisting impact index data. - Introduced SignalsScoringOptions for configurable scoring weights in reachability scoring. - Added unit tests for ReachabilityScoringService and RuntimeFactsIngestionService. - Created dotnet-filter.sh script to handle command-line arguments for dotnet. - Established nuget-prime project for managing package downloads.
88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
using System.Text.Json.Nodes;
|
|
|
|
namespace StellaOps.Findings.Ledger.Domain;
|
|
|
|
public sealed record LedgerEventDraft(
|
|
string TenantId,
|
|
Guid ChainId,
|
|
long SequenceNumber,
|
|
Guid EventId,
|
|
string EventType,
|
|
string PolicyVersion,
|
|
string FindingId,
|
|
string ArtifactId,
|
|
Guid? SourceRunId,
|
|
string ActorId,
|
|
string ActorType,
|
|
DateTimeOffset OccurredAt,
|
|
DateTimeOffset RecordedAt,
|
|
JsonObject Payload,
|
|
JsonObject CanonicalEnvelope,
|
|
string? ProvidedPreviousHash,
|
|
string? EvidenceBundleReference = null);
|
|
|
|
public sealed record LedgerEventRecord(
|
|
string TenantId,
|
|
Guid ChainId,
|
|
long SequenceNumber,
|
|
Guid EventId,
|
|
string EventType,
|
|
string PolicyVersion,
|
|
string FindingId,
|
|
string ArtifactId,
|
|
Guid? SourceRunId,
|
|
string ActorId,
|
|
string ActorType,
|
|
DateTimeOffset OccurredAt,
|
|
DateTimeOffset RecordedAt,
|
|
JsonObject EventBody,
|
|
string EventHash,
|
|
string PreviousHash,
|
|
string MerkleLeafHash,
|
|
string CanonicalJson,
|
|
string? EvidenceBundleReference = null);
|
|
|
|
public sealed record LedgerChainHead(
|
|
long SequenceNumber,
|
|
string EventHash,
|
|
DateTimeOffset RecordedAt);
|
|
|
|
public enum LedgerWriteStatus
|
|
{
|
|
Success,
|
|
Idempotent,
|
|
ValidationFailed,
|
|
Conflict
|
|
}
|
|
|
|
public sealed record LedgerWriteResult(
|
|
LedgerWriteStatus Status,
|
|
LedgerEventRecord? Record,
|
|
IReadOnlyList<string> Errors,
|
|
LedgerEventRecord? ExistingRecord,
|
|
string? ConflictCode)
|
|
{
|
|
public static LedgerWriteResult ValidationFailed(params string[] errors)
|
|
=> new(LedgerWriteStatus.ValidationFailed, null, errors, null, null);
|
|
|
|
public static LedgerWriteResult Conflict(string code, params string[] errors)
|
|
=> new(LedgerWriteStatus.Conflict, null, errors, null, code);
|
|
|
|
public static LedgerWriteResult Idempotent(LedgerEventRecord record)
|
|
=> new(LedgerWriteStatus.Idempotent, record, Array.Empty<string>(), record, null);
|
|
|
|
public static LedgerWriteResult Success(LedgerEventRecord record)
|
|
=> new(LedgerWriteStatus.Success, record, Array.Empty<string>(), null, null);
|
|
}
|
|
|
|
public sealed class LedgerDuplicateEventException : Exception
|
|
{
|
|
public LedgerDuplicateEventException(Guid eventId, Exception innerException)
|
|
: base($"Ledger event {eventId} already exists.", innerException)
|
|
{
|
|
EventId = eventId;
|
|
}
|
|
|
|
public Guid EventId { get; }
|
|
}
|