{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:security-approval-decision-record-v1",
  "title": "資安供應鏈人工決策紀錄契約 v1",
  "description": "定義 AwoooP 如何保存 Security Supply Chain 人工批准、拒絕、延後、補 evidence 或維持 blocked 的稽核紀錄。此契約不授權 runtime execution。",
  "type": "object",
  "required": [
    "schema_version",
    "status",
    "date",
    "mode",
    "runtime_execution_authorized",
    "source_indexes",
    "summary",
    "decision_records",
    "recording_rules",
    "forbidden_actions"
  ],
  "properties": {
    "schema_version": {
      "const": "security_approval_decision_record_v1"
    },
    "status": {
      "type": "string",
      "enum": ["draft"]
    },
    "date": {
      "type": "string"
    },
    "mode": {
      "type": "string",
      "enum": ["decision_record_only"]
    },
    "runtime_execution_authorized": {
      "type": "boolean",
      "const": false
    },
    "source_indexes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "summary": {
      "type": "object",
      "required": [
        "total_decision_records",
        "approve_scope_count",
        "reject_count",
        "defer_count",
        "request_more_evidence_count",
        "keep_blocked_count",
        "pending_runtime_gate_count",
        "runtime_actions_authorized",
        "raw_secret_storage_authorized"
      ],
      "properties": {
        "total_decision_records": {
          "type": "integer",
          "minimum": 0
        },
        "approve_scope_count": {
          "type": "integer",
          "minimum": 0
        },
        "reject_count": {
          "type": "integer",
          "minimum": 0
        },
        "defer_count": {
          "type": "integer",
          "minimum": 0
        },
        "request_more_evidence_count": {
          "type": "integer",
          "minimum": 0
        },
        "keep_blocked_count": {
          "type": "integer",
          "minimum": 0
        },
        "pending_runtime_gate_count": {
          "type": "integer",
          "minimum": 0
        },
        "runtime_actions_authorized": {
          "type": "boolean",
          "const": false
        },
        "raw_secret_storage_authorized": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    },
    "decision_records": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "record_id",
          "gate_id",
          "source_queue_item_id",
          "decision",
          "decided_by",
          "decided_at",
          "approved_scope",
          "evidence_refs",
          "execution_authorized",
          "followup_runtime_gate_required",
          "notes"
        ],
        "properties": {
          "record_id": {
            "type": "string"
          },
          "gate_id": {
            "type": "string"
          },
          "source_queue_item_id": {
            "type": "string"
          },
          "decision": {
            "type": "string",
            "enum": ["approve_scope", "reject", "defer", "request_more_evidence", "keep_blocked"]
          },
          "decided_by": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "decided_at": {
            "type": "string"
          },
          "approved_scope": {
            "type": "string",
            "enum": [
              "none",
              "design_or_draft_only",
              "read_only_inventory_only",
              "low_noise_scan_scope_only",
              "manual_exception_only",
              "blocked_by_default"
            ]
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "execution_authorized": {
            "type": "boolean",
            "const": false
          },
          "followup_runtime_gate_required": {
            "type": "boolean",
            "const": true
          },
          "notes": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "recording_rules": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    },
    "forbidden_actions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1
    }
  },
  "additionalProperties": false
}
