{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:gitea-inventory-coverage-attestation-v1",
  "title": "Gitea 清冊覆蓋 Owner Attestation 契約 v1",
  "description": "定義 Gitea public-only evidence、local remote evidence、org/user endpoint identity 與 internal 110 adjacent source 的 owner coverage attestation。此 schema 不授權 token 收集、Gitea/GitHub 寫入、refs sync 或 GitHub primary cutover。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "mode",
    "runtime_execution_authorized",
    "source_contract",
    "source_request_contracts",
    "source_indexes",
    "summary",
    "attestation_items",
    "decision_values",
    "allowed_outputs",
    "forbidden_actions"
  ],
  "properties": {
    "schema_version": {
      "const": "gitea_inventory_coverage_attestation_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft_waiting_owner_attestation"]
    },
    "date": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["coverage_attestation_only"]
    },
    "runtime_execution_authorized": {
      "type": "boolean",
      "const": false
    },
    "source_contract": {
      "type": "string",
      "const": "gitea_repo_inventory_v1"
    },
    "source_request_contracts": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "gitea_authenticated_inventory_export_request_v1",
          "gitea_authenticated_inventory_import_acceptance_v1"
        ]
      },
      "minItems": 2
    },
    "source_indexes": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "summary": {
      "type": "object",
      "required": [
        "owner_attestation_status",
        "required_attestation_item_count",
        "received_attestation_count",
        "accepted_attestation_count",
        "rejected_attestation_count",
        "public_only_repo_count",
        "local_gitea_unique_repo_count",
        "local_gitea_gap_count",
        "internal_110_adjacent_source_count",
        "owner_scope_decision_required",
        "token_value_collection_allowed",
        "repo_write_allowed",
        "refs_sync_allowed",
        "github_primary_switch_authorized",
        "action_buttons_allowed"
      ],
      "properties": {
        "owner_attestation_status": {
          "type": "string",
          "enum": ["waiting_owner_attestation"]
        },
        "required_attestation_item_count": {"type": "integer", "minimum": 0},
        "received_attestation_count": {"type": "integer", "minimum": 0},
        "accepted_attestation_count": {"type": "integer", "minimum": 0},
        "rejected_attestation_count": {"type": "integer", "minimum": 0},
        "public_only_repo_count": {"type": "integer", "minimum": 0},
        "local_gitea_unique_repo_count": {"type": "integer", "minimum": 0},
        "local_gitea_gap_count": {"type": "integer", "minimum": 0},
        "internal_110_adjacent_source_count": {"type": "integer", "minimum": 0},
        "owner_scope_decision_required": {
          "type": "boolean",
          "const": true
        },
        "token_value_collection_allowed": {
          "type": "boolean",
          "const": false
        },
        "repo_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "refs_sync_allowed": {
          "type": "boolean",
          "const": false
        },
        "github_primary_switch_authorized": {
          "type": "boolean",
          "const": false
        },
        "action_buttons_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    },
    "attestation_items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "item_id",
          "title",
          "why_required",
          "current_evidence_gap",
          "requested_owner_decision",
          "acceptable_decisions",
          "minimum_evidence_refs",
          "received_decision",
          "accepted",
          "execution_authorized"
        ],
        "properties": {
          "item_id": {"type": "string"},
          "title": {"type": "string"},
          "why_required": {"type": "string"},
          "current_evidence_gap": {"type": "string"},
          "requested_owner_decision": {"type": "string"},
          "acceptable_decisions": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          },
          "minimum_evidence_refs": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          },
          "received_decision": {
            "type": ["string", "null"]
          },
          "accepted": {
            "type": "boolean",
            "const": false
          },
          "execution_authorized": {
            "type": "boolean",
            "const": false
          }
        },
        "additionalProperties": false
      },
      "minItems": 1
    },
    "decision_values": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "value",
          "meaning",
          "allowed_effect",
          "execution_authorized"
        ],
        "properties": {
          "value": {"type": "string"},
          "meaning": {"type": "string"},
          "allowed_effect": {"type": "string"},
          "execution_authorized": {
            "type": "boolean",
            "const": false
          }
        },
        "additionalProperties": false
      },
      "minItems": 1
    },
    "allowed_outputs": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "forbidden_actions": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    }
  },
  "additionalProperties": false
}
