{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:ai-agent-low-medium-risk-whitelist-v1",
  "title": "AWOOOI AI Agent low and medium risk whitelist v1",
  "description": "P2-408 將 P2-407 no-write 分析建議轉成中 / 低風險候選白名單、dry-run verifier、rollback proof 與 audit reason。此 schema 只允許 committed snapshot / governance UI 呈現，不授權 live auto worker、Gateway queue 寫入、Telegram 實發、Bot API、receipt production write、production write、secret 讀取、付費 API、host write、kubectl 或不可逆操作。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "source_readbacks",
    "whitelist_truth",
    "whitelist_candidates",
    "dry_run_verifiers",
    "rollback_proofs",
    "audit_reason_templates",
    "high_risk_redirects",
    "owner_review_gates",
    "activation_boundaries",
    "telegram_policy",
    "display_redaction_contract",
    "rollups",
    "next_actions"
  ],
  "properties": {
    "schema_version": { "type": "string", "const": "ai_agent_low_medium_risk_whitelist_v1" },
    "generated_at": { "type": "string", "minLength": 1 },
    "program_status": {
      "type": "object",
      "required": [
        "overall_completion_percent",
        "current_priority",
        "current_task_id",
        "next_task_id",
        "read_only_mode",
        "runtime_authority",
        "status_note"
      ],
      "properties": {
        "overall_completion_percent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "current_priority": { "type": "string", "enum": ["P0", "P1", "P2", "P3"] },
        "current_task_id": { "type": "string", "const": "P2-408" },
        "next_task_id": { "type": "string", "const": "P2-409" },
        "read_only_mode": { "type": "boolean", "const": true },
        "runtime_authority": { "type": "string", "const": "low_medium_risk_whitelist_no_live_execution_committed_snapshot" },
        "status_note": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "source_refs": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
    "source_readbacks": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/source_readback" } },
    "whitelist_truth": { "type": "object", "additionalProperties": { "type": ["boolean", "integer", "string"] } },
    "whitelist_candidates": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/whitelist_candidate" } },
    "dry_run_verifiers": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/dry_run_verifier" } },
    "rollback_proofs": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/rollback_proof" } },
    "audit_reason_templates": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/audit_reason_template" } },
    "high_risk_redirects": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/high_risk_redirect" } },
    "owner_review_gates": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/owner_review_gate" } },
    "activation_boundaries": { "type": "object", "additionalProperties": { "type": "boolean" } },
    "telegram_policy": {
      "type": "object",
      "required": [
        "canonical_room",
        "canonical_room_env",
        "gateway_queue_write_allowed",
        "direct_bot_api_allowed",
        "telegram_send_allowed",
        "receipt_write_allowed"
      ],
      "properties": {
        "canonical_room": { "type": "string", "const": "AwoooI SRE 戰情室" },
        "canonical_room_env": { "type": "string", "const": "SRE_GROUP_CHAT_ID" },
        "gateway_queue_write_allowed": { "type": "boolean", "const": false },
        "direct_bot_api_allowed": { "type": "boolean", "const": false },
        "telegram_send_allowed": { "type": "boolean", "const": false },
        "receipt_write_allowed": { "type": "boolean", "const": false }
      },
      "additionalProperties": true
    },
    "display_redaction_contract": {
      "type": "object",
      "required": [
        "redaction_required",
        "unsafe_payload_display_allowed",
        "private_reasoning_display_allowed",
        "secret_value_display_allowed",
        "work_window_transcript_display_allowed",
        "allowed_display_fields",
        "blocked_display_fields"
      ],
      "properties": {
        "redaction_required": { "type": "boolean", "const": true },
        "unsafe_payload_display_allowed": { "type": "boolean", "const": false },
        "private_reasoning_display_allowed": { "type": "boolean", "const": false },
        "secret_value_display_allowed": { "type": "boolean", "const": false },
        "work_window_transcript_display_allowed": { "type": "boolean", "const": false },
        "allowed_display_fields": { "type": "array", "items": { "type": "string" } },
        "blocked_display_fields": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "rollups": { "type": "object", "additionalProperties": { "type": ["integer", "array"] } },
    "next_actions": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/next_action" } }
  },
  "additionalProperties": false,
  "$defs": {
    "source_readback": {
      "type": "object",
      "required": ["readback_id", "source_schema_version", "source_ref", "endpoint", "owner_agent", "status", "key_readback", "next_action"],
      "properties": {
        "readback_id": { "type": "string", "minLength": 1 },
        "source_schema_version": { "type": "string", "minLength": 1 },
        "source_ref": { "type": "string", "minLength": 1 },
        "endpoint": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "status": { "type": "string", "minLength": 1 },
        "key_readback": { "type": "string", "minLength": 1 },
        "next_action": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "whitelist_candidate": {
      "type": "object",
      "required": ["candidate_id", "display_name", "risk_tier", "owner_agent", "whitelist_status", "allowed_no_write_outputs", "required_evidence", "dry_run_verifier_id", "rollback_proof_id", "audit_reason_template_id", "owner_approval_required_for_live_execution", "live_execution_allowed", "production_write_allowed", "side_effect_count", "blocked_runtime_actions", "next_gate"],
      "properties": {
        "candidate_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "risk_tier": { "enum": ["low", "medium"] },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "whitelist_status": { "enum": ["candidate_only_no_live_execution", "dry_run_ready_no_live_execution", "owner_review_required_no_live_execution"] },
        "allowed_no_write_outputs": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "required_evidence": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "dry_run_verifier_id": { "type": "string", "minLength": 1 },
        "rollback_proof_id": { "type": "string", "minLength": 1 },
        "audit_reason_template_id": { "type": "string", "minLength": 1 },
        "owner_approval_required_for_live_execution": { "type": "boolean", "const": true },
        "live_execution_allowed": { "type": "boolean", "const": false },
        "production_write_allowed": { "type": "boolean", "const": false },
        "side_effect_count": { "type": "integer", "const": 0 },
        "blocked_runtime_actions": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "next_gate": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "dry_run_verifier": {
      "type": "object",
      "required": ["verifier_id", "display_name", "owner_agent", "verifier_status", "required_inputs", "pass_condition", "live_readback_allowed", "production_write_allowed"],
      "properties": {
        "verifier_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "verifier_status": { "enum": ["ready", "owner_review_required"] },
        "required_inputs": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "pass_condition": { "type": "string", "minLength": 1 },
        "live_readback_allowed": { "type": "boolean", "const": false },
        "production_write_allowed": { "type": "boolean", "const": false }
      },
      "additionalProperties": false
    },
    "rollback_proof": {
      "type": "object",
      "required": ["rollback_proof_id", "display_name", "owner_agent", "rollback_scope", "proof_status", "rollback_command_allowed", "required_before_live_execution"],
      "properties": {
        "rollback_proof_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "rollback_scope": { "type": "string", "minLength": 1 },
        "proof_status": { "enum": ["noop_ready", "draft_ready", "owner_review_required"] },
        "rollback_command_allowed": { "type": "boolean", "const": false },
        "required_before_live_execution": { "type": "boolean", "const": true }
      },
      "additionalProperties": false
    },
    "audit_reason_template": {
      "type": "object",
      "required": ["template_id", "display_name", "risk_tier", "required_fields", "example_reason", "sensitive_payload_allowed"],
      "properties": {
        "template_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "risk_tier": { "enum": ["low", "medium"] },
        "required_fields": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "example_reason": { "type": "string", "minLength": 1 },
        "sensitive_payload_allowed": { "type": "boolean", "const": false }
      },
      "additionalProperties": false
    },
    "high_risk_redirect": {
      "type": "object",
      "required": ["redirect_id", "display_name", "risk_tier", "owner_agent", "redirect_to", "blocked_runtime_actions", "reason"],
      "properties": {
        "redirect_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "risk_tier": { "enum": ["high", "critical"] },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "redirect_to": { "type": "string", "const": "P2-409 Owner Review Queue" },
        "blocked_runtime_actions": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "reason": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "owner_review_gate": {
      "type": "object",
      "required": ["gate_id", "display_name", "owner_agent", "status", "required_fields", "acceptance_checks", "blocked_runtime_actions"],
      "properties": {
        "gate_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron", "sre"] },
        "status": { "enum": ["owner_review_required", "blocked_by_runtime_gate", "draft_ready"] },
        "required_fields": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "acceptance_checks": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "blocked_runtime_actions": { "type": "array", "minItems": 1, "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "next_action": {
      "type": "object",
      "required": ["task_id", "priority", "summary", "gate"],
      "properties": {
        "task_id": { "type": "string", "minLength": 1 },
        "priority": { "enum": ["P0", "P1", "P2", "P3"] },
        "summary": { "type": "string", "minLength": 1 },
        "gate": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    }
  }
}
