{
  "$id": "https://schema.rtemis.org/artifact/diagnostics/v1/schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "rtemis diagnostics artifact",
  "description": "One immutable version of an rtemis harness artifact holding what validating a plan version reported, and which implementation answered. `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",
      "const": "diagnostics"
    },
    "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": "What validating one plan version reported.",
      "type": "object",
      "properties": {
        "plan": {
          "description": "The plan version these findings are about.",
          "type": "object",
          "properties": {
            "name": {
              "description": "The referenced artifact's name.",
              "type": "string"
            },
            "version": {
              "description": "Which version of it.",
              "type": "integer",
              "minimum": 1
            },
            "id": {
              "description": "What that version's content hashed to, as `blake3:<hex>`.",
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": ["name", "version", "id"]
        },
        "identity": {
          "description": "Which implementation answered, and from which rule set.",
          "type": "object",
          "properties": {
            "implementation": {
              "description": "Which evaluator produced these findings.",
              "type": "object",
              "properties": {
                "name": {
                  "description": "What answered: `rtemis`, `rtemis-schema` or `rtemis-wasm`.",
                  "type": "string"
                },
                "version": {
                  "description": "Its version.",
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": ["name", "version"]
            },
            "checks": {
              "description": "The rule set it evaluated.",
              "type": "object",
              "properties": {
                "id": {
                  "description": "The document's `$id`.",
                  "type": "string"
                },
                "sha256": {
                  "description": "Its sha256, or null where the answer did not come from reading it. Null means rtemis: it does not *read* `checks.json`, it is the source the rules are compiled from, so it has no digest to report and one it computed would assert a correspondence nothing checks. A null here is therefore a fact worth having -- it says the reference implementation answered.",
                  "type": ["string", "null"]
                }
              },
              "additionalProperties": false,
              "required": ["id", "sha256"]
            },
            "traits": {
              "description": "The algorithm trait table it read.",
              "type": "object",
              "properties": {
                "id": {
                  "description": "The document's `$id`.",
                  "type": "string"
                },
                "sha256": {
                  "description": "Its sha256, or null where the answer did not come from reading it. Null means rtemis: it does not *read* `checks.json`, it is the source the rules are compiled from, so it has no digest to report and one it computed would assert a correspondence nothing checks. A null here is therefore a fact worth having -- it says the reference implementation answered.",
                  "type": ["string", "null"]
                }
              },
              "additionalProperties": false,
              "required": ["id", "sha256"]
            }
          },
          "additionalProperties": false,
          "required": ["implementation", "checks", "traits"]
        },
        "findings": {
          "description": "The findings, in the shape `diagnostic/r/v1` declares. Empty means clean.",
          "type": "array",
          "items": {
            "$ref": "https://schema.rtemis.org/diagnostic/r/v1/schema.json"
          }
        }
      },
      "additionalProperties": false,
      "required": ["plan", "identity", "findings"]
    }
  },
  "additionalProperties": false,
  "required": ["id", "type", "name", "version", "created", "origin", "content"]
}
