69 lines
1.7 KiB
C#
69 lines
1.7 KiB
C#
// <copyright file="ConflictResolution.cs" company="StellaOps">
|
|
// Copyright (c) StellaOps. Licensed under AGPL-3.0-or-later.
|
|
// </copyright>
|
|
|
|
namespace StellaOps.AirGap.Sync.Models;
|
|
|
|
/// <summary>
|
|
/// Result of conflict resolution for a job ID.
|
|
/// </summary>
|
|
public sealed record ConflictResolution
|
|
{
|
|
/// <summary>
|
|
/// Gets the type of conflict detected.
|
|
/// </summary>
|
|
public required ConflictType Type { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the resolution strategy applied.
|
|
/// </summary>
|
|
public required ResolutionStrategy Resolution { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the selected entry (when resolution is not Error).
|
|
/// </summary>
|
|
public OfflineJobLogEntry? SelectedEntry { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the entries that were dropped.
|
|
/// </summary>
|
|
public IReadOnlyList<OfflineJobLogEntry>? DroppedEntries { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the error message (when resolution is Error).
|
|
/// </summary>
|
|
public string? Error { get; init; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Types of conflicts that can occur during merge.
|
|
/// </summary>
|
|
public enum ConflictType
|
|
{
|
|
/// <summary>
|
|
/// Same JobId with different HLC timestamps but identical payload.
|
|
/// </summary>
|
|
DuplicateTimestamp,
|
|
|
|
/// <summary>
|
|
/// Same JobId with different payloads - indicates a bug.
|
|
/// </summary>
|
|
PayloadMismatch
|
|
}
|
|
|
|
/// <summary>
|
|
/// Strategies for resolving conflicts.
|
|
/// </summary>
|
|
public enum ResolutionStrategy
|
|
{
|
|
/// <summary>
|
|
/// Take the entry with the earliest HLC timestamp.
|
|
/// </summary>
|
|
TakeEarliest,
|
|
|
|
/// <summary>
|
|
/// Fail the merge - conflict cannot be resolved.
|
|
/// </summary>
|
|
Error
|
|
}
|