/** Error codes — event is rejected (status = failed). */
export enum ReadingEventErrorCode {
  /** readingTargetType=knowledge_source but KnowledgeSource not found */
  MATERIAL_NOT_FOUND = 'MATERIAL_NOT_FOUND',
  /** readingTargetType=temporary_file but TemporaryReadingMaterial not found */
  TEMPORARY_MATERIAL_NOT_FOUND = 'TEMPORARY_MATERIAL_NOT_FOUND',
  /** Material exists but does not belong to userId */
  MATERIAL_ACCESS_DENIED = 'MATERIAL_ACCESS_DENIED',
  /** TemporaryReadingMaterial has expired */
  TEMPORARY_MATERIAL_EXPIRED = 'TEMPORARY_MATERIAL_EXPIRED',
  /** readingTargetType is not 'knowledge_source' or 'temporary_file' */
  INVALID_TARGET_TYPE = 'INVALID_TARGET_TYPE',
  /** eventType is not one of the 5 valid types */
  INVALID_EVENT_TYPE = 'INVALID_EVENT_TYPE',
  /** clientTimestampMs is malformed or absent */
  INVALID_TIMESTAMP = 'INVALID_TIMESTAMP',
  /** position JSON is malformed */
  INVALID_POSITION = 'INVALID_POSITION',
  /** activeSecondsDelta < 0 */
  INVALID_ACTIVE_SECONDS = 'INVALID_ACTIVE_SECONDS',
  /** Batch size exceeds limit (default 100) */
  BATCH_LIMIT_EXCEEDED = 'BATCH_LIMIT_EXCEEDED',
  /** clientSessionId missing */
  MISSING_CLIENT_SESSION = 'MISSING_CLIENT_SESSION',
  /** materialId missing */
  MISSING_MATERIAL_ID = 'MISSING_MATERIAL_ID',
}

/** Warning codes — event is accepted but flagged. */
export enum ReadingEventWarningCode {
  /** activeSecondsDelta > 300, truncated to 300 */
  ACTIVE_SECONDS_CAPPED = 'ACTIVE_SECONDS_CAPPED',
  /** Timestamp skewed vs server time > 5 min */
  CLIENT_TIMESTAMP_SKEWED = 'CLIENT_TIMESTAMP_SKEWED',
  /** Position present but invalid for the event type (e.g. MaterialClosed without position — position is ignored, not rejected) */
  POSITION_IGNORED = 'POSITION_IGNORED',
  /** eventId already processed (idempotent replay) */
  DUPLICATE_EVENT = 'DUPLICATE_EVENT',
  /** Sequence out of order within session (non-fatal) */
  OUT_OF_ORDER_EVENT = 'OUT_OF_ORDER_EVENT',
  /** The source material has been deleted */
  SOURCE_DELETED = 'SOURCE_DELETED',
}
