openapi: 3.1.0
info:
  title: Baseline Compare Evidence Gap Details Contract
  version: 0.1.0
  summary: Internal reference schema for the shared operator-safe evidence-gap read model.
  description: |
    This artifact defines the stable read shape for baseline compare evidence-gap detail.
    It is designed for canonical Monitoring run detail and tenant baseline compare review surfaces.
    In this feature slice it is a reference schema for the shared page read model, not a commitment to add new HTTP endpoints.
servers:
  - url: https://tenantpilot.local
paths: {}
components:
  schemas:
    OperationRunReference:
      type: object
      required:
        - id
        - type
        - status
        - outcome
      properties:
        id:
          type: integer
          minimum: 1
        type:
          type: string
          enum:
            - baseline_compare
        status:
          type: string
        outcome:
          type: string
        tenant_id:
          type: integer
          nullable: true
        workspace_id:
          type: integer
          nullable: true
    EvidenceGapBucket:
      type: object
      required:
        - reason_code
        - reason_label
        - count
        - rows
      properties:
        reason_code:
          type: string
        reason_label:
          type: string
        count:
          type: integer
          minimum: 0
        rows:
          type: array
          items:
            $ref: '#/components/schemas/EvidenceGapRow'
    EvidenceGapRow:
      type: object
      required:
        - reason_code
        - policy_type
        - subject_key
      properties:
        reason_code:
          type: string
        policy_type:
          type: string
        subject_key:
          type: string
    EvidenceGapSummary:
      type: object
      required:
        - count
        - by_reason
        - detail_state
      properties:
        count:
          type: integer
          minimum: 0
        by_reason:
          type: object
          additionalProperties:
            type: integer
            minimum: 0
        detail_state:
          type: string
          enum:
            - no_gaps
            - details_recorded
            - details_not_recorded
    EvidenceGapDetailResponse:
      type: object
      required:
        - summary
        - buckets
      properties:
        summary:
          $ref: '#/components/schemas/EvidenceGapSummary'
        buckets:
          type: array
          items:
            $ref: '#/components/schemas/EvidenceGapBucket'
        filters:
          type: object
          additionalProperties:
            type: string