{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ghtier.com/data/assessment.schema.json",
  "title": "ghtier assessment",
  "description": "Results of running ghtier's checklist checks against one GitHub organization. Written by skills/ghtier-assess/assess.mjs, imported on /checklist.",
  "type": "object",
  "required": [
    "tool",
    "version",
    "org",
    "generatedAt",
    "results"
  ],
  "properties": {
    "tool": {
      "const": "ghtier-assess"
    },
    "version": {
      "const": 1
    },
    "org": {
      "type": "string"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "checklistGeneratedAt": {
      "type": "string",
      "description": "generatedAt of the checklist.json the checks came from."
    },
    "assessor": {
      "type": "object",
      "properties": {
        "login": {
          "type": "string"
        },
        "role": {
          "type": "string"
        }
      }
    },
    "results": {
      "type": "object",
      "description": "Keyed by checklist item id.",
      "additionalProperties": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "enum": [
              "pass",
              "fail",
              "partial",
              "review",
              "error"
            ]
          },
          "value": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "Absent for review and error."
          },
          "detail": {
            "type": "string"
          },
          "repos": {
            "type": "object",
            "properties": {
              "passed": {
                "type": "integer"
              },
              "failed": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "unknown": {
                "type": "integer"
              }
            }
          },
          "title": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "effort": {
            "type": "string"
          },
          "needs": {
            "type": "string"
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "docs": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string"
              },
              "url": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "sources": {
      "type": "array",
      "description": "Every file the runner read, with its SHA-256, so a run can be tied to the exact checks and tier data it used.",
      "items": {
        "type": "object",
        "required": [
          "name",
          "sha256"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "from": {
            "type": "string"
          },
          "sha256": {
            "type": "string"
          }
        }
      }
    },
    "inventory": {
      "type": "object",
      "description": "Who holds which tier in the organization: owners, organization role holders, the base permission, installed Apps, outside collaborators, self-hosted runners, deploy keys with write access, ruleset bypass actors, organization webhooks, organization secrets visible to all repositories, open runner groups and SSO-authorized credentials.",
      "required": [
        "counts",
        "holders"
      ],
      "properties": {
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "counts": {
          "type": "object",
          "properties": {
            "0": {
              "type": "integer"
            },
            "1": {
              "type": "integer"
            },
            "2": {
              "type": "integer"
            },
            "3": {
              "type": "integer"
            },
            "untiered": {
              "type": "integer"
            }
          }
        },
        "holders": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "kind",
              "holder",
              "via",
              "tier",
              "why"
            ],
            "properties": {
              "kind": {
                "enum": [
                  "owner",
                  "org-role",
                  "base-permission",
                  "app",
                  "outside-collaborator",
                  "runner",
                  "deploy-key",
                  "ruleset-bypass",
                  "webhook",
                  "org-secret",
                  "runner-group",
                  "credential"
                ]
              },
              "holder": {
                "type": "string"
              },
              "holderType": {
                "enum": [
                  "user",
                  "team",
                  "everyone",
                  "app",
                  "machine",
                  "key",
                  "role",
                  "endpoint",
                  "secret"
                ]
              },
              "via": {
                "type": "string"
              },
              "tier": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 0,
                "maximum": 3,
                "description": "null when a person has to review it."
              },
              "why": {
                "type": "string"
              },
              "href": {
                "type": "string"
              },
              "permissions": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "errors": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "what": {
                "type": "string"
              },
              "path": {
                "type": "string"
              },
              "detail": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
