{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://proofet.com/atlas/schemas/0.1.0/assurance-result.schema.json",
  "title": "Proofet Atlas Assurance Result",
  "type": "object",
  "additionalProperties": false,
  "required": ["id", "characteristic", "status", "scope", "evidence", "detail", "limitations"],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)*$"
    },
    "characteristic": {
      "enum": [
        "atlas.assurance.decoding",
        "atlas.assurance.structure",
        "atlas.assurance.conformance",
        "atlas.assurance.cryptography",
        "atlas.assurance.status",
        "atlas.assurance.trust",
        "atlas.assurance.binding",
        "atlas.assurance.privacy",
        "atlas.assurance.fitness_for_purpose"
      ]
    },
    "subject": { "type": "string", "minLength": 1 },
    "status": { "enum": ["pass", "fail", "warning", "not_checked", "not_applicable"] },
    "scope": { "type": "string", "minLength": 1 },
    "ruleset": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "required": ["identifier", "version"],
      "properties": {
        "identifier": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "minLength": 1 }
      }
    },
    "evidence": {
      "type": "array",
      "items": { "$ref": "#/$defs/evidence" }
    },
    "detail": { "type": "string", "minLength": 1 },
    "limitations": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true
    },
    "evaluated_at": { "type": ["string", "null"], "format": "date-time" },
    "outcome": { "enum": ["acceptable", "rejected", "indeterminate"] }
  },
  "$defs": {
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source", "path", "observation"],
      "properties": {
        "source": { "type": "string", "minLength": 1 },
        "path": { "type": "string" },
        "value": {},
        "value_digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "redaction": { "type": "string", "minLength": 1 },
        "observation": { "type": "string", "minLength": 1 }
      }
    }
  },
  "allOf": [
    {
      "if": { "properties": { "characteristic": { "const": "atlas.assurance.fitness_for_purpose" } } },
      "then": { "required": ["ruleset", "outcome"] }
    }
  ]
}