{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://paulkov.github.io/dpone/schemas/gitops/airflow-xcom-summary.schema.json",
  "title": "dpone GitOps Airflow XCom summary contract",
  "type": "object",
  "required": [
    "kind",
    "schema_version",
    "producer",
    "status",
    "run_spec_path",
    "runtime_evidence_path"
  ],
  "properties": {
    "kind": {
      "const": "gitops.airflow_xcom_summary"
    },
    "schema_version": {
      "type": "string"
    },
    "producer": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "runtime_profile_path": {
      "type": "string"
    },
    "run_spec_path": {
      "type": "string"
    },
    "runtime_evidence_path": {
      "type": "string"
    },
    "runtime_evidence_sha256": {
      "type": "string"
    },
    "runtime_evidence": {
      "type": "object",
      "additionalProperties": true
    },
    "failed_step": {
      "type": [
        "string",
        "null"
      ]
    },
    "step_counts": {
      "type": "object",
      "additionalProperties": true
    },
    "artifact_paths": {
      "type": "object",
      "additionalProperties": true
    },
    "warnings": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/issue"
      }
    },
    "interval": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "interval_start": {
          "type": [
            "string",
            "null"
          ]
        },
        "interval_end": {
          "type": [
            "string",
            "null"
          ]
        },
        "logical_date": {
          "type": [
            "string",
            "null"
          ]
        },
        "dag_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "dag_run_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "try_number": {
          "type": [
            "string",
            "null"
          ]
        },
        "partition_key": {
          "type": [
            "string",
            "null"
          ]
        },
        "partition_dimension": {
          "type": [
            "string",
            "null"
          ]
        },
        "partition_mode": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "native",
            "degraded_unpartitioned",
            null
          ]
        }
      }
    },
    "backfill": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "run_key": {
          "type": "string"
        },
        "dataset": {
          "type": "string"
        },
        "inner_mode": {
          "type": "string"
        },
        "operation_status": {
          "type": "string"
        },
        "retry_policy": {
          "type": "string"
        },
        "state_path": {
          "type": "string"
        },
        "chunks_total": {
          "type": "integer"
        },
        "chunks_selected": {
          "type": "integer"
        },
        "chunks_committed": {
          "type": "integer"
        },
        "chunks_failed": {
          "type": "integer"
        },
        "chunks_skipped_resume": {
          "type": "integer"
        },
        "verification": {
          "type": "object",
          "additionalProperties": true
        },
        "mapping": {
          "type": "object",
          "required": [
            "mode",
            "backfill_plan_hash",
            "item_index",
            "first_chunk_index",
            "last_chunk_index",
            "chunks_count",
            "plan_fingerprint",
            "item_status"
          ],
          "additionalProperties": false,
          "properties": {
            "mode": {
              "enum": [
                "visible",
                "summary"
              ]
            },
            "backfill_plan_hash": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "item_index": {
              "type": "integer",
              "minimum": 0
            },
            "first_chunk_index": {
              "type": "integer",
              "minimum": 1
            },
            "last_chunk_index": {
              "type": "integer",
              "minimum": 1
            },
            "chunks_count": {
              "type": "integer",
              "minimum": 1
            },
            "plan_fingerprint": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            "item_status": {
              "enum": [
                "success",
                "error",
                "cancelled"
              ]
            }
          }
        }
      }
    },
    "blockers": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/issue"
      }
    },
    "run_identity": {
      "type": "object",
      "required": [
        "schema",
        "release_id",
        "deployment_id",
        "dag_spec",
        "workload_pack",
        "runtime_image_digest",
        "binding_set_ref",
        "connection_registry_ref",
        "credential_runtime_ref",
        "airflow_bundle"
      ],
      "additionalProperties": false,
      "properties": {
        "schema": {
          "const": "dpone.airflow-run-identity.v1"
        },
        "release_id": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "deployment_id": {
          "type": "string",
          "pattern": "^sha256:[0-9a-f]{64}$"
        },
        "dag_spec": {
          "anyOf": [
            {
              "type": "object",
              "required": [
                "id",
                "sha256"
              ],
              "additionalProperties": false,
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^sha256:[0-9a-f]{64}$"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "workload_pack": {
          "type": "object",
          "required": [
            "id",
            "sha256"
          ],
          "additionalProperties": false,
          "properties": {
            "id": {
              "type": "string",
              "minLength": 1
            },
            "sha256": {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            }
          }
        },
        "runtime_image_digest": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "binding_set_ref": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "connection_registry_ref": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "credential_runtime_ref": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^sha256:[0-9a-f]{64}$"
            },
            {
              "type": "null"
            }
          ]
        },
        "airflow_bundle": {
          "anyOf": [
            {
              "type": "object",
              "required": [
                "backend",
                "ref",
                "versioned",
                "version",
                "snapshot_ref"
              ],
              "additionalProperties": false,
              "properties": {
                "backend": {
                  "type": "string",
                  "minLength": 1
                },
                "ref": {
                  "type": "string",
                  "minLength": 1,
                  "pattern": "^\\S+$",
                  "not": {
                    "pattern": "(?:[?&](?:token|password|signature|credential|x-amz-signature|x-goog-signature)=|://[^/]*@)"
                  }
                },
                "versioned": {
                  "type": "boolean"
                },
                "version": {
                  "anyOf": [
                    {
                      "type": "string",
                      "minLength": 1
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "snapshot_ref": {
                  "anyOf": [
                    {
                      "type": "string",
                      "pattern": "^sha256:[0-9a-f]{64}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "allOf": [
                {
                  "if": {
                    "properties": {
                      "versioned": {
                        "const": true
                      }
                    }
                  },
                  "then": {
                    "properties": {
                      "version": {
                        "type": "string",
                        "minLength": 1
                      }
                    }
                  },
                  "else": {
                    "properties": {
                      "version": {
                        "type": "null"
                      }
                    }
                  }
                }
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  },
  "$defs": {
    "issue": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "code",
        "message",
        "path",
        "source"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "source": {
          "type": "string"
        }
      }
    }
  },
  "additionalProperties": true
}
