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

part of '../../repositories.dart';

/// Typed repository failure for optimistic writes and uniqueness checks.
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({
    required this.code,
    this.entityId,
    this.expectedRevision,
    this.actualRevision,
  });

  /// Stores the `code` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final RepositoryFailureCode code;

  /// Stores the `entityId` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final String? entityId;

  /// Stores the `expectedRevision` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final int? expectedRevision;

  /// Stores the `actualRevision` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final int? actualRevision;
}
