{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:source-control-workflow-secret-name-local-evidence-v1",
  "title": "Source Control Workflow / Secret Name Local Evidence v1",
  "description": "定義本機 working tree 只讀萃取出的 workflow / runner label / CODEOWNERS / secret 名稱 evidence。此 schema 僅允許名稱與 metadata，不允許 secret value。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "mode",
    "runtime_execution_authorized",
    "source_contract",
    "summary",
    "unique_secret_names",
    "runner_label_names",
    "repos",
    "redaction_rules",
    "forbidden_actions"
  ],
  "properties": {
    "schema_version": {
      "const": "source_control_workflow_secret_name_local_evidence_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft_partial_local_evidence"]
    },
    "date": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["local_read_only_redacted_inventory"]
    },
    "runtime_execution_authorized": {
      "type": "boolean",
      "const": false
    },
    "source_contract": {
      "type": "string",
      "const": "source_control_workflow_secret_name_inventory_v1"
    },
    "summary": {
      "type": "object",
      "required": [
        "candidate_repo_count",
        "local_repo_visible_count",
        "local_evidence_repo_count",
        "workflow_file_count",
        "gitea_workflow_file_count",
        "github_workflow_file_count",
        "codeowners_file_count",
        "unique_secret_name_count",
        "runner_label_count",
        "secret_value_collection_allowed",
        "secret_value_detected",
        "runtime_actions_authorized",
        "action_buttons_allowed"
      ],
      "properties": {
        "candidate_repo_count": {"type": "integer", "minimum": 0},
        "local_repo_visible_count": {"type": "integer", "minimum": 0},
        "local_evidence_repo_count": {"type": "integer", "minimum": 0},
        "workflow_file_count": {"type": "integer", "minimum": 0},
        "gitea_workflow_file_count": {"type": "integer", "minimum": 0},
        "github_workflow_file_count": {"type": "integer", "minimum": 0},
        "codeowners_file_count": {"type": "integer", "minimum": 0},
        "unique_secret_name_count": {"type": "integer", "minimum": 0},
        "runner_label_count": {"type": "integer", "minimum": 0},
        "secret_value_collection_allowed": {"type": "boolean", "const": false},
        "secret_value_detected": {"type": "boolean", "const": false},
        "runtime_actions_authorized": {"type": "boolean", "const": false},
        "action_buttons_allowed": {"type": "boolean", "const": false}
      },
      "additionalProperties": false
    },
    "unique_secret_names": {
      "type": "array",
      "items": {"type": "string"}
    },
    "runner_label_names": {
      "type": "array",
      "items": {"type": "string"}
    },
    "repos": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "repo_key",
          "repo_path",
          "github_repo",
          "source_key",
          "scope_status",
          "risk",
          "local_status",
          "workflow_files",
          "codeowners_files",
          "referenced_secret_names",
          "runner_label_names",
          "environment_names",
          "api_required_lanes",
          "still_forbidden"
        ],
        "properties": {
          "repo_key": {"type": "string"},
          "repo_path": {"type": "string"},
          "github_repo": {"type": "string"},
          "source_key": {"type": "string"},
          "scope_status": {
            "type": "string",
            "enum": ["in_scope", "external_scope_review"]
          },
          "risk": {
            "type": "string",
            "enum": ["LOW", "MEDIUM", "HIGH"]
          },
          "local_status": {
            "type": "string",
            "enum": [
              "partial_local_evidence",
              "local_repo_visible_no_workflow_files",
              "missing_local_repo"
            ]
          },
          "workflow_files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "provider",
                "workflow_file_path",
                "workflow_display_name",
                "trigger_names",
                "runner_label_names",
                "environment_names",
                "referenced_secret_names"
              ],
              "properties": {
                "provider": {
                  "type": "string",
                  "enum": ["gitea", "github", "unknown"]
                },
                "workflow_file_path": {"type": "string"},
                "workflow_display_name": {"type": "string"},
                "trigger_names": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "runner_label_names": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "environment_names": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "referenced_secret_names": {
                  "type": "array",
                  "items": {"type": "string"}
                }
              },
              "additionalProperties": false
            }
          },
          "codeowners_files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "codeowners_path",
                "owner_tokens",
                "owner_token_count"
              ],
              "properties": {
                "codeowners_path": {"type": "string"},
                "owner_tokens": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "owner_token_count": {"type": "integer", "minimum": 0}
              },
              "additionalProperties": false
            }
          },
          "referenced_secret_names": {
            "type": "array",
            "items": {"type": "string"}
          },
          "runner_label_names": {
            "type": "array",
            "items": {"type": "string"}
          },
          "environment_names": {
            "type": "array",
            "items": {"type": "string"}
          },
          "api_required_lanes": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          },
          "still_forbidden": {
            "type": "array",
            "items": {"type": "string"},
            "minItems": 1
          }
        },
        "additionalProperties": false
      }
    },
    "redaction_rules": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    },
    "forbidden_actions": {
      "type": "array",
      "items": {"type": "string"},
      "minItems": 1
    }
  },
  "additionalProperties": false
}
