{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://viridisconservation.com/science/decision-workspace/decision-package.schema.json",
  "title": "Viridis versioned decision package",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "identity",
    "provenance",
    "scientificScope",
    "executable",
    "decisionRole",
    "evidence",
    "explanation"
  ],
  "properties": {
    "schemaVersion": {
      "const": "viridis.decision-package.v1"
    },
    "identity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "version",
        "title",
        "purpose"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "version": {
          "type": "string",
          "pattern": "^\\d+\\.\\d+\\.\\d+(-[a-zA-Z0-9.-]+)?$"
        },
        "title": {
          "type": "string"
        },
        "purpose": {
          "type": "string"
        }
      }
    },
    "provenance": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "title",
          "url",
          "kind",
          "doi",
          "repository",
          "commit",
          "sha256",
          "license"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "pattern": "^(https://|/science/)"
          },
          "kind": {
            "enum": [
              "paper",
              "formal_source",
              "code",
              "certificate",
              "audit",
              "documentation"
            ]
          },
          "doi": {
            "type": [
              "string",
              "null"
            ]
          },
          "repository": {
            "type": [
              "string",
              "null"
            ]
          },
          "commit": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{40}$"
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{64}$"
          },
          "license": {
            "type": "string"
          }
        }
      }
    },
    "scientificScope": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "statement",
        "definitions",
        "assumptions",
        "domains",
        "exclusions",
        "intelligenceBound"
      ],
      "properties": {
        "statement": {
          "type": "string"
        },
        "definitions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "symbol",
              "definition",
              "unit"
            ],
            "properties": {
              "symbol": {
                "type": "string"
              },
              "definition": {
                "type": "string"
              },
              "unit": {
                "type": "string"
              }
            }
          }
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "domains": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclusions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "intelligenceBound": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "relationship",
            "justification",
            "sourceIds"
          ],
          "properties": {
            "relationship": {
              "enum": [
                "ROOT",
                "DIRECT_DERIVATION",
                "SHARED_ASSUMPTIONS",
                "CONSTRAINT_COMPATIBILITY",
                "NOT_ESTABLISHED"
              ]
            },
            "justification": {
              "type": "string"
            },
            "sourceIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "executable": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "entrypoint",
        "implementationSha256",
        "inputs",
        "outputs",
        "constraints",
        "dependencies",
        "errorStates"
      ],
      "properties": {
        "entrypoint": {
          "type": "string"
        },
        "implementationSha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "inputs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "unit",
              "required",
              "range"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "unit": {
                "type": "string"
              },
              "required": {
                "type": "boolean"
              },
              "range": {
                "type": "string"
              }
            }
          }
        },
        "outputs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "name",
              "unit"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "unit": {
                "type": "string"
              }
            }
          }
        },
        "constraints": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "dependencies": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "version",
              "role"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "version": {
                "type": "string"
              },
              "role": {
                "type": "string"
              }
            }
          }
        },
        "errorStates": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "decisionRole": {
      "enum": [
        "APPLICABILITY_AND_CONSTRAINT_FRAMEWORK",
        "SCENARIO_RESOURCE_ALLOCATION"
      ]
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "formal",
        "implementation",
        "empirical",
        "release"
      ],
      "properties": {
        "formal": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "scope",
            "artifacts",
            "limitations",
            "theorems",
            "toolchain",
            "mathlibCommit",
            "foundationalAxioms",
            "scientificAssumptions",
            "dependencyClosure"
          ],
          "properties": {
            "status": {
              "type": "string"
            },
            "scope": {
              "type": "string"
            },
            "artifacts": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "theorems": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "toolchain": {
              "type": "string"
            },
            "mathlibCommit": {
              "type": [
                "string",
                "null"
              ]
            },
            "foundationalAxioms": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "scientificAssumptions": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "dependencyClosure": {
              "type": "string"
            }
          }
        },
        "implementation": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "scope",
            "artifacts",
            "limitations"
          ],
          "properties": {
            "status": {
              "type": "string"
            },
            "scope": {
              "type": "string"
            },
            "artifacts": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "empirical": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "scope",
            "artifacts",
            "limitations"
          ],
          "properties": {
            "status": {
              "type": "string"
            },
            "scope": {
              "type": "string"
            },
            "artifacts": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "release": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "scope",
            "artifacts",
            "limitations",
            "approval",
            "reviewId"
          ],
          "properties": {
            "status": {
              "type": "string"
            },
            "scope": {
              "type": "string"
            },
            "artifacts": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "limitations": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "approval": {
              "enum": [
                "LOCAL_PREVIEW_ONLY",
                "APPROVED_PRODUCTION"
              ]
            },
            "reviewId": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "explanation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "means",
        "doesNotEstablish",
        "informationThatCouldChangeResult"
      ],
      "properties": {
        "means": {
          "type": "string"
        },
        "doesNotEstablish": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "informationThatCouldChangeResult": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
