{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:source-control-workflow-secret-name-inventory-v1",
  "title": "Source Control Workflow / Runner / Secret Name Inventory v1",
  "description": "定義 GitHub primary cutover 前，AwoooP 需要只讀顯示的 workflow、webhook、runner、deploy key、branch protection、CODEOWNERS 與 secret 名稱 inventory。此契約禁止保存 secret value，也不授權任何 repo 或 refs 動作。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "mode",
    "runtime_execution_authorized",
    "source_indexes",
    "summary",
    "inventory_lanes",
    "repo_inventory_readiness",
    "inventory_rules",
    "forbidden_actions"
  ],
  "properties": {
    "schema_version": {
      "const": "source_control_workflow_secret_name_inventory_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft_missing_evidence"]
    },
    "date": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["inventory_contract_only"]
    },
    "runtime_execution_authorized": {
      "type": "boolean",
      "const": false
    },
    "source_indexes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "summary": {
      "type": "object",
      "required": [
        "candidate_repo_count",
        "in_scope_repo_count",
        "external_scope_count",
        "inventory_complete_count",
        "missing_inventory_count",
        "secret_value_collection_allowed",
        "runtime_actions_authorized",
        "action_buttons_allowed"
      ],
      "properties": {
        "candidate_repo_count": {
          "type": "integer",
          "minimum": 0
        },
        "in_scope_repo_count": {
          "type": "integer",
          "minimum": 0
        },
        "external_scope_count": {
          "type": "integer",
          "minimum": 0
        },
        "inventory_complete_count": {
          "type": "integer",
          "minimum": 0
        },
        "missing_inventory_count": {
          "type": "integer",
          "minimum": 0
        },
        "secret_value_collection_allowed": {
          "type": "boolean",
          "const": false
        },
        "runtime_actions_authorized": {
          "type": "boolean",
          "const": false
        },
        "action_buttons_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    },
    "inventory_lanes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "lane_id",
          "title",
          "status",
          "allowed_fields",
          "forbidden_fields",
          "required_before_primary",
          "execution_authorized"
        ],
        "properties": {
          "lane_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["missing_evidence", "contract_defined_not_collected"]
          },
          "allowed_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "forbidden_fields": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "required_before_primary": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "execution_authorized": {
            "type": "boolean",
            "const": false
          }
        },
        "additionalProperties": false
      }
    },
    "repo_inventory_readiness": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "github_repo",
          "source_key",
          "scope_status",
          "inventory_state",
          "risk",
          "required_inventory",
          "current_gap",
          "allowed_now",
          "still_forbidden"
        ],
        "properties": {
          "github_repo": {
            "type": "string"
          },
          "source_key": {
            "type": "string"
          },
          "scope_status": {
            "type": "string",
            "enum": ["in_scope", "external_scope_review"]
          },
          "inventory_state": {
            "type": "string",
            "enum": ["missing_evidence", "scope_review_only"]
          },
          "risk": {
            "type": "string",
            "enum": ["LOW", "MEDIUM", "HIGH"]
          },
          "required_inventory": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "current_gap": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "allowed_now": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "still_forbidden": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          }
        },
        "additionalProperties": false
      }
    },
    "inventory_rules": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "forbidden_actions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    }
  },
  "additionalProperties": false
}
