{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://opentine.com/schemas/opentine-project-1.schema.json",
  "title": "opentine.project (project_version 1)",
  "description": "One version of a project manifest (SPEC 4.16): binds a tenant to its code slots. `prev` is the previous version's blob-oid digest (null for seq 0); `signature` is an Ed25519 tine-sig/3 block by an owner of the previous version, over `opentine.project.v1:` + JCS({body, header}). A private project names its upstreams by commitment only.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "kind",
    "project_version",
    "project_id",
    "tenant",
    "seq",
    "prev",
    "visibility",
    "owners",
    "slots",
    "forked_from",
    "created_at",
    "signature"
  ],
  "properties": {
    "kind": {
      "const": "opentine.project"
    },
    "project_version": {
      "const": 1
    },
    "project_id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
    },
    "tenant": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$"
    },
    "seq": {
      "type": "integer",
      "minimum": 0
    },
    "prev": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^blob:sha256:[0-9a-f]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "visibility": {
      "enum": [
        "public",
        "private"
      ]
    },
    "owners": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
      },
      "minItems": 1,
      "maxItems": 16
    },
    "slots": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role",
          "forge",
          "forge_repo_id",
          "upstream_visibility",
          "locator",
          "default_branch"
        ],
        "properties": {
          "role": {
            "enum": [
              "primary",
              "secondary"
            ]
          },
          "forge": {
            "enum": [
              "github",
              "gitlab",
              "forgejo",
              "git",
              "entire"
            ]
          },
          "forge_repo_id": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^[A-Za-z0-9_.:/-]{1,128}$"
              },
              {
                "type": "null"
              }
            ]
          },
          "upstream_visibility": {
            "enum": [
              "public",
              "private"
            ]
          },
          "locator": {
            "anyOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "pattern": "^(https://|ssh://|git@)",
                    "maxLength": 2048
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "commitment"
                ],
                "properties": {
                  "commitment": {
                    "type": "string",
                    "pattern": "^sha256:[0-9a-f]{64}$"
                  }
                }
              }
            ]
          },
          "default_branch": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._/-]{1,255}$"
          }
        }
      },
      "minItems": 1,
      "maxItems": 2
    },
    "forked_from": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "signature": {
      "$ref": "tine-sig-3.schema.json"
    }
  }
}
