{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "const": "scope-report"
    },
    "version": {
      "type": "number",
      "const": 1
    },
    "project": {
      "type": "string",
      "minLength": 1
    },
    "scope": {
      "type": "string",
      "minLength": 1
    },
    "repo": {
      "type": "string"
    },
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "rubric": {
      "type": "object",
      "properties": {
        "asOf": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "multiplier": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "leadShare": {
          "type": "number",
          "minimum": 0
        },
        "ahPerNight": {
          "type": "number",
          "exclusiveMinimum": 0
        }
      },
      "required": [
        "asOf",
        "multiplier",
        "leadShare",
        "ahPerNight"
      ]
    },
    "spent": {
      "type": "object",
      "properties": {
        "leadAH": {
          "type": "number",
          "minimum": 0
        },
        "crewAH": {
          "type": "number",
          "minimum": 0
        },
        "from": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "to": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "source": {
          "type": "string",
          "enum": [
            "transcripts",
            "estimate"
          ]
        }
      },
      "required": [
        "leadAH",
        "crewAH",
        "source"
      ]
    },
    "remaining": {
      "type": "object",
      "properties": {
        "crewAH": {
          "type": "number",
          "minimum": 0
        },
        "p50AH": {
          "type": "number",
          "minimum": 0
        },
        "p80AH": {
          "type": "number",
          "minimum": 0
        },
        "nights": {
          "type": "array",
          "prefixItems": [
            {
              "type": "number",
              "minimum": 0
            },
            {
              "type": "number",
              "minimum": 0
            }
          ],
          "items": false,
          "minItems": 2,
          "maxItems": 2
        }
      },
      "required": [
        "crewAH",
        "p50AH",
        "p80AH",
        "nights"
      ]
    },
    "referenceClass": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "rangeAH": {
          "type": "array",
          "prefixItems": [
            {
              "type": "number",
              "minimum": 0
            },
            {
              "type": "number",
              "minimum": 0
            }
          ],
          "items": false,
          "minItems": 2,
          "maxItems": 2
        },
        "examples": {
          "default": [],
          "type": "array",
          "items": {
            "type": "array",
            "prefixItems": [
              {
                "type": "string"
              },
              {
                "type": "number",
                "minimum": 0
              }
            ],
            "items": false,
            "minItems": 2,
            "maxItems": 2
          }
        }
      },
      "required": [
        "name",
        "rangeAH"
      ]
    },
    "lanes": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "model": {
            "type": "string"
          },
          "briefs": {
            "minItems": 1,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "kind": {
                  "type": "string",
                  "enum": [
                    "build",
                    "fix",
                    "refactor",
                    "asset",
                    "media",
                    "writing",
                    "plan",
                    "research",
                    "review",
                    "ops",
                    "other"
                  ]
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "done",
                    "active",
                    "planned"
                  ]
                },
                "estimateAH": {
                  "type": "number",
                  "minimum": 0
                },
                "actualAH": {
                  "type": "number",
                  "minimum": 0
                },
                "count": {
                  "type": "integer",
                  "exclusiveMinimum": 0,
                  "maximum": 9007199254740991
                },
                "note": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "kind",
                "status"
              ]
            }
          }
        },
        "required": [
          "name",
          "briefs"
        ]
      }
    },
    "risks": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "questions": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "kind",
    "version",
    "project",
    "scope",
    "date",
    "rubric",
    "lanes"
  ]
}
