// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../../../persistence.dart';

/// Adapter-neutral repository failure.
sealed class RepositoryFailure {
  /// Creates a `RepositoryFailure` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  const RepositoryFailure({
    this.entityId,
    this.expectedRevision,
    this.actualRevision,
    this.message,
  });

  /// Stable id of the entity related to the failure, when available.
  final String? entityId;

  /// Revision the caller expected for a compare-and-set operation.
  final core.Revision? expectedRevision;

  /// Revision currently stored by the adapter.
  final core.Revision? actualRevision;

  /// Optional non-localized diagnostic text for logs and tests.
  final String? message;
}
