{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://state-hub.coulomb.social/schemas/repository-rename-handoff-v1.schema.json",
  "title": "State Hub repository rename handoff v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "handoff_id",
    "operation_id",
    "renamed_repository_id",
    "source_repository",
    "old_slug",
    "new_slug",
    "surface",
    "affected",
    "required_reingest",
    "verification",
    "owning_work_record",
    "status",
    "evidence",
    "sensitive_data_prohibited"
  ],
  "properties": {
    "schema_version": {
      "const": "state-hub.repository-rename-handoff.v1"
    },
    "handoff_id": {
      "type": "string",
      "minLength": 1,
      "description": "Canonical live task or intake record ID in the owning repository."
    },
    "operation_id": {
      "type": "string",
      "format": "uuid"
    },
    "renamed_repository_id": {
      "type": "string",
      "format": "uuid"
    },
    "source_repository": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$",
      "description": "Repository that owns the slug-bearing source to change or re-ingest."
    },
    "old_slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "new_slug": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9-]*$"
    },
    "surface": {
      "enum": [
        "fabric-projection",
        "ci",
        "package",
        "deployment",
        "credential-route",
        "policy",
        "sbom",
        "documentation",
        "consumer",
        "other"
      ]
    },
    "affected": {
      "type": "object",
      "additionalProperties": false,
      "required": ["paths", "graph_ids"],
      "properties": {
        "paths": {
          "type": "array",
          "items": {"type": "string", "minLength": 1},
          "uniqueItems": true
        },
        "graph_ids": {
          "type": "array",
          "items": {"type": "string", "minLength": 1},
          "uniqueItems": true
        }
      },
      "anyOf": [
        {"properties": {"paths": {"minItems": 1}}},
        {"properties": {"graph_ids": {"minItems": 1}}}
      ]
    },
    "required_reingest": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required", "procedure"],
      "properties": {
        "required": {"type": "boolean"},
        "procedure": {"type": "string", "minLength": 1},
        "expected_source_revision": {"type": ["string", "null"]}
      }
    },
    "verification": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["check", "expected", "evidence_ref"],
        "properties": {
          "check": {"type": "string", "minLength": 1},
          "expected": {"type": "string", "minLength": 1},
          "evidence_ref": {"type": ["string", "null"]}
        }
      }
    },
    "owning_work_record": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "workplan_id", "task_id"],
      "properties": {
        "repository": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]*$"
        },
        "workplan_id": {"type": "string", "minLength": 1},
        "task_id": {"type": "string", "minLength": 1}
      }
    },
    "status": {
      "enum": ["open", "acknowledged", "verified", "cancelled"]
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["kind", "ref"],
        "properties": {
          "kind": {
            "enum": [
              "commit",
              "progress-event",
              "decision",
              "test-report",
              "deployment-observation",
              "reingest-receipt",
              "other"
            ]
          },
          "ref": {"type": "string", "minLength": 1},
          "checksum": {
            "type": ["string", "null"],
            "pattern": "^[a-fA-F0-9]{64}$"
          }
        }
      }
    },
    "sensitive_data_prohibited": {
      "const": true,
      "description": "Evidence contains references and checksums only, never credentials or secret values."
    }
  }
}
