{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:source-control-ref-truth-classification-v1",
  "title": "AWOOOI Source Control Ref Truth Classification (v1)",
  "description": "將 Gitea / GitHub branch/tag read-only diff 轉成真相來源候選與人工審核分類；不授權 refs sync。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "default_mode",
    "source_snapshot",
    "summary",
    "still_forbidden",
    "repos"
  ],
  "properties": {
    "schema_version": {
      "const": "source_control_ref_truth_classification_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft_blocked"]
    },
    "date": {
      "type": "string"
    },
    "default_mode": {
      "type": "string",
      "enum": ["classification_only"]
    },
    "source_snapshot": {
      "type": "string"
    },
    "summary": {
      "type": "object",
      "required": [
        "repo_count",
        "total_items",
        "manual_truth_required_count",
        "deprecated_candidate_count",
        "release_tag_review_count",
        "github_only_review_count"
      ],
      "properties": {
        "repo_count": {"type": "integer", "minimum": 0},
        "total_items": {"type": "integer", "minimum": 0},
        "manual_truth_required_count": {"type": "integer", "minimum": 0},
        "deprecated_candidate_count": {"type": "integer", "minimum": 0},
        "release_tag_review_count": {"type": "integer", "minimum": 0},
        "github_only_review_count": {"type": "integer", "minimum": 0}
      },
      "additionalProperties": false
    },
    "still_forbidden": {
      "type": "array",
      "items": {"type": "string"}
    },
    "repos": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "gitea_repo",
          "github_repo",
          "risk",
          "awooop_consumption",
          "item_count",
          "items"
        ],
        "properties": {
          "gitea_repo": {"type": "string"},
          "github_repo": {"type": "string"},
          "risk": {
            "type": "string",
            "enum": ["LOW", "MEDIUM", "HIGH"]
          },
          "awooop_consumption": {
            "type": "string",
            "enum": ["mirror_only", "approval_candidate"]
          },
          "item_count": {"type": "integer", "minimum": 0},
          "items": {
            "type": "array",
            "items": {"$ref": "#/$defs/classificationItem"}
          }
        },
        "additionalProperties": false
      }
    }
  },
  "$defs": {
    "classificationItem": {
      "type": "object",
      "required": [
        "ref_type",
        "ref_name",
        "lane",
        "risk",
        "proposed_truth_source",
        "classification",
        "reason",
        "next_review",
        "gitea_sha",
        "github_sha",
        "allowed_now",
        "forbidden_actions"
      ],
      "properties": {
        "ref_type": {
          "type": "string",
          "enum": ["branch", "tag"]
        },
        "ref_name": {"type": "string"},
        "lane": {
          "type": "string",
          "enum": [
            "main_truth_required",
            "active_branch_truth_required",
            "archive_or_deprecate_candidate",
            "release_tag_missing_on_github",
            "github_only_manual_review",
            "github_only_uat_tag",
            "manual_review"
          ]
        },
        "risk": {
          "type": "string",
          "enum": ["LOW", "MEDIUM", "HIGH"]
        },
        "proposed_truth_source": {
          "type": "string",
          "enum": ["gitea", "github", "manual_required", "deprecated_candidate"]
        },
        "classification": {
          "type": "string",
          "enum": [
            "manual_truth_required",
            "manual_review_deprecated_candidate",
            "manual_review_release_tag",
            "manual_review_github_only",
            "manual_review"
          ]
        },
        "reason": {"type": "string"},
        "next_review": {"type": "string"},
        "gitea_sha": {"type": "string"},
        "github_sha": {"type": "string"},
        "allowed_now": {
          "type": "array",
          "items": {"type": "string"}
        },
        "forbidden_actions": {
          "type": "array",
          "items": {"type": "string"}
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
