{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awoooi.wooo.work/schemas/ai_agent_telegram_action_required_digest_policy_v1.schema.json",
  "title": "AI Agent Telegram Action Required Digest Policy v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "trigger_categories",
    "digest_channels",
    "digest_rules",
    "message_template_contract",
    "rate_limit_policy",
    "display_redaction_contract",
    "agent_roles",
    "operation_boundaries",
    "approval_boundaries",
    "rollups"
  ],
  "properties": {
    "schema_version": {
      "const": "ai_agent_telegram_action_required_digest_policy_v1"
    },
    "generated_at": {
      "type": "string"
    },
    "program_status": {
      "type": "object",
      "additionalProperties": false,
      "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"
        },
        "current_task_id": {
          "type": "string"
        },
        "next_task_id": {
          "type": "string"
        },
        "read_only_mode": {
          "const": true
        },
        "runtime_authority": {
          "const": "policy_only_no_telegram_send_or_route_change"
        },
        "status_note": {
          "type": "string"
        }
      }
    },
    "source_refs": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "trigger_categories": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "category_id",
          "owner_agent",
          "policy_intent",
          "blocked_now"
        ],
        "properties": {
          "category_id": {
            "type": "string"
          },
          "owner_agent": {
            "type": "string"
          },
          "policy_intent": {
            "type": "string"
          },
          "blocked_now": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "digest_channels": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "channel_id",
          "purpose",
          "success_immediate_allowed",
          "direct_send_allowed",
          "queue_write_allowed",
          "requires_telegram_gateway_e2e"
        ],
        "properties": {
          "channel_id": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          },
          "success_immediate_allowed": {
            "const": false
          },
          "direct_send_allowed": {
            "const": false
          },
          "queue_write_allowed": {
            "const": false
          },
          "requires_telegram_gateway_e2e": {
            "type": "boolean"
          }
        }
      }
    },
    "digest_rules": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rule_id",
          "category_id",
          "signal_state",
          "severity",
          "decision",
          "owner_agent",
          "required_evidence",
          "channels",
          "requires_openclaw_review",
          "telegram_direct_send_allowed",
          "next_action"
        ],
        "properties": {
          "rule_id": {
            "type": "string"
          },
          "category_id": {
            "type": "string"
          },
          "signal_state": {
            "type": "string"
          },
          "severity": {
            "type": "string"
          },
          "decision": {
            "enum": [
              "suppress_success_noise",
              "draft_action_required_digest",
              "draft_failure_escalation_digest",
              "hold_for_owner_packet"
            ]
          },
          "owner_agent": {
            "type": "string"
          },
          "required_evidence": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "requires_openclaw_review": {
            "type": "boolean"
          },
          "telegram_direct_send_allowed": {
            "const": false
          },
          "next_action": {
            "type": "string"
          }
        }
      }
    },
    "message_template_contract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "required_fields",
        "forbidden_fields",
        "success_message_policy",
        "action_required_message_policy",
        "failure_message_policy"
      ],
      "properties": {
        "required_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "forbidden_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "success_message_policy": {
          "type": "string"
        },
        "action_required_message_policy": {
          "type": "string"
        },
        "failure_message_policy": {
          "type": "string"
        }
      }
    },
    "rate_limit_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "success_policy",
        "digest_window_minutes",
        "dedupe_key_fields",
        "max_digest_items",
        "fallback_policy"
      ],
      "properties": {
        "success_policy": {
          "type": "string"
        },
        "digest_window_minutes": {
          "type": "integer",
          "minimum": 1
        },
        "dedupe_key_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "max_digest_items": {
          "type": "integer",
          "minimum": 1
        },
        "fallback_policy": {
          "type": "string"
        }
      }
    },
    "display_redaction_contract": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "conversation_transcript_display_allowed",
        "redaction_required",
        "allowed_frontend_fields",
        "forbidden_frontend_content"
      ],
      "properties": {
        "conversation_transcript_display_allowed": {
          "const": false
        },
        "redaction_required": {
          "const": true
        },
        "allowed_frontend_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "forbidden_frontend_content": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "agent_roles": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "agent_id",
          "digest_responsibility",
          "blocked_now"
        ],
        "properties": {
          "agent_id": {
            "type": "string"
          },
          "digest_responsibility": {
            "type": "string"
          },
          "blocked_now": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "operation_boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "read_only_policy_allowed",
        "telegram_direct_send_allowed",
        "telegram_test_message_allowed",
        "telegram_gateway_queue_write_allowed",
        "alertmanager_route_change_allowed",
        "telegram_receiver_change_allowed",
        "awooop_event_write_allowed",
        "workflow_trigger_allowed",
        "external_scan_allowed",
        "runtime_execution_allowed",
        "secret_plaintext_allowed",
        "conversation_transcript_allowed"
      ],
      "properties": {
        "read_only_policy_allowed": {
          "const": true
        },
        "telegram_direct_send_allowed": {
          "const": false
        },
        "telegram_test_message_allowed": {
          "const": false
        },
        "telegram_gateway_queue_write_allowed": {
          "const": false
        },
        "alertmanager_route_change_allowed": {
          "const": false
        },
        "telegram_receiver_change_allowed": {
          "const": false
        },
        "awooop_event_write_allowed": {
          "const": false
        },
        "workflow_trigger_allowed": {
          "const": false
        },
        "external_scan_allowed": {
          "const": false
        },
        "runtime_execution_allowed": {
          "const": false
        },
        "secret_plaintext_allowed": {
          "const": false
        },
        "conversation_transcript_allowed": {
          "const": false
        }
      }
    },
    "approval_boundaries": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "telegram_digest_send_approved",
        "telegram_gateway_queue_write_approved",
        "telegram_route_change_approved",
        "alertmanager_receiver_change_approved",
        "awooop_event_write_approved",
        "workflow_trigger_approved",
        "runtime_execution_approved",
        "secret_plaintext_approved"
      ],
      "properties": {
        "telegram_digest_send_approved": {
          "const": false
        },
        "telegram_gateway_queue_write_approved": {
          "const": false
        },
        "telegram_route_change_approved": {
          "const": false
        },
        "alertmanager_receiver_change_approved": {
          "const": false
        },
        "awooop_event_write_approved": {
          "const": false
        },
        "workflow_trigger_approved": {
          "const": false
        },
        "runtime_execution_approved": {
          "const": false
        },
        "secret_plaintext_approved": {
          "const": false
        }
      }
    },
    "rollups": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "rule_count",
        "channel_count",
        "trigger_category_count",
        "by_decision",
        "action_required_rule_ids",
        "failure_escalation_rule_ids",
        "suppressed_success_rule_ids",
        "telegram_direct_send_allowed_count",
        "telegram_gateway_queue_write_allowed_count",
        "route_change_allowed_count",
        "conversation_transcript_allowed_count",
        "next_approval_task_ids"
      ],
      "properties": {
        "rule_count": {
          "type": "integer",
          "minimum": 0
        },
        "channel_count": {
          "type": "integer",
          "minimum": 0
        },
        "trigger_category_count": {
          "type": "integer",
          "minimum": 0
        },
        "by_decision": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "action_required_rule_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "failure_escalation_rule_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "suppressed_success_rule_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "telegram_direct_send_allowed_count": {
          "const": 0
        },
        "telegram_gateway_queue_write_allowed_count": {
          "const": 0
        },
        "route_change_allowed_count": {
          "const": 0
        },
        "conversation_transcript_allowed_count": {
          "const": 0
        },
        "next_approval_task_ids": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
