{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hw-apex-bench.invalid/schemas/axis4-evidence-v3.schema.json",
  "title": "Axis 4 frozen inputs and response hash evidence",
  "oneOf": [
    {
      "$ref": "#/$defs/prepared"
    },
    {
      "$ref": "#/$defs/evidence"
    }
  ],
  "$defs": {
    "file": {
      "type": "object",
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "required": [
        "path",
        "bytes",
        "sha256"
      ],
      "additionalProperties": false
    },
    "canonical": {
      "type": "object",
      "properties": {
        "assembly_id": {
          "type": "string",
          "minLength": 1
        },
        "contig_id": {
          "type": "string",
          "minLength": 1
        },
        "start0": {
          "type": "integer",
          "minimum": 0
        },
        "end0": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "assembly_id",
        "contig_id",
        "start0",
        "end0"
      ],
      "additionalProperties": false
    },
    "query": {
      "type": "object",
      "properties": {
        "assembly_id": {
          "type": "string",
          "minLength": 1
        },
        "contig_id": {
          "type": "string",
          "minLength": 1
        },
        "start0": {
          "type": "integer",
          "minimum": 0
        },
        "end0": {
          "type": "integer",
          "minimum": 1
        },
        "sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      },
      "required": [
        "assembly_id",
        "contig_id",
        "start0",
        "end0",
        "sha256"
      ],
      "additionalProperties": false
    },
    "row": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "minimum": 0
        },
        "group_id": {
          "type": "integer",
          "minimum": 0
        },
        "assembly": {
          "type": "string",
          "minLength": 1
        },
        "canonical": {
          "$ref": "#/$defs/canonical"
        },
        "translated": {
          "type": "object",
          "minProperties": 1
        },
        "length": {
          "type": "integer",
          "minimum": 0
        },
        "observed_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "status": {
          "enum": [
            "PASS",
            "FAILED"
          ]
        },
        "response_file": {
          "anyOf": [
            {
              "$ref": "#/$defs/file"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "group_id",
        "assembly",
        "canonical",
        "translated",
        "length",
        "observed_sha256",
        "status",
        "response_file"
      ],
      "additionalProperties": false
    },
    "prepared": {
      "type": "object",
      "properties": {
        "schema": {
          "const": "axis4-prepared-v1"
        },
        "evidence_kind": {
          "enum": [
            "official",
            "synthetic"
          ]
        },
        "domain": {
          "const": "uppercase-sequence-without-FASTA-framing"
        },
        "coordinate_convention": {
          "const": "0-based-half-open"
        },
        "protocol_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "sample_seed": {
          "type": "integer",
          "minimum": 0,
          "maximum": 18446744073709551615
        },
        "sample_algorithm": {
          "const": "python.random.Random/MT19937/sample"
        },
        "sample_limit": {
          "const": 32
        },
        "assemblies": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "assembly_id": {
                "type": "string",
                "minLength": 1
              },
              "fasta": {
                "$ref": "#/$defs/file"
              },
              "source_url": {
                "type": "string",
                "minLength": 1
              },
              "source_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              },
              "contigs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "contig_id": {
                      "type": "string",
                      "minLength": 1
                    },
                    "length": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "contig_id",
                    "length"
                  ],
                  "additionalProperties": false
                },
                "minItems": 1
              },
              "canonical_bytes": {
                "type": "integer",
                "minimum": 0
              },
              "canonical_sha256": {
                "type": "string",
                "pattern": "^[0-9a-f]{64}$"
              }
            },
            "required": [
              "assembly_id",
              "fasta",
              "source_url",
              "contigs",
              "canonical_bytes",
              "canonical_sha256"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        },
        "groups": {
          "type": "array",
          "items": {
            "type": "object",
            "minProperties": 1,
            "additionalProperties": {
              "$ref": "#/$defs/query"
            }
          },
          "minItems": 1
        },
        "input_files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/file"
          },
          "minItems": 1
        }
      },
      "required": [
        "schema",
        "evidence_kind",
        "domain",
        "coordinate_convention",
        "protocol_sha256",
        "sample_seed",
        "sample_algorithm",
        "sample_limit",
        "assemblies",
        "groups",
        "input_files"
      ],
      "additionalProperties": false
    },
    "evidence": {
      "type": "object",
      "properties": {
        "schema": {
          "const": "axis4-evidence-v3"
        },
        "axis": {
          "const": 4
        },
        "status": {
          "enum": [
            "PASS",
            "FAILED",
            "BLOCKED"
          ]
        },
        "error": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence_kind": {
          "enum": [
            "official",
            "synthetic"
          ]
        },
        "performance_valid": {
          "type": "boolean"
        },
        "domain": {
          "const": "uppercase-sequence-without-FASTA-framing"
        },
        "timing_boundary": {
          "const": "complete group: native fetch, uppercase normalization, SHA-256 judgement and translation; response file writes outside timer"
        },
        "scope": {
          "const": "cpu-in-process"
        },
        "decoder_threads": {
          "const": 1
        },
        "command": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "prepared": {
          "$ref": "#/$defs/file"
        },
        "plan": {
          "$ref": "#/$defs/file"
        },
        "input_files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/file"
          },
          "minItems": 1
        },
        "storage_files": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/file"
          },
          "minItems": 1
        },
        "stored_bytes": {
          "type": "integer",
          "minimum": 0
        },
        "sample_seed": {
          "type": "integer",
          "minimum": 0
        },
        "sample_ids": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": 0
          },
          "minItems": 0,
          "maxItems": 32,
          "uniqueItems": true
        },
        "silence_before": {
          "anyOf": [
            {
              "$ref": "#/$defs/file"
            },
            {
              "type": "null"
            }
          ]
        },
        "silence_after": {
          "anyOf": [
            {
              "$ref": "#/$defs/file"
            },
            {
              "type": "null"
            }
          ]
        },
        "rows": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/row"
          },
          "minItems": 0
        },
        "group_times": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "group_id": {
                "type": "integer",
                "minimum": 0
              },
              "elapsed_ns": {
                "type": "integer",
                "minimum": 1
              }
            },
            "required": [
              "group_id",
              "elapsed_ns"
            ],
            "additionalProperties": false
          },
          "minItems": 0
        },
        "seconds": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "type": "null"
            }
          ]
        },
        "verified": {
          "type": "integer",
          "minimum": 0
        },
        "reader_build": {
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            }
          ]
        },
        "implementation": {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "admission": {
          "type": "object",
          "properties": {
            "order": {
              "enum": [
                [
                  "inputs-checked",
                  "reader-opened",
                  "quiet-wait",
                  "gate-before",
                  "timed-groups",
                  "gate-after",
                  "reader-closed"
                ],
                [
                  "inputs-checked",
                  "reader-opened",
                  "quiet-wait",
                  "gate-before",
                  "timed-groups",
                  "gate-after",
                  "sample-files-written",
                  "reader-closed"
                ]
              ]
            },
            "input_check_ns": {
              "type": "integer",
              "minimum": 0
            },
            "open_ns": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0
                },
                {
                  "type": "null"
                }
              ]
            },
            "quiet_wait": {
              "type": "object",
              "properties": {
                "bound_seconds": {
                  "type": "number",
                  "minimum": 0
                },
                "poll_seconds": {
                  "type": "number",
                  "minimum": 0
                },
                "waited_ns": {
                  "type": "integer",
                  "minimum": 0
                },
                "refused": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "load1": {
                        "type": "number"
                      },
                      "reasons": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1
                        },
                        "minItems": 1
                      }
                    },
                    "required": [
                      "load1",
                      "reasons"
                    ],
                    "additionalProperties": false
                  }
                },
                "blocked": {
                  "type": "boolean"
                }
              },
              "required": [
                "bound_seconds",
                "poll_seconds",
                "waited_ns",
                "refused"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "order",
            "input_check_ns",
            "open_ns",
            "quiet_wait"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "schema",
        "axis",
        "status",
        "error",
        "evidence_kind",
        "performance_valid",
        "domain",
        "timing_boundary",
        "scope",
        "decoder_threads",
        "command",
        "prepared",
        "plan",
        "input_files",
        "storage_files",
        "stored_bytes",
        "sample_seed",
        "sample_ids",
        "silence_before",
        "silence_after",
        "rows",
        "group_times",
        "seconds",
        "verified",
        "reader_build",
        "implementation"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "PASS"
              }
            }
          },
          "then": {
            "properties": {
              "error": {
                "type": "null"
              },
              "seconds": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "silence_before": {
                "$ref": "#/$defs/file"
              },
              "silence_after": {
                "$ref": "#/$defs/file"
              },
              "reader_build": {
                "type": "object"
              },
              "rows": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/row"
                },
                "minItems": 1
              },
              "group_times": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "group_id": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "elapsed_ns": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "group_id",
                    "elapsed_ns"
                  ],
                  "additionalProperties": false
                },
                "minItems": 1
              }
            }
          },
          "else": {
            "properties": {
              "seconds": {
                "type": "null"
              },
              "performance_valid": {
                "const": false
              },
              "error": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "evidence_kind": {
                "const": "synthetic"
              }
            }
          },
          "then": {
            "properties": {
              "performance_valid": {
                "const": false
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "evidence_kind": {
                "const": "official"
              },
              "status": {
                "const": "PASS"
              }
            }
          },
          "then": {
            "properties": {
              "performance_valid": {
                "const": true
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "status": {
                "const": "BLOCKED"
              }
            }
          },
          "then": {
            "required": [
              "admission"
            ],
            "properties": {
              "seconds": {
                "type": "null"
              },
              "performance_valid": {
                "const": false
              }
            }
          }
        }
      ]
    }
  }
}
