{
  "type": "object",
  "properties": {
    "profile": {
      "const": "autonomous_build_result_v1"
    },
    "contract_sha256": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "source_commit": {
      "type": "string",
      "pattern": "^[a-f0-9]{40}$"
    },
    "status": {
      "enum": [
        "software_complete",
        "incomplete"
      ]
    },
    "requirement_results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "requirement_id": {
            "type": "string",
            "minLength": 1
          },
          "status": {
            "enum": [
              "passed",
              "failed",
              "not_run"
            ]
          },
          "scenario_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1
          }
        },
        "required": [
          "requirement_id",
          "status",
          "scenario_ids"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "command_results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "command_id": {
            "type": "string",
            "minLength": 1
          },
          "exit_code": {
            "type": "integer",
            "minimum": 0
          },
          "skipped": {
            "type": "boolean"
          },
          "artifact_paths": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "minItems": 1
          },
          "artifact_hashes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "minLength": 1
                },
                "sha256": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              },
              "required": [
                "path",
                "sha256"
              ],
              "additionalProperties": false
            },
            "minItems": 1
          }
        },
        "required": [
          "command_id",
          "exit_code",
          "skipped",
          "artifact_paths",
          "artifact_hashes"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "scenario_results": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "scenario_id": {
            "type": "string",
            "minLength": 1
          },
          "capture_path": {
            "type": "string",
            "minLength": 1
          },
          "capture_sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "provenance": {
            "type": "object",
            "properties": {
              "source_commit": {
                "type": "string",
                "minLength": 1
              },
              "run_id": {
                "type": "string",
                "minLength": 1
              },
              "adapter": {
                "type": "string",
                "minLength": 1
              },
              "captured_at": {
                "type": "string",
                "format": "date-time"
              }
            },
            "required": [
              "source_commit",
              "run_id",
              "adapter",
              "captured_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "scenario_id",
          "capture_path",
          "capture_sha256",
          "provenance"
        ],
        "additionalProperties": false
      },
      "minItems": 1
    },
    "unresolved_build_blockers": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0
    },
    "external_live_blockers": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "minItems": 0
    }
  },
  "required": [
    "profile",
    "contract_sha256",
    "source_commit",
    "status",
    "requirement_results",
    "command_results",
    "scenario_results",
    "unresolved_build_blockers",
    "external_live_blockers"
  ],
  "additionalProperties": false,
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
