{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "const": "dev-hub.plan"
    },
    "schemaVersion": {
      "type": "number",
      "const": 1
    },
    "revisionOf": {
      "type": "object",
      "properties": {
        "projectId": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "projectVersion": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "planFingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "required": [
        "projectId",
        "projectVersion",
        "planFingerprint"
      ],
      "additionalProperties": false
    },
    "project": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "minLength": 3,
          "maxLength": 100
        },
        "brief": {
          "type": "string",
          "minLength": 30,
          "maxLength": 8000
        },
        "workType": {
          "type": "string",
          "enum": [
            "new",
            "improvement"
          ]
        },
        "platforms": {
          "minItems": 1,
          "maxItems": 5,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "website",
              "web-app",
              "android",
              "ios",
              "backend-api"
            ]
          }
        },
        "mobileCodebase": {
          "type": "string",
          "enum": [
            "shared",
            "separate"
          ]
        },
        "launchStrategy": {
          "type": "string",
          "enum": [
            "together",
            "staggered"
          ]
        },
        "launchOrder": {
          "minItems": 1,
          "maxItems": 5,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "website",
              "web-app",
              "android",
              "ios",
              "backend-api"
            ]
          }
        },
        "startDate": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            {
              "type": "string",
              "const": ""
            }
          ]
        },
        "targetDate": {
          "anyOf": [
            {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            {
              "type": "string",
              "const": ""
            }
          ]
        },
        "holidays": {
          "maxItems": 120,
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          }
        },
        "repositoryUrl": {
          "type": "string",
          "maxLength": 240
        }
      },
      "required": [
        "title",
        "brief",
        "workType",
        "platforms",
        "mobileCodebase",
        "launchStrategy",
        "launchOrder",
        "startDate",
        "targetDate",
        "holidays",
        "repositoryUrl"
      ],
      "additionalProperties": false
    },
    "features": {
      "minItems": 1,
      "maxItems": 200,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$"
          },
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 160
          },
          "module": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "minLength": 5,
            "maxLength": 2400
          },
          "priority": {
            "type": "string",
            "enum": [
              "must",
              "should",
              "later"
            ]
          },
          "scope": {
            "type": "string",
            "enum": [
              "included",
              "later",
              "excluded"
            ]
          },
          "platformWork": {
            "minItems": 1,
            "maxItems": 5,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "platform": {
                  "type": "string",
                  "enum": [
                    "website",
                    "web-app",
                    "android",
                    "ios",
                    "backend-api"
                  ]
                },
                "intent": {
                  "type": "string",
                  "enum": [
                    "build",
                    "complete",
                    "fix",
                    "verify",
                    "none"
                  ]
                },
                "gaps": {
                  "maxItems": 30,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 600
                  }
                }
              },
              "required": [
                "platform",
                "intent",
                "gaps"
              ],
              "additionalProperties": false
            }
          },
          "requirements": {
            "maxItems": 30,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 3,
              "maxLength": 600
            }
          },
          "userFlow": {
            "maxItems": 30,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 3,
              "maxLength": 600
            }
          },
          "acceptanceCriteria": {
            "minItems": 1,
            "maxItems": 8,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 5,
              "maxLength": 300
            }
          },
          "dependencies": {
            "maxItems": 200,
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence": {
            "maxItems": 30,
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 3,
              "maxLength": 600
            }
          }
        },
        "required": [
          "id",
          "name",
          "module",
          "description",
          "priority",
          "scope",
          "platformWork",
          "requirements",
          "userFlow",
          "acceptanceCriteria",
          "dependencies",
          "evidence"
        ],
        "additionalProperties": false
      }
    },
    "risks": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 3,
        "maxLength": 600
      }
    },
    "questions": {
      "maxItems": 30,
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 3,
        "maxLength": 600
      }
    },
    "plan": {
      "type": "object",
      "properties": {
        "summary": {
          "type": "string",
          "minLength": 10,
          "maxLength": 1600
        },
        "assumptions": {
          "maxItems": 16,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string",
                "minLength": 5,
                "maxLength": 400
              },
              "blocking": {
                "type": "boolean"
              }
            },
            "required": [
              "text",
              "blocking"
            ],
            "additionalProperties": false
          }
        },
        "milestones": {
          "minItems": 2,
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 80
              },
              "title": {
                "type": "string",
                "minLength": 3,
                "maxLength": 120
              },
              "description": {
                "type": "string",
                "minLength": 5,
                "maxLength": 600
              },
              "phase": {
                "type": "string",
                "enum": [
                  "scope",
                  "design",
                  "build",
                  "quality",
                  "release"
                ]
              },
              "platforms": {
                "minItems": 1,
                "maxItems": 5,
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "website",
                    "web-app",
                    "android",
                    "ios",
                    "backend-api"
                  ]
                }
              },
              "dependsOnMilestones": {
                "maxItems": 20,
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "deliverables": {
                "minItems": 1,
                "maxItems": 12,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 80
                    },
                    "title": {
                      "type": "string",
                      "minLength": 2,
                      "maxLength": 160
                    },
                    "platforms": {
                      "minItems": 1,
                      "maxItems": 5,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "website",
                          "web-app",
                          "android",
                          "ios",
                          "backend-api"
                        ]
                      }
                    },
                    "checks": {
                      "minItems": 1,
                      "maxItems": 8,
                      "type": "array",
                      "items": {
                        "type": "string",
                        "minLength": 5,
                        "maxLength": 300
                      }
                    },
                    "tasks": {
                      "minItems": 1,
                      "maxItems": 12,
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 80
                          },
                          "title": {
                            "type": "string",
                            "minLength": 3,
                            "maxLength": 160
                          },
                          "description": {
                            "type": "string",
                            "minLength": 5,
                            "maxLength": 1800
                          },
                          "skill": {
                            "type": "string",
                            "enum": [
                              "lead",
                              "design",
                              "frontend",
                              "backend",
                              "qa",
                              "any"
                            ]
                          },
                          "lowHours": {
                            "type": "number",
                            "minimum": 0.5,
                            "maximum": 160
                          },
                          "highHours": {
                            "type": "number",
                            "minimum": 0.5,
                            "maximum": 240
                          },
                          "dependsOn": {
                            "maxItems": 80,
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "required": [
                          "id",
                          "title",
                          "description",
                          "skill",
                          "lowHours",
                          "highHours",
                          "dependsOn"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "featureIds": {
                      "maxItems": 200,
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "id",
                    "title",
                    "platforms",
                    "checks",
                    "tasks",
                    "featureIds"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "id",
              "title",
              "description",
              "phase",
              "platforms",
              "dependsOnMilestones",
              "deliverables"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "summary",
        "assumptions",
        "milestones"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "format",
    "schemaVersion",
    "project",
    "features",
    "risks",
    "questions",
    "plan"
  ],
  "additionalProperties": false
}