{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://bt6.dev/schemas/bt6-maintainer-profile.v1.json",
  "title": "BT6 Maintainer Repository Profile",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "project", "repository", "delivery", "validation"],
  "properties": {
    "version": { "const": "1" },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "displayName", "family"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
        "displayName": { "type": "string", "minLength": 1 },
        "family": {
          "enum": [
            "research-tool",
            "support-tool",
            "knowledge-tool",
            "application",
            "library",
            "service",
            "data-pipeline",
            "automation",
            "infrastructure",
            "mixed"
          ]
        }
      }
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": ["canonicalRemote", "baseBranch"],
      "properties": {
        "canonicalRemote": { "type": "string", "minLength": 1 },
        "baseBranch": { "type": "string", "minLength": 1 },
        "expectedSlug": { "type": "string", "minLength": 1 },
        "ciRemote": { "type": "string", "minLength": 1 }
      }
    },
    "tracker": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "authorityRemote": { "type": "string", "minLength": 1 },
        "provider": { "enum": ["github", "gitea", "local", "auto"] },
        "expectedActor": { "type": "string", "minLength": 1 }
      }
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": ["requireCiGreen", "requireCurrentHead", "defaultMergeMethod"],
      "properties": {
        "requireCiGreen": { "const": true },
        "requireCurrentHead": { "const": true },
        "defaultMergeMethod": { "enum": ["squash", "merge", "rebase"] },
        "allowedMergeMethods": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": { "enum": ["squash", "merge", "rebase"] }
        }
      }
    },
    "validation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["quick", "full"],
      "properties": {
        "quick": {
          "description": "Fast core-system commands required for pull requests.",
          "$ref": "#/$defs/commands"
        },
        "full": {
          "description": "Exhaustive commands required for tagged-release validation, not ordinary pull requests.",
          "$ref": "#/$defs/commands"
        },
        "qualityPolicy": {
          "type": "object",
          "description": "Optional explicit restatement of the shared BT6 quality defaults; values cannot weaken them.",
          "additionalProperties": false,
          "required": [
            "pullRequestChangedLineCoverageFloor",
            "requireBehaviorTests",
            "fullSuiteTrigger"
          ],
          "properties": {
            "pullRequestChangedLineCoverageFloor": { "const": 50 },
            "requireBehaviorTests": { "const": true },
            "fullSuiteTrigger": { "const": "tagged-release" }
          }
        },
        "documentation": { "$ref": "#/$defs/commands" },
        "researchIntegrity": { "$ref": "#/$defs/commands" }
      }
    },
    "riskSurfaces": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "paths", "concerns"],
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
          "paths": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
          "concerns": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
          "requiredChecks": { "$ref": "#/$defs/commands" }
        }
      }
    },
    "research": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "corpusPaths": { "$ref": "#/$defs/paths" },
        "evidencePaths": { "$ref": "#/$defs/paths" },
        "provenanceRequired": { "type": "boolean" },
        "citationVerificationRequired": { "type": "boolean" }
      }
    },
    "security": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "disclosureUrl": { "type": "string", "format": "uri" },
        "sensitiveDataPaths": { "$ref": "#/$defs/paths" },
        "mutationRequiresExplicitApproval": { "const": true }
      }
    },
    "support": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "requiredEnvironmentFields": { "type": "array", "uniqueItems": true, "items": { "type": "string" } },
        "translationPolicy": { "enum": ["validated-only", "draft-with-disclosure", "project-defined"] }
      }
    }
  },
  "$defs": {
    "commands": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "minLength": 1 }
    },
    "paths": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    }
  }
}
