{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:ai-agent-report-no-write-analysis-runtime-v1",
  "title": "AWOOOI AI Agent report no-write analysis runtime v1",
  "description": "P2-407 讓 OpenClaw、Hermes 與 NemoTron 讀取日報 / 週報 / 月報、P2-406B receipt owner review 與 P2-004 供應鏈漂移監控後產生分析草稿。此 schema 只允許 committed snapshot / governance UI 呈現，不授權 AI live runtime、Telegram 實發、Gateway queue 寫入、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",
    "analysis_truth",
    "report_inputs",
    "agent_analysis_passes",
    "draft_recommendations",
    "draft_artifacts",
    "owner_review_gates",
    "activation_boundaries",
    "telegram_policy",
    "display_redaction_contract",
    "rollups",
    "next_actions"
  ],
  "properties": {
    "schema_version": { "type": "string", "const": "ai_agent_report_no_write_analysis_runtime_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-407" },
        "next_task_id": { "type": "string", "const": "P2-408" },
        "read_only_mode": { "type": "boolean", "const": true },
        "runtime_authority": { "type": "string", "const": "report_analysis_no_write_runtime_only_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" } },
    "analysis_truth": {
      "type": "object",
      "additionalProperties": { "type": ["boolean", "integer", "string"] }
    },
    "report_inputs": { "type": "array", "minItems": 3, "items": { "$ref": "#/$defs/report_input" } },
    "agent_analysis_passes": { "type": "array", "minItems": 3, "items": { "$ref": "#/$defs/agent_analysis_pass" } },
    "draft_recommendations": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/draft_recommendation" } },
    "draft_artifacts": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/draft_artifact" } },
    "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",
        "raw_report_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 },
        "raw_report_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"] },
        "status": { "type": "string", "minLength": 1 },
        "key_readback": { "type": "string", "minLength": 1 },
        "next_action": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "report_input": {
      "type": "object",
      "required": ["report_id", "display_name", "owner_agent", "completion_percent", "source_confidence", "actionability_score", "analysis_focus", "blocked_runtime_action"],
      "properties": {
        "report_id": { "enum": ["daily", "weekly", "monthly"] },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
        "completion_percent": { "type": "integer", "minimum": 0, "maximum": 100 },
        "source_confidence": { "type": "string", "minLength": 1 },
        "actionability_score": { "type": "integer", "minimum": 0, "maximum": 100 },
        "analysis_focus": { "type": "array", "minItems": 1, "items": { "type": "string" } },
        "blocked_runtime_action": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "agent_analysis_pass": {
      "type": "object",
      "required": ["agent_id", "display_name", "role", "reviewed_source_count", "draft_finding_count", "highest_risk_tier", "live_runtime_write_allowed", "summary", "handoff_to"],
      "properties": {
        "agent_id": { "enum": ["openclaw", "hermes", "nemotron"] },
        "display_name": { "type": "string", "minLength": 1 },
        "role": { "type": "string", "minLength": 1 },
        "reviewed_source_count": { "type": "integer", "minimum": 0 },
        "draft_finding_count": { "type": "integer", "minimum": 0 },
        "highest_risk_tier": { "enum": ["low", "medium", "high", "critical"] },
        "live_runtime_write_allowed": { "type": "boolean", "const": false },
        "summary": { "type": "string", "minLength": 1 },
        "handoff_to": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "draft_recommendation": {
      "type": "object",
      "required": ["recommendation_id", "display_name", "owner_agent", "risk_tier", "approval_required", "actionability_score", "problem", "draft_solution", "expected_signal", "blocked_runtime_action"],
      "properties": {
        "recommendation_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
        "risk_tier": { "enum": ["low", "medium", "high", "critical"] },
        "approval_required": { "type": "boolean" },
        "actionability_score": { "type": "integer", "minimum": 0, "maximum": 100 },
        "problem": { "type": "string", "minLength": 1 },
        "draft_solution": { "type": "string", "minLength": 1 },
        "expected_signal": { "type": "string", "minLength": 1 },
        "blocked_runtime_action": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "draft_artifact": {
      "type": "object",
      "required": ["artifact_id", "display_name", "owner_agent", "status", "writes_production", "sends_telegram", "contains_secret", "evidence_ref"],
      "properties": {
        "artifact_id": { "type": "string", "minLength": 1 },
        "display_name": { "type": "string", "minLength": 1 },
        "owner_agent": { "enum": ["openclaw", "hermes", "nemotron"] },
        "status": { "enum": ["committed_snapshot_ready", "draft_only", "owner_review_required", "blocked_by_runtime_gate"] },
        "writes_production": { "type": "boolean", "const": false },
        "sends_telegram": { "type": "boolean", "const": false },
        "contains_secret": { "type": "boolean", "const": false },
        "evidence_ref": { "type": "string", "minLength": 1 }
      },
      "additionalProperties": false
    },
    "owner_review_gate": {
      "type": "object",
      "required": ["gate_id", "display_name", "owner_agent", "risk_tier", "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"] },
        "risk_tier": { "enum": ["low", "medium", "high", "critical"] },
        "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
    }
  }
}
