{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mnstry.app/schemas/atelier-project-config.v1.schema.json",
  "title": "mnstry.atelier-project-config@v1",
  "description": "Portable project adapter config for resolving a workspace, graph inputs, boundaries, and generated Atelier projections. Machine-local paths belong in ignored local overlays.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema"],
  "properties": {
    "schema": {
      "const": "mnstry.atelier-project-config@v1"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "roots": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "workspace": {
          "$ref": "#/$defs/pathString"
        },
        "workspaceRoot": {
          "$ref": "#/$defs/pathString"
        },
        "repoOps": {
          "$ref": "#/$defs/pathString"
        },
        "repoOpsRoot": {
          "$ref": "#/$defs/pathString"
        }
      }
    },
    "graph": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "repoAccessPath": {
          "$ref": "#/$defs/pathString"
        },
        "repoAccessConfig": {
          "$ref": "#/$defs/pathString"
        },
        "outputPath": {
          "$ref": "#/$defs/pathString"
        },
        "workspaceGraphPath": {
          "$ref": "#/$defs/pathString"
        },
        "workspaceGraph": {
          "$ref": "#/$defs/pathString"
        },
        "externalRelationPrefixes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "externalRelationIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "projection": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "outputRoot": {
          "$ref": "#/$defs/pathString"
        },
        "root": {
          "$ref": "#/$defs/pathString"
        },
        "readinessPath": {
          "$ref": "#/$defs/pathString"
        },
        "readiness": {
          "$ref": "#/$defs/pathString"
        }
      }
    },
    "alignment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "appRepo": {
          "type": "string",
          "minLength": 1
        },
        "appRoot": {
          "$ref": "#/$defs/pathString"
        },
        "root": {
          "$ref": "#/$defs/pathString"
        },
        "path": {
          "$ref": "#/$defs/pathString"
        }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "root": {
          "$ref": "#/$defs/pathString"
        },
        "mnstryRuntimeRoot": {
          "$ref": "#/$defs/pathString"
        }
      }
    },
    "boundaries": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "policyPath": {
          "$ref": "#/$defs/pathString"
        },
        "governanceLedgerPath": {
          "$ref": "#/$defs/pathString"
        },
        "strictNewRepos": {
          "type": "boolean"
        }
      }
    },
    "setup": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "profile": {
          "enum": ["single-repo", "private-domain", "shared-project", "multi-repo", "monorepo", "control-workspace"]
        },
        "include": {
          "$ref": "#/$defs/pathString"
        },
        "exclude": {
          "$ref": "#/$defs/pathString"
        }
      }
    },
    "repos": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1
          },
          "path": {
            "$ref": "#/$defs/pathString"
          },
          "readBoundary": {
            "enum": ["private", "team", "operator", "staff", "public", "sensitive"]
          },
          "role": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "description": "Reserved value \"external\" marks a git folder the workspace acknowledges but does not manage: no read boundary is implied, and it is excluded from graph walking, sidecar requirements, projection, and boundary enforcement.",
            "type": "string",
            "minLength": 1
          },
          "remote": {
            "type": "string",
            "minLength": 1
          },
          "identity": {
            "description": "Provider-stable repository identity. Names change and hosting providers redirect the old URL indefinitely, so a name alone cannot tell \"same repo, renamed\" from \"different repo\". Never substitute the root commit: repos created from one template share it.",
            "type": "object",
            "additionalProperties": false,
            "required": ["provider", "id"],
            "properties": {
              "provider": {
                "enum": ["github"]
              },
              "id": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "aliases": {
            "description": "Former names this repo has been known by. Config referencing an old name resolves through these with a deprecation notice.",
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            },
            "uniqueItems": true
          },
          "required": {
            "type": "boolean"
          }
        },
        "allOf": [
          {
            "if": {
              "properties": { "kind": { "const": "external" } },
              "required": ["kind"]
            },
            "then": {
              "not": { "required": ["readBoundary"] }
            }
          }
        ]
      }
    }
  },
  "$defs": {
    "pathString": {
      "type": "string",
      "minLength": 1,
      "not": {
        "anyOf": [
          {
            "pattern": "\\u0000"
          },
          {
            "pattern": "^[a-z][a-z0-9+.-]*:"
          },
          {
            "pattern": "^/"
          }
        ]
      }
    }
  }
}
