{
  "$id": "https://schema.rtemis.org/artifact/v1/schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "rtemis harness artifact",
  "description": "One immutable version of any rtemis harness artifact, routed to its                         shape by `type`. `name` and `version` say which revision of which                         artifact; `id` is a BLAKE3 digest over the RFC 8785 canonical form of                         `content`, so it says whether two versions are the same document.",
  "type": "object",
  "properties": {
    "id": {
      "description": "Digest of `content`, as `blake3:<hex>` over its RFC 8785 canonical form. The algorithm travels with the digest rather than being implied, so a later one can be introduced without rewriting what is already recorded -- the property `DataFingerprint` gets from carrying `algorithm` and `encoding` beside each hash.",
      "type": "string"
    },
    "type": {
      "description": "Which of the five this is.",
      "type": "string",
      "enum": ["question", "plan", "diagnostics", "record", "report"]
    },
    "name": {
      "description": "The artifact's name within its study, stable across versions.",
      "type": "string"
    },
    "version": {
      "description": "Which revision this is, from 1, contiguous within a name.",
      "type": "integer",
      "minimum": 1
    },
    "created": {
      "description": "When this version was written, RFC 3339 in UTC.",
      "type": "string"
    },
    "origin": {
      "description": "Who authored this version.",
      "type": "string",
      "enum": ["user_edit", "agent_revision", "applied_patch", "run_result"]
    },
    "content": {
      "description": "The document itself, in the shape the selected leaf declares."
    }
  },
  "required": ["id", "type", "name", "version", "created", "origin", "content"],
  "unevaluatedProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "type": {
            "const": "question"
          }
        },
        "required": ["type"]
      },
      "then": {
        "$ref": "https://schema.rtemis.org/artifact/question/v1/schema.json"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "plan"
          }
        },
        "required": ["type"]
      },
      "then": {
        "$ref": "https://schema.rtemis.org/artifact/plan/v1/schema.json"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "diagnostics"
          }
        },
        "required": ["type"]
      },
      "then": {
        "$ref": "https://schema.rtemis.org/artifact/diagnostics/v1/schema.json"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "record"
          }
        },
        "required": ["type"]
      },
      "then": {
        "$ref": "https://schema.rtemis.org/artifact/record/v1/schema.json"
      }
    },
    {
      "if": {
        "properties": {
          "type": {
            "const": "report"
          }
        },
        "required": ["type"]
      },
      "then": {
        "$ref": "https://schema.rtemis.org/artifact/report/v1/schema.json"
      }
    }
  ]
}
