{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sediment.so/schemas/facts/pull-request-merge/v3.json",
  "title": "PullRequestMerge",
  "description": "One pull request merge boundary.",
  "type": "object",
  "properties": {
    "schema_version": {
      "enum": [
        1,
        2
      ],
      "type": "integer",
      "description": "The positive integer version of the canonical row schema."
    },
    "repository_provider": {
      "anyOf": [
        {
          "const": "github",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Captured forge provider."
    },
    "repository_host": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
        },
        {
          "type": "null"
        }
      ],
      "description": "Configured lowercase forge host."
    },
    "repository_id": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
        },
        {
          "type": "null"
        }
      ],
      "description": "Immutable provider repository ID within its forge host."
    },
    "merge_id": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "Stable id for this pull request merge boundary."
    },
    "org_id": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The deployment's tenant id, normalized. Bound to the server."
    },
    "provider": {
      "const": "github",
      "type": "string",
      "description": "Which system this fact came from."
    },
    "repo": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "`owner/repo`, lowercased. Empty string when the sender omitted it."
    },
    "pr_number": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9223372036854775807,
      "description": "The positive pull request number within the repository."
    },
    "head_repo": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The repository that supplied the pull request head."
    },
    "head_repository_provider": {
      "anyOf": [
        {
          "const": "github",
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Captured head repository provider, independent of the target identity."
    },
    "head_repository_host": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
        },
        {
          "type": "null"
        }
      ],
      "description": "Captured head repository host, independent of the target identity."
    },
    "head_repository_id": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
        },
        {
          "type": "null"
        }
      ],
      "description": "Captured immutable head repository ID, independent of the target identity."
    },
    "head_ref": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The normalized final pull request head branch."
    },
    "head_sha": {
      "type": "string",
      "description": "The final pull request head commit."
    },
    "base_ref": {
      "type": "string",
      "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$",
      "description": "The normalized target branch at merge time."
    },
    "base_sha": {
      "type": "string",
      "description": "The target branch commit recorded by the merge event."
    },
    "merge_commit_sha": {
      "type": "string",
      "description": "The provider-reported merged commit boundary."
    },
    "merged_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the forge recorded the pull request merge."
    },
    "source_event_id": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[^\\u0000\\uD800-\\uDFFF]*$"
        },
        {
          "type": "null"
        }
      ],
      "description": "The provider delivery identity when supplied."
    },
    "captured_at": {
      "type": "string",
      "format": "date-time",
      "description": "When Sediment stored the fact, stamped server-side. Windows and ordering anchor on this, never on a client clock."
    }
  },
  "additionalProperties": false,
  "required": [
    "schema_version",
    "repository_provider",
    "repository_host",
    "repository_id",
    "merge_id",
    "org_id",
    "provider",
    "repo",
    "pr_number",
    "head_repo",
    "head_repository_provider",
    "head_repository_host",
    "head_repository_id",
    "head_ref",
    "head_sha",
    "base_ref",
    "base_sha",
    "merge_commit_sha",
    "merged_at",
    "source_event_id",
    "captured_at"
  ]
}
