$schema: http://json-schema.org/draft-07/schema#
title: EvidencIA API Contract
definitions:
  TranscriptSegment:
    additionalProperties: false
    properties:
      text:
        maxLength: 100000
        minLength: 1
        title: Text
        type: string
      start:
        minimum: 0
        title: Start
        type: number
      duration:
        minimum: 0
        title: Duration
        type: number
    required:
    - text
    - start
    - duration
    title: TranscriptSegment
    type: object
  AnalyzeRequest:
    additionalProperties: false
    properties:
      videoId:
        description: Identificador do vídeo no YouTube
        maxLength: 128
        minLength: 1
        title: Videoid
        type: string
      videoTitle:
        description: Título do vídeo
        maxLength: 500
        minLength: 1
        title: Videotitle
        type: string
      channelName:
        description: Nome do canal do YouTube
        maxLength: 500
        minLength: 1
        title: Channelname
        type: string
      uploadDate:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Data de publicação no formato ISO 8601
        title: Uploaddate
      durationSeconds:
        anyOf:
        - minimum: 0
          type: integer
        - type: 'null'
        default: null
        description: Duração do vídeo em segundos
        title: Durationseconds
      transcript:
        description: Texto higienizado da transcrição
        maxLength: 100000
        minLength: 50
        title: Transcript
        type: string
      language:
        anyOf:
        - maxLength: 20
          type: string
        - type: 'null'
        default: pt-BR
        description: Código do idioma
        title: Language
      segments:
        items:
          $ref: '#/definitions/TranscriptSegment'
        maxItems: 5000
        title: Segments
        type: array
      analysisMode:
        default: evidence_first
        enum:
        - evidence_first
        - evidence_only
        title: Analysismode
        type: string
    required:
    - videoId
    - videoTitle
    - channelName
    - transcript
    title: AnalyzeRequest
    type: object
  Claim:
    additionalProperties: false
    properties:
      id:
        description: Identificador único da alegação
        title: Id
        type: string
      text:
        description: Texto da alegação extraída
        minLength: 1
        title: Text
        type: string
      transcriptSnippet:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Trecho textual da transcrição onde a alegação ocorre
        title: Transcriptsnippet
      timestampStart:
        anyOf:
        - minimum: 0
          type: number
        - type: 'null'
        default: null
        description: Segundo de início no vídeo
        title: Timestampstart
      timestampEnd:
        anyOf:
        - minimum: 0
          type: number
        - type: 'null'
        default: null
        description: Segundo de término no vídeo
        title: Timestampend
      temporalContext:
        $ref: '#/definitions/TemporalContext'
        description: Contexto temporal da alegação
      evidence:
        description: Evidências relacionadas
        items:
          $ref: '#/definitions/Evidence'
        title: Evidence
        type: array
      uncertainty:
        description: Estado de certeza analítica
        enum:
        - supported
        - contradicted
        - contextualized
        - conflicting
        - insufficient_evidence
        title: Uncertainty
        type: string
      reflectionQuestions:
        anyOf:
        - items:
            type: string
          type: array
        - type: 'null'
        description: Perguntas orientadoras neutras
        title: Reflectionquestions
    required:
    - id
    - text
    - temporalContext
    - uncertainty
    title: Claim
    type: object
  Evidence:
    additionalProperties: false
    properties:
      sourceId:
        description: Identificador único da evidência
        title: Sourceid
        type: string
      relation:
        description: Relação factual com a alegação
        enum:
        - supports
        - contradicts
        - contextualizes
        title: Relation
        type: string
      title:
        description: Título da checagem ou estudo
        title: Title
        type: string
      url:
        description: Hiperligação completa com protocolo seguro
        title: Url
        type: string
      publishedAt:
        description: Data de publicação original
        title: Publishedat
        type: string
      publisher:
        description: Instituição ou agência publicadora
        title: Publisher
        type: string
      snippet:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Trecho textual relevante da checagem
        title: Snippet
      matchReason:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Explicação objetiva de por que a fonte foi recuperada
        title: Matchreason
      provenance:
        $ref: '#/definitions/EvidenceProvenance'
        description: Metadados de auditoria e proveniência
    required:
    - sourceId
    - relation
    - title
    - url
    - publishedAt
    - publisher
    - provenance
    title: Evidence
    type: object
  EvidenceProvenance:
    additionalProperties: false
    properties:
      dataset:
        description: 'Nome do dataset de proveniência (ex.: factchecks-br)'
        title: Dataset
        type: string
      indexedAt:
        description: Data/hora de indexação da evidência
        title: Indexedat
        type: string
      contentHash:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Hash de integridade da evidência
        title: Contenthash
    required:
    - dataset
    - indexedAt
    title: EvidenceProvenance
    type: object
  TemporalContext:
    additionalProperties: false
    properties:
      claimDate:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Data estimada da alegação
        title: Claimdate
      videoPublishedAt:
        description: Data de publicação original do vídeo
        title: Videopublishedat
        type: string
      note:
        anyOf:
        - type: string
        - type: 'null'
        default: null
        description: Orientação de contexto temporal
        title: Note
    required:
    - videoPublishedAt
    title: TemporalContext
    type: object
  AnalyzeResponse:
    additionalProperties: false
    properties:
      videoId:
        title: Videoid
        type: string
      analysisMode:
        enum:
        - evidence_first
        - evidence_only
        title: Analysismode
        type: string
      videoTitle:
        title: Videotitle
        type: string
      channelName:
        title: Channelname
        type: string
      publishedAt:
        title: Publishedat
        type: string
      processingTimeMs:
        title: Processingtimems
        type: integer
      claims:
        items:
          $ref: '#/definitions/Claim'
        title: Claims
        type: array
      limitations:
        description: Ressalvas metodológicas e limitações
        items:
          type: string
        title: Limitations
        type: array
    required:
    - videoId
    - analysisMode
    - videoTitle
    - channelName
    - publishedAt
    - processingTimeMs
    - claims
    title: AnalyzeResponse
    type: object
  AuthTokenRequest:
    additionalProperties: false
    properties:
      installationId:
        description: Identificador único anônimo da instalação da extensão
        maxLength: 128
        minLength: 8
        pattern: ^[A-Za-z0-9_-]+$
        title: Installationid
        type: string
      clientVersion:
        anyOf:
        - type: string
        - type: 'null'
        default: 1.0.0
        description: Versão do cliente da extensão
        title: Clientversion
    required:
    - installationId
    title: AuthTokenRequest
    type: object
  AuthTokenResponse:
    additionalProperties: false
    properties:
      token:
        description: Token de acesso efêmero (JWT/HMAC)
        title: Token
        type: string
      tokenType:
        default: Bearer
        description: Tipo do token de autenticação
        title: Tokentype
        type: string
      expiresIn:
        default: 86400
        description: Tempo de vida útil em segundos (24 horas)
        title: Expiresin
        type: integer
    required:
    - token
    title: AuthTokenResponse
    type: object
  ClassifyRequest:
    additionalProperties: false
    properties:
      text:
        description: Texto ou proposição a ser classificada
        maxLength: 10000
        minLength: 3
        title: Text
        type: string
      threshold:
        anyOf:
        - maximum: 1.0
          minimum: 0.0
          type: number
        - type: 'null'
        default: null
        description: 'Limiar de aceitação (default: 0.65)'
        title: Threshold
    required:
    - text
    title: ClassifyRequest
    type: object
  ClassifyResponse:
    additionalProperties: false
    properties:
      label:
        description: fake, true ou unverified
        title: Label
        type: string
      dominant_label:
        description: fake ou true
        title: Dominant Label
        type: string
      verdict_pt:
        description: Descrição da classe linguística, não prova factual
        title: Verdict Pt
        type: string
      confidence:
        description: Score normalizado não calibrado empiricamente [0.5, 1.0]
        title: Confidence
        type: number
      accepted:
        description: Se a confiança superou o limiar de aceitação
        title: Accepted
        type: boolean
      threshold:
        description: Limiar adotado
        title: Threshold
        type: number
      probabilities:
        additionalProperties:
          type: number
        description: P(fake) e P(true)
        title: Probabilities
        type: object
      top_features:
        description: Features mais discriminativas
        items:
          items: {}
          type: array
        title: Top Features
        type: array
      heuristic_reasons:
        description: Gatilhos linguísticos identificados
        items:
          type: string
        title: Heuristic Reasons
        type: array
      epistemic_tone:
        default: neutral
        description: Tom epistêmico da alegação
        title: Epistemic Tone
        type: string
    required:
    - label
    - dominant_label
    - verdict_pt
    - confidence
    - accepted
    - threshold
    - probabilities
    title: ClassifyResponse
    type: object
  FeedbackRequest:
    additionalProperties: false
    properties:
      videoId:
        description: Identificador do vídeo avaliado
        maxLength: 128
        minLength: 1
        title: Videoid
        type: string
      rating:
        description: Classificação de relevância e utilidade da análise
        enum:
        - positive
        - negative
        title: Rating
        type: string
      reason:
        anyOf:
        - enum:
          - outdated_sources
          - insufficient_evidence
          - inaccurate
          - other
          type: string
        - type: 'null'
        default: null
        description: Motivo opcional da classificação
        title: Reason
    required:
    - videoId
    - rating
    title: FeedbackRequest
    type: object
  FeedbackResponse:
    additionalProperties: false
    properties:
      status:
        const: received
        default: received
        title: Status
        type: string
      message:
        default: Feedback anônimo registrado com sucesso.
        title: Message
        type: string
    title: FeedbackResponse
    type: object
  HealthResponse:
    additionalProperties: false
    properties:
      status:
        enum:
        - healthy
        - degraded
        - unhealthy
        title: Status
        type: string
      version:
        title: Version
        type: string
      services:
        additionalProperties:
          type: string
        title: Services
        type: object
      timestamp:
        title: Timestamp
        type: string
    required:
    - status
    - version
    - services
    - timestamp
    title: HealthResponse
    type: object
  LivenessResponse:
    additionalProperties: false
    properties:
      status:
        const: alive
        default: alive
        title: Status
        type: string
      timestamp:
        title: Timestamp
        type: string
    required:
    - timestamp
    title: LivenessResponse
    type: object
  ReadinessResponse:
    additionalProperties: false
    properties:
      status:
        enum:
        - ready
        - not_ready
        title: Status
        type: string
      components:
        additionalProperties:
          type: string
        title: Components
        type: object
      timestamp:
        title: Timestamp
        type: string
    required:
    - status
    - components
    - timestamp
    title: ReadinessResponse
    type: object
