{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://w3id.org/materica/schema/0.1/record.reader.json",
  "$comment": "Generated by scripts/gen_reader_schema.py from record.writer.json. Edit the writer schema.",
  "title": "Record",
  "description": "A record as a reader checks it at step 3 of a read (record_format.md section 1 item 2): the envelope, and the body's structure as far as schema 0.1 knows it. Open: members and tokens it does not know pass, and it never applies the shape of a value field, a form or a section's specimen. Its $defs hold those shapes as step 8 checks them (read_side_contract.md section 3), opened alike, without the members a read does not check.",
  "type": "object",
  "required": [
    "schema_version",
    "record_type",
    "id",
    "version",
    "name",
    "licence",
    "content_hash",
    "body"
  ],
  "properties": {
    "schema_version": {
      "description": "MAJOR.MINOR.PATCH (record_format.md section 8).",
      "type": "string"
    },
    "record_type": {
      "description": "record_format.md section 3. An interface record's body is specified in a later minor version.",
      "type": "string"
    },
    "id": {
      "description": "<namespace>/<local id> (record_format.md section 7 item 2).",
      "type": "string",
      "pattern": "^[a-z0-9_]+/[A-Za-z0-9_.-]+(?![\\s\\S])"
    },
    "version": {
      "description": "MAJOR.MINOR.PATCH (record_format.md section 8).",
      "type": "string",
      "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?![\\s\\S])"
    },
    "name": {
      "type": "string"
    },
    "licence": {
      "description": "The licence of the values, an SPDX expression; quoted evidence is never covered by it (record_format.md section 2).",
      "type": "object",
      "required": [
        "values",
        "evidence"
      ],
      "properties": {
        "values": {
          "type": "string"
        },
        "evidence": {
          "type": "string"
        }
      }
    },
    "content_hash": {
      "description": "record_format.md section 9.",
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])"
    },
    "card": {
      "type": "string"
    },
    "body": {
      "type": "object"
    }
  },
  "allOf": [
    {
      "if": {
        "required": [
          "record_type"
        ],
        "properties": {
          "record_type": {
            "const": "material"
          }
        }
      },
      "then": {
        "properties": {
          "body": {
            "description": "record_format.md section 4.",
            "type": "object",
            "required": [
              "sections"
            ],
            "properties": {
              "sections": {
                "description": "The sections of schema 0.1, every one optional (record_format.md section 4.1).",
                "type": "object",
                "properties": {
                  "bulk": {
                    "description": "record_format.md section 4 item 2.",
                    "type": "object",
                    "required": [
                      "fields"
                    ],
                    "properties": {
                      "specimen": true,
                      "fields": {
                        "description": "A field's name to its value field.",
                        "type": "object"
                      }
                    }
                  },
                  "fluid": {
                    "description": "record_format.md section 4 item 2.",
                    "type": "object",
                    "required": [
                      "fields"
                    ],
                    "properties": {
                      "specimen": true,
                      "fields": {
                        "description": "A field's name to its value field.",
                        "type": "object"
                      }
                    }
                  },
                  "magnetic": {
                    "description": "record_format.md section 4 item 2.",
                    "type": "object",
                    "required": [
                      "fields"
                    ],
                    "properties": {
                      "specimen": true,
                      "fields": {
                        "description": "A field's name to its value field.",
                        "type": "object"
                      }
                    }
                  },
                  "biocompatibility": {
                    "description": "record_format.md section 4 item 2.",
                    "type": "object",
                    "required": [
                      "fields"
                    ],
                    "properties": {
                      "specimen": true,
                      "fields": {
                        "description": "A field's name to its value field.",
                        "type": "object"
                      }
                    }
                  }
                }
              },
              "extensions": {
                "description": "A registered namespace to its sections; a reader ignores what it holds (record_format.md section 4 item 4).",
                "type": "object"
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "record_type"
        ],
        "properties": {
          "record_type": {
            "const": "overlay"
          }
        }
      },
      "then": {
        "properties": {
          "body": {
            "description": "record_format.md section 4.4.",
            "type": "object",
            "required": [
              "purpose",
              "base",
              "scope",
              "replaces"
            ],
            "properties": {
              "purpose": {
                "type": "string"
              },
              "base": {
                "description": "The one material an overlay replaces fields of (record_format.md section 4.4 item 2).",
                "type": "object",
                "required": [
                  "id",
                  "version",
                  "content_hash"
                ],
                "properties": {
                  "id": {
                    "description": "<namespace>/<local id> (record_format.md section 7 item 2).",
                    "type": "string"
                  },
                  "version": {
                    "description": "MAJOR.MINOR.PATCH (record_format.md section 8).",
                    "type": "string"
                  },
                  "content_hash": {
                    "description": "record_format.md section 9.",
                    "type": "string"
                  }
                }
              },
              "scope": {
                "description": "record_format.md section 4.4 item 3.",
                "type": "object",
                "required": [
                  "consumer"
                ],
                "properties": {
                  "consumer": {
                    "type": "string"
                  },
                  "model": {
                    "description": "A consumer's model, by name and version; the version is the consumer's, not bound by record_format.md section 8.",
                    "type": "object",
                    "required": [
                      "name",
                      "version"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "version": {
                        "type": "string"
                      }
                    }
                  },
                  "model_configuration_hash": {
                    "type": "string"
                  },
                  "run": {
                    "type": "string"
                  }
                }
              },
              "replaces": {
                "description": "<section>.<field> to the whole value field that replaces the base's (record_format.md section 4.4 item 2).",
                "type": "object"
              }
            }
          }
        }
      }
    }
  ],
  "$defs": {
    "record_id": {
      "description": "<namespace>/<local id> (record_format.md section 7 item 2).",
      "type": "string"
    },
    "version": {
      "description": "MAJOR.MINOR.PATCH (record_format.md section 8).",
      "type": "string"
    },
    "content_hash": {
      "description": "record_format.md section 9.",
      "type": "string"
    },
    "value_field": {
      "description": "A value field of one form, or the alternatives of one (record_format.md section 5). A reader checks it only when it reads the field.",
      "oneOf": [
        {
          "$ref": "#/$defs/form_field"
        },
        {
          "$ref": "#/$defs/alternatives"
        }
      ]
    },
    "form_field": {
      "description": "A value field of one form; the form token decides which (record_format.md sections 5 and 6).",
      "oneOf": [
        {
          "$ref": "#/$defs/constant_field"
        },
        {
          "$ref": "#/$defs/table_field"
        },
        {
          "$ref": "#/$defs/power_law_field"
        },
        {
          "$ref": "#/$defs/interval_field"
        },
        {
          "$ref": "#/$defs/composition_field"
        },
        {
          "$ref": "#/$defs/parameter_set_field"
        },
        {
          "$ref": "#/$defs/reference_data_field"
        },
        {
          "$ref": "#/$defs/evidence_field"
        }
      ]
    },
    "alternatives": {
      "description": "Every alternative found, each complete, in stored order and none the default; nothing beside them (record_format.md section 5).",
      "type": "object",
      "required": [
        "alternatives"
      ],
      "properties": {
        "alternatives": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/form_field"
          }
        }
      },
      "not": {
        "anyOf": [
          {
            "required": [
              "form"
            ]
          },
          {
            "required": [
              "unit"
            ]
          },
          {
            "required": [
              "value"
            ]
          },
          {
            "required": [
              "table"
            ]
          },
          {
            "required": [
              "power_law"
            ]
          },
          {
            "required": [
              "interval"
            ]
          },
          {
            "required": [
              "composition"
            ]
          },
          {
            "required": [
              "parameter_set"
            ]
          },
          {
            "required": [
              "reference_data"
            ]
          },
          {
            "required": [
              "evidence"
            ]
          },
          {
            "required": [
              "conditions"
            ]
          },
          {
            "required": [
              "specimen"
            ]
          },
          {
            "required": [
              "statistics"
            ]
          },
          {
            "required": [
              "provenance"
            ]
          },
          {
            "required": [
              "label"
            ]
          },
          {
            "required": [
              "label_basis"
            ]
          },
          {
            "required": [
              "fit"
            ]
          }
        ]
      }
    },
    "field_members": {
      "description": "The members of a value field that do not depend on its form (record_format.md section 5), with the rules that join them to the form: a fit record where the origin is fitted or the extraction a fit (provenance.md section 3), a search where the statistics represent a spread across sources, and a recipe where the form's member is withheld (provenance.md sections 2 and 7).",
      "type": "object",
      "required": [
        "unit",
        "provenance"
      ],
      "properties": {
        "unit": {
          "$ref": "#/$defs/unit"
        },
        "specimen": {
          "$ref": "#/$defs/specimen"
        },
        "provenance": {
          "$ref": "#/$defs/provenance"
        },
        "label": {
          "type": "string"
        },
        "label_basis": true,
        "fit": true
      }
    },
    "constant_field": {
      "description": "A constant: one number, whose range is its conditions (record_format.md section 6).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "value",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "constant"
        },
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "table_field": {
      "description": "A table: values against a numeric condition, its axis, which the field's conditions hold as not_applicable (record_format.md section 6).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "table",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "table"
        },
        "table": {
          "anyOf": [
            {
              "$ref": "#/$defs/table"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "power_law_field": {
      "description": "A power law (record_format.md section 6). Its member is a placeholder until its shape is written.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "power_law",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "power_law"
        },
        "power_law": {
          "anyOf": [
            {
              "$ref": "#/$defs/placeholder"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "interval_field": {
      "description": "An interval: bounds with their basis, known only as bounds (record_format.md section 6).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "interval",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "interval"
        },
        "interval": {
          "anyOf": [
            {
              "$ref": "#/$defs/interval"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "composition_field": {
      "description": "A composition (record_format.md section 6).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "composition",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "composition"
        },
        "composition": {
          "anyOf": [
            {
              "$ref": "#/$defs/composition"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "parameter_set_field": {
      "description": "A model parameter set (model_families.md). Its member is a placeholder until its shape is written.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "parameter_set",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "parameter_set"
        },
        "parameter_set": {
          "anyOf": [
            {
              "$ref": "#/$defs/placeholder"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "reference_data_field": {
      "description": "Reference data (fits_and_reference_data.md section 1), whose statistics may not apply. Its member is a placeholder until its shape is written.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "reference_data",
        "conditions",
        "statistics"
      ],
      "properties": {
        "form": {
          "const": "reference_data"
        },
        "reference_data": {
          "anyOf": [
            {
              "$ref": "#/$defs/placeholder"
            },
            {
              "$ref": "#/$defs/status_withheld"
            }
          ]
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "statistics": {
          "anyOf": [
            {
              "$ref": "#/$defs/statistics_block"
            },
            {
              "$ref": "#/$defs/status_withheld_or_not_applicable"
            }
          ]
        }
      }
    },
    "evidence_field": {
      "description": "Biocompatibility evidence: a list of test reports, never a status, under no condition and with no statistics (record_format.md section 4.3).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/field_members"
        }
      ],
      "required": [
        "form",
        "evidence",
        "conditions"
      ],
      "properties": {
        "form": {
          "const": "evidence"
        },
        "evidence": {
          "type": "array",
          "minItems": 1,
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/evidence_entry"
              },
              {
                "$ref": "#/$defs/withheld_evidence_entry"
              }
            ]
          }
        },
        "conditions": {
          "description": "No condition: a registered one here breaks the field's shape.",
          "type": "object"
        }
      }
    },
    "unit": {
      "description": "A unit code, compared with the registered unit at step 9 alone (record_format.md section 4.2), or a status object.",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/status_object"
        }
      ]
    },
    "table": {
      "description": "A table's members (record_format.md section 6, table items 1 to 5): y holds one number for each value of x, at least two of them distinct, in an order that never decreases, each edge lying strictly inside x's range and in x exactly twice, consecutively, and no other value of x twice; and source_range is two numbers, the first not greater than the second, sharing with x's range a value that is no edge. A schema states none of these rules across members, which step 8 of a read checks. points, a name item 5 reserves, is no member of this shape: a 0.1.0 writer does not write it, and a reader refuses a table that holds it at step 8 (points_unsupported).",
      "type": "object",
      "required": [
        "axis",
        "axis_unit",
        "x",
        "y",
        "scheme",
        "edges"
      ],
      "properties": {
        "axis": {
          "type": "string"
        },
        "axis_unit": {
          "$ref": "#/$defs/unit"
        },
        "x": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "number"
          }
        },
        "y": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "number"
          }
        },
        "scheme": {
          "type": "string"
        },
        "edges": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "type": "number"
          }
        },
        "source_range": {
          "$ref": "#/$defs/range"
        }
      },
      "if": {
        "required": [
          "scheme"
        ],
        "properties": {
          "scheme": {
            "const": "loglog"
          }
        }
      },
      "then": {
        "properties": {
          "x": {
            "items": {
              "exclusiveMinimum": 0
            }
          },
          "y": {
            "items": {
              "exclusiveMinimum": 0
            }
          }
        }
      }
    },
    "interval": {
      "description": "lower <= upper where both are numbers, and at most one holds none (record_format.md section 6).",
      "type": "object",
      "required": [
        "lower",
        "upper",
        "basis"
      ],
      "properties": {
        "lower": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_none"
            }
          ]
        },
        "upper": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_none"
            }
          ]
        },
        "basis": {
          "type": "string"
        }
      },
      "not": {
        "properties": {
          "lower": {
            "type": "object"
          },
          "upper": {
            "type": "object"
          }
        }
      }
    },
    "composition": {
      "description": "At least one component, none twice; stated_sum is the sum the source gives, never normalised (record_format.md section 6).",
      "type": "object",
      "required": [
        "basis",
        "sum_rule",
        "components"
      ],
      "properties": {
        "basis": {
          "type": "string"
        },
        "sum_rule": {
          "type": "string"
        },
        "stated_sum": {
          "type": "number"
        },
        "components": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/composition_component"
          }
        }
      }
    },
    "composition_component": {
      "description": "A component, element:<symbol>, its fraction from 0 to 1, and optionally its own statistics block.",
      "type": "object",
      "required": [
        "component",
        "fraction"
      ],
      "properties": {
        "component": {
          "type": "string"
        },
        "fraction": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "statistics": {
          "$ref": "#/$defs/field_statistics"
        }
      }
    },
    "evidence_entry": {
      "description": "A test report (record_format.md section 4.3). Each member but provenance may hold a status object other than withheld.",
      "type": "object",
      "required": [
        "endpoint",
        "standard",
        "contact_category",
        "contact_duration",
        "material_form",
        "processing",
        "reported_result",
        "provenance"
      ],
      "properties": {
        "endpoint": {
          "$ref": "#/$defs/report_text"
        },
        "standard": {
          "anyOf": [
            {
              "$ref": "#/$defs/standard"
            },
            {
              "$ref": "#/$defs/status_not_withheld"
            }
          ]
        },
        "contact_category": {
          "$ref": "#/$defs/report_text"
        },
        "contact_duration": {
          "$ref": "#/$defs/report_text"
        },
        "material_form": {
          "$ref": "#/$defs/report_text"
        },
        "processing": {
          "$ref": "#/$defs/report_text"
        },
        "reported_result": {
          "$ref": "#/$defs/report_text"
        },
        "provenance": {
          "$ref": "#/$defs/provenance"
        }
      }
    },
    "withheld_evidence_entry": {
      "description": "A test report from a reference-only source: withheld whole, its provenance kept and carrying the recipe (record_format.md section 4.3 item 2, provenance.md section 7 item 2).",
      "type": "object",
      "required": [
        "endpoint",
        "standard",
        "contact_category",
        "contact_duration",
        "material_form",
        "processing",
        "reported_result",
        "provenance"
      ],
      "properties": {
        "endpoint": {
          "$ref": "#/$defs/status_withheld"
        },
        "standard": {
          "$ref": "#/$defs/status_withheld"
        },
        "contact_category": {
          "$ref": "#/$defs/status_withheld"
        },
        "contact_duration": {
          "$ref": "#/$defs/status_withheld"
        },
        "material_form": {
          "$ref": "#/$defs/status_withheld"
        },
        "processing": {
          "$ref": "#/$defs/status_withheld"
        },
        "reported_result": {
          "$ref": "#/$defs/status_withheld"
        },
        "provenance": {
          "$ref": "#/$defs/provenance"
        }
      }
    },
    "report_text": {
      "description": "The source's words, until the member's tokens are listed (record_format.md section 4.3).",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$ref": "#/$defs/status_not_withheld"
        }
      ]
    },
    "standard": {
      "description": "The standard and part a test followed, and its year, a whole number.",
      "type": "object",
      "required": [
        "designation",
        "year"
      ],
      "properties": {
        "designation": {
          "type": "string"
        },
        "year": {
          "type": "integer"
        }
      }
    },
    "conditions": {
      "description": "The conditions the value was measured at, by name (provenance.md section 6.1): a token condition holds a token of its own row's list, and a numeric one's registered unit is compared at step 9.",
      "type": "object",
      "properties": {
        "temperature": {
          "anyOf": [
            {
              "$ref": "#/$defs/numeric_condition"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "shear_rate": {
          "anyOf": [
            {
              "$ref": "#/$defs/numeric_condition"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "magnetic_flux_density": {
          "anyOf": [
            {
              "$ref": "#/$defs/numeric_condition"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "density_kind": {
          "anyOf": [
            {
              "$ref": "#/$defs/condition_density_kind"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "specimen_shape": {
          "anyOf": [
            {
              "$ref": "#/$defs/condition_specimen_shape"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "specimen_size": {
          "anyOf": [
            {
              "$ref": "#/$defs/numeric_condition"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "measurement_geometry": {
          "anyOf": [
            {
              "$ref": "#/$defs/condition_measurement_geometry"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "measurement_dimension": {
          "anyOf": [
            {
              "$ref": "#/$defs/numeric_condition"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "test_method": {
          "anyOf": [
            {
              "$ref": "#/$defs/condition_test_method"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        }
      }
    },
    "based": {
      "description": "Where a condition or a specimen fact comes from: stated, or inferred with the text it was inferred from (provenance.md section 6).",
      "type": "object",
      "required": [
        "basis"
      ],
      "properties": {
        "basis": {
          "type": "string"
        },
        "inferred_from": {
          "type": "string"
        }
      },
      "if": {
        "required": [
          "basis"
        ],
        "properties": {
          "basis": {
            "const": "inferred"
          }
        }
      },
      "then": {
        "required": [
          "inferred_from"
        ]
      }
    },
    "numeric_condition": {
      "description": "A value or a range [lo, hi], lo not above hi, in the condition's registered unit; optionally the source's plus or minus and whether it was set or measured (provenance.md section 6.1 items 1, 6 and 7).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "unit"
      ],
      "properties": {
        "value": {
          "type": "number"
        },
        "range": {
          "$ref": "#/$defs/range"
        },
        "unit": {
          "$ref": "#/$defs/unit"
        },
        "plus_minus": {
          "$ref": "#/$defs/plus_minus"
        },
        "set_or_measured": {
          "type": "string"
        }
      },
      "if": {
        "required": [
          "value"
        ]
      },
      "then": {
        "not": {
          "required": [
            "range"
          ]
        }
      },
      "else": {
        "required": [
          "range"
        ]
      }
    },
    "condition_density_kind": {
      "description": "The token condition density_kind: a token of its row (provenance.md section 6.1 item 1); it registers no unit.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "condition_specimen_shape": {
      "description": "The token condition specimen_shape: a token of its row (provenance.md section 6.1 item 1); it registers no unit.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "condition_measurement_geometry": {
      "description": "The token condition measurement_geometry: a token of its row (provenance.md section 6.1 item 1); it registers no unit.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "condition_test_method": {
      "description": "The token condition test_method: a token of its row (provenance.md section 6.1 item 1); it registers no unit.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "range": {
      "description": "[lo, hi], lo not above hi.",
      "type": "array",
      "prefixItems": [
        {
          "type": "number"
        },
        {
          "type": "number"
        }
      ],
      "minItems": 2,
      "maxItems": 2
    },
    "plus_minus": {
      "description": "The plus or minus a source states (provenance.md section 6.1 item 6): at most one entry of each kind, and one of unstated kind alone.",
      "type": "array",
      "minItems": 1,
      "maxItems": 2,
      "items": {
        "$ref": "#/$defs/plus_minus_entry"
      },
      "if": {
        "minItems": 2
      },
      "then": {
        "allOf": [
          {
            "contains": {
              "required": [
                "stated_as"
              ],
              "properties": {
                "stated_as": {
                  "const": "bound"
                }
              }
            }
          },
          {
            "contains": {
              "required": [
                "stated_as"
              ],
              "properties": {
                "stated_as": {
                  "const": "sd"
                }
              }
            }
          }
        ]
      }
    },
    "plus_minus_entry": {
      "type": "object",
      "required": [
        "stated_as",
        "value",
        "unit"
      ],
      "properties": {
        "stated_as": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "value": {
          "type": "number",
          "minimum": 0
        },
        "unit": {
          "$ref": "#/$defs/unit"
        }
      }
    },
    "specimen": {
      "description": "Specimen facts, by name (provenance.md section 6.2); a field's override its section's, fact by fact. Where a fact's row fixes its unit, step 9 compares the unit with it and the writer binds the unit to it: a fact whose unit the source does not give is written as a status object.",
      "type": "object",
      "properties": {
        "species": {
          "anyOf": [
            {
              "$ref": "#/$defs/species"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "anatomical_site": {
          "anyOf": [
            {
              "$ref": "#/$defs/anatomical_site"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "tissue_state": {
          "anyOf": [
            {
              "$ref": "#/$defs/tissue_state"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "disease_and_treatment_state": {
          "anyOf": [
            {
              "$ref": "#/$defs/disease_and_treatment_state"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "preparation": {
          "anyOf": [
            {
              "$ref": "#/$defs/preparation"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "preservation": {
          "anyOf": [
            {
              "$ref": "#/$defs/preservation"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "post_mortem_interval": {
          "anyOf": [
            {
              "$ref": "#/$defs/post_mortem_interval"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "donor_age": {
          "anyOf": [
            {
              "$ref": "#/$defs/donor_age"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "mimics": {
          "anyOf": [
            {
              "$ref": "#/$defs/mimics"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "supply_form": {
          "anyOf": [
            {
              "$ref": "#/$defs/supply_form"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "lot": {
          "anyOf": [
            {
              "$ref": "#/$defs/lot"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        }
      }
    },
    "species": {
      "description": "An NCBI Taxonomy identifier.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "ncbi_taxon",
        "label"
      ],
      "properties": {
        "ncbi_taxon": {
          "type": "integer"
        },
        "label": {
          "type": "string"
        }
      }
    },
    "anatomical_site": {
      "description": "A UBERON identifier.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "uberon",
        "label"
      ],
      "properties": {
        "uberon": {
          "type": "string"
        },
        "label": {
          "type": "string"
        }
      }
    },
    "tissue_state": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "disease_and_treatment_state": {
      "description": "The state, and which disease or treatment: a text exactly where the state is diseased or treated, none where it is normal (provenance.md section 6.2).",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      },
      "if": {
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "anyOf": [
              {
                "const": "diseased"
              },
              {
                "const": "treated"
              }
            ]
          }
        }
      },
      "then": {
        "required": [
          "text"
        ]
      },
      "else": {
        "not": {
          "required": [
            "text"
          ]
        }
      }
    },
    "preparation": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "type": "string"
        }
      }
    },
    "preservation": {
      "description": "The preservation, with a text required for other.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        },
        "text": {
          "type": "string"
        }
      },
      "if": {
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "const": "other"
          }
        }
      },
      "then": {
        "required": [
          "text"
        ]
      }
    },
    "post_mortem_interval": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "value",
        "unit"
      ],
      "properties": {
        "value": {
          "type": "number"
        },
        "unit": {
          "$ref": "#/$defs/unit"
        }
      }
    },
    "donor_age": {
      "description": "A value or a range [lo, hi], in seconds.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "unit"
      ],
      "properties": {
        "value": {
          "type": "number"
        },
        "range": {
          "$ref": "#/$defs/range"
        },
        "unit": {
          "$ref": "#/$defs/unit"
        }
      },
      "if": {
        "required": [
          "value"
        ]
      },
      "then": {
        "not": {
          "required": [
            "range"
          ]
        }
      },
      "else": {
        "required": [
          "range"
        ]
      }
    },
    "mimics": {
      "description": "What a phantom or a substitute was made to mimic, as its maker states it: its basis is stated, never inferred, so it has no inferred_from.",
      "type": "object",
      "required": [
        "text",
        "basis"
      ],
      "properties": {
        "text": {
          "type": "string"
        },
        "basis": {
          "type": "string"
        }
      }
    },
    "supply_form": {
      "description": "A manufactured material as supplied, a coupon made or cut for the test, or a finished component tested as a specimen of its material.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "token"
      ],
      "properties": {
        "token": {
          "type": "string"
        }
      }
    },
    "lot": {
      "description": "The lot or batch, as the source names it.",
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/based"
        }
      ],
      "required": [
        "text"
      ],
      "properties": {
        "text": {
          "type": "string"
        }
      }
    },
    "field_statistics": {
      "description": "A statistics block, withheld in a reference-only value (uncertainty.md section 1).",
      "anyOf": [
        {
          "$ref": "#/$defs/statistics_block"
        },
        {
          "$ref": "#/$defs/status_withheld"
        }
      ]
    },
    "statistics_block": {
      "description": "uncertainty.md section 1: every member present, population_level, n_sources and precision_conditions exactly where represents calls for them.",
      "type": "object",
      "required": [
        "central",
        "n_specimens",
        "n_donors",
        "mean",
        "sd",
        "min",
        "max",
        "distribution",
        "basis",
        "represents",
        "dispersion",
        "relative_uncertainty",
        "expanded_uncertainty"
      ],
      "properties": {
        "central": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_not_applicable"
            }
          ]
        },
        "n_specimens": {
          "$ref": "#/$defs/count"
        },
        "n_donors": {
          "$ref": "#/$defs/count"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "sd": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "min": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "max": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "distribution": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "basis": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_not_applicable"
            }
          ]
        },
        "represents": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated_or_not_applicable"
            }
          ]
        },
        "population_level": {
          "anyOf": [
            {
              "$ref": "#/$defs/population_level"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "n_sources": {
          "$ref": "#/$defs/count"
        },
        "precision_conditions": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "dispersion": {
          "type": "string"
        },
        "relative_uncertainty": {
          "anyOf": [
            {
              "$ref": "#/$defs/uncertainty"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "expanded_uncertainty": {
          "anyOf": [
            {
              "$ref": "#/$defs/uncertainty"
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "required": [
              "represents"
            ],
            "properties": {
              "represents": {
                "const": "population"
              }
            }
          },
          "then": {
            "required": [
              "population_level"
            ]
          },
          "else": {
            "not": {
              "required": [
                "population_level"
              ]
            }
          }
        },
        {
          "if": {
            "required": [
              "represents"
            ],
            "properties": {
              "represents": {
                "const": "across_sources"
              }
            }
          },
          "then": {
            "required": [
              "n_sources"
            ]
          },
          "else": {
            "not": {
              "required": [
                "n_sources"
              ]
            }
          }
        },
        {
          "if": {
            "required": [
              "represents"
            ],
            "properties": {
              "represents": {
                "const": "measurement"
              }
            }
          },
          "then": {
            "required": [
              "precision_conditions"
            ]
          },
          "else": {
            "not": {
              "required": [
                "precision_conditions"
              ]
            }
          }
        }
      ]
    },
    "count": {
      "description": "A whole number, not negative, or a status object.",
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0
        },
        {
          "$ref": "#/$defs/status_object"
        }
      ]
    },
    "population_level": {
      "description": "The level a population spread is taken over, and the level it is taken within (uncertainty.md section 1 rule 10).",
      "type": "object",
      "required": [
        "level",
        "within"
      ],
      "properties": {
        "level": {
          "type": "string"
        },
        "within": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_none"
            }
          ]
        }
      }
    },
    "uncertainty": {
      "description": "A relative or expanded uncertainty, as stored (uncertainty.md section 1): at least one of coverage_factor and coverage_probability a number, dof a number exactly where distribution is student_t, and precision_conditions exactly where represents is measurement. value is in unit 1 in a relative one, and in the field's unit in an expanded one.",
      "type": "object",
      "required": [
        "value",
        "coverage_factor",
        "coverage_probability",
        "distribution",
        "dof",
        "basis",
        "represents"
      ],
      "properties": {
        "value": {
          "type": "number",
          "minimum": 0
        },
        "coverage_factor": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "coverage_probability": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 1
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "distribution": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "dof": {
          "anyOf": [
            {
              "type": "number",
              "exclusiveMinimum": 0
            },
            {
              "$ref": "#/$defs/status_object"
            }
          ]
        },
        "basis": {
          "type": "string"
        },
        "represents": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        },
        "precision_conditions": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/$defs/status_unstated"
            }
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "required": [
              "coverage_factor"
            ],
            "properties": {
              "coverage_factor": {
                "type": "object"
              }
            }
          },
          "then": {
            "properties": {
              "coverage_probability": {
                "type": "number"
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "distribution"
            ],
            "properties": {
              "distribution": {
                "const": "student_t"
              }
            }
          },
          "then": {
            "properties": {
              "dof": {
                "type": "number"
              }
            }
          },
          "else": {
            "properties": {
              "dof": {
                "type": "object"
              }
            }
          }
        },
        {
          "if": {
            "required": [
              "represents"
            ],
            "properties": {
              "represents": {
                "const": "measurement"
              }
            }
          },
          "then": {
            "required": [
              "precision_conditions"
            ]
          },
          "else": {
            "not": {
              "required": [
                "precision_conditions"
              ]
            }
          }
        }
      ]
    },
    "provenance": {
      "description": "provenance.md section 2. A read checks origin, source and, for origin derived, derivation; the other members are the record checks'.",
      "type": "object",
      "required": [
        "origin"
      ],
      "properties": {
        "origin": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "extraction": true,
        "evidence": true,
        "assistance": true,
        "review": true,
        "derivation": true,
        "formulation": true,
        "search": true,
        "import": true,
        "per_parameter": true,
        "recipe": true
      },
      "allOf": [
        {
          "if": {
            "required": [
              "origin"
            ],
            "properties": {
              "origin": {
                "const": "measured_by_source"
              }
            }
          },
          "then": {
            "required": [
              "source"
            ]
          }
        },
        {
          "if": {
            "required": [
              "origin"
            ],
            "properties": {
              "origin": {
                "const": "derived"
              }
            }
          },
          "then": {
            "required": [
              "derivation"
            ]
          }
        },
        {
          "if": {
            "required": [
              "origin"
            ],
            "properties": {
              "origin": {
                "const": "derived"
              }
            }
          },
          "then": {
            "properties": {
              "derivation": {
                "$ref": "#/$defs/derivation"
              }
            }
          }
        }
      ]
    },
    "source": {
      "description": "The source registry's key, the document read and the place in it. A read checks only key, which a result returns.",
      "type": "object",
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "document": true,
        "locator": true
      }
    },
    "derivation": {
      "description": "A derived value's method, its inputs as pinned references, its assumptions, the inputs' specimen facts, and whether the inputs' conditions differ (provenance.md section 5).",
      "type": "object",
      "required": [
        "method",
        "inputs",
        "assumptions",
        "input_specimens"
      ],
      "properties": {
        "method": {
          "type": "string"
        },
        "inputs": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/derivation_input"
          }
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "input_specimens": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/input_specimen"
          }
        },
        "mixed_conditions": {
          "type": "boolean"
        }
      }
    },
    "derivation_input": {
      "type": "object",
      "required": [
        "record",
        "field"
      ],
      "properties": {
        "record": {
          "$ref": "#/$defs/pinned_record"
        },
        "field": {
          "type": "string"
        }
      }
    },
    "input_specimen": {
      "description": "An input's specimen facts, input being its index in inputs.",
      "type": "object",
      "required": [
        "input",
        "specimen"
      ],
      "properties": {
        "input": {
          "type": "integer",
          "minimum": 0
        },
        "specimen": {
          "$ref": "#/$defs/specimen"
        }
      }
    },
    "pinned_record": {
      "description": "A record by its id and version, pinned by its content hash.",
      "type": "object",
      "required": [
        "id",
        "version",
        "content_hash"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/record_id"
        },
        "version": {
          "$ref": "#/$defs/version"
        },
        "content_hash": {
          "$ref": "#/$defs/content_hash"
        }
      }
    },
    "status_object": {
      "description": "A member's status where it has no ordinary value (provenance.md section 1).",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_withheld": {
      "description": "A status object holding withheld: a reference-only value (provenance.md section 7).",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_none": {
      "description": "A status object holding none.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_not_applicable": {
      "description": "A status object holding not_applicable.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_unstated": {
      "description": "A status object holding unstated.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_unstated_or_not_applicable": {
      "description": "A status object holding unstated or not_applicable.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_withheld_or_not_applicable": {
      "description": "A status object holding withheld or not_applicable.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "status_not_withheld": {
      "description": "A status object holding any token but withheld, which an evidence entry holds only whole.",
      "type": "object",
      "required": [
        "status"
      ],
      "properties": {
        "status": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        }
      }
    },
    "placeholder": {
      "description": "A member whose shape is not yet written, in a member that may hold a status object instead: any object but one holding status, which is a status object and holds a token its row allows (provenance.md section 1 item 5).",
      "type": "object",
      "not": {
        "required": [
          "status"
        ]
      }
    }
  }
}
