{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:ai-agent-automation-backlog-v1",
  "title": "AWOOOI AI Agent 自動化待辦 v1",
  "description": "描述由資產盤點、健康訊號、市場觀察與治理關卡產生的只讀自動化待辦。此 schema 不授權任何生產寫入、SDK 安裝、付費 API 呼叫、shadow/canary 或生產路由變更。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "source_inventory_snapshot_ref",
    "program_status",
    "rollups",
    "progress_summary",
    "backlog_items",
    "item_approval_boundary_rollup",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "ai_agent_automation_backlog_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "source_inventory_snapshot_ref": {
      "type": "string",
      "minLength": 1
    },
    "program_status": {
      "type": "object",
      "required": [
        "overall_completion_percent",
        "current_priority",
        "current_task_id",
        "next_task_id",
        "read_only_mode"
      ],
      "properties": {
        "overall_completion_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "current_priority": {
          "type": "string",
          "enum": ["P0", "P1", "P2", "P3"]
        },
        "current_task_id": {
          "type": "string",
          "minLength": 1
        },
        "next_task_id": {
          "type": "string",
          "minLength": 1
        },
        "read_only_mode": {
          "type": "boolean",
          "const": true
        }
      },
      "additionalProperties": false
    },
    "rollups": {
      "type": "object",
      "required": [
        "total_items",
        "by_priority",
        "by_status",
        "by_gate_status",
        "by_owner_agent"
      ],
      "properties": {
        "total_items": {
          "type": "integer",
          "minimum": 0
        },
        "by_priority": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_gate_status": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "by_owner_agent": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "additionalProperties": false
    },
    "progress_summary": {
      "type": "object",
      "required": [
        "overall_percent",
        "done_items",
        "planned_items",
        "total_items",
        "formula",
        "by_priority",
        "by_workstream"
      ],
      "properties": {
        "overall_percent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "done_items": {
          "type": "integer",
          "minimum": 0
        },
        "planned_items": {
          "type": "integer",
          "minimum": 0
        },
        "total_items": {
          "type": "integer",
          "minimum": 0
        },
        "formula": {
          "type": "string",
          "minLength": 1
        },
        "by_priority": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "priority",
              "completion_percent",
              "done_items",
              "total_items"
            ],
            "properties": {
              "priority": {
                "type": "string",
                "enum": ["P0", "P1", "P2", "P3"]
              },
              "completion_percent": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "done_items": {
                "type": "integer",
                "minimum": 0
              },
              "total_items": {
                "type": "integer",
                "minimum": 0
              }
            },
            "additionalProperties": false
          }
        },
        "by_workstream": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "workstream_id",
              "display_name",
              "completion_percent",
              "done_items",
              "total_items",
              "next_task_id"
            ],
            "properties": {
              "workstream_id": {
                "type": "string",
                "minLength": 1
              },
              "display_name": {
                "type": "string",
                "minLength": 1
              },
              "completion_percent": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              },
              "done_items": {
                "type": "integer",
                "minimum": 0
              },
              "total_items": {
                "type": "integer",
                "minimum": 0
              },
              "next_task_id": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "backlog_items": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "item_id",
          "priority",
          "status",
          "workstream_id",
          "source_asset_id",
          "source_signal_kind",
          "title",
          "owner_agent",
          "recommended_action",
          "action_class",
          "gate_status",
          "risk_level",
          "evidence_refs",
          "acceptance_criteria",
          "approval_boundary",
          "next_review"
        ],
        "properties": {
          "item_id": {
            "type": "string",
            "minLength": 1
          },
          "priority": {
            "type": "string",
            "enum": ["P0", "P1", "P2", "P3"]
          },
          "status": {
            "type": "string",
            "enum": [
              "planned",
              "in_progress",
              "blocked",
              "ready_for_review",
              "done",
              "deferred",
              "rejected"
            ]
          },
          "workstream_id": {
            "type": "string",
            "minLength": 1
          },
          "source_asset_id": {
            "type": "string",
            "minLength": 1
          },
          "source_signal_kind": {
            "type": "string",
            "enum": [
              "inventory_gap",
              "health_gap",
              "backup_gap",
              "dependency_gap",
              "market_signal",
              "approval_boundary",
              "runtime_evidence_gap",
              "ui_visibility_gap"
            ]
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "owner_agent": {
            "type": "string",
            "minLength": 1
          },
          "recommended_action": {
            "type": "string",
            "minLength": 1
          },
          "action_class": {
            "type": "string",
            "minLength": 1
          },
          "gate_status": {
            "type": "string",
            "minLength": 1
          },
          "risk_level": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "acceptance_criteria": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "approval_boundary": {
            "type": "object",
            "required": [
              "mode",
              "display_summary",
              "allowed_actions",
              "blocked_actions",
              "requires_operator_approval_for"
            ],
            "properties": {
              "mode": {
                "type": "string",
                "minLength": 1
              },
              "display_summary": {
                "type": "string",
                "minLength": 1
              },
              "allowed_actions": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "blocked_actions": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "requires_operator_approval_for": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              }
            },
            "additionalProperties": false
          },
          "next_review": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "item_approval_boundary_rollup": {
      "type": "object",
      "required": [
        "total_items",
        "by_mode",
        "items_requiring_explicit_approval",
        "items_with_blocked_operations"
      ],
      "properties": {
        "total_items": {
          "type": "integer",
          "minimum": 0
        },
        "by_mode": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "items_requiring_explicit_approval": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "items_with_blocked_operations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "approval_boundaries": {
      "type": "object",
      "required": [
        "sdk_installation_allowed",
        "paid_api_call_allowed",
        "shadow_or_canary_allowed",
        "production_routing_allowed",
        "destructive_operation_allowed"
      ],
      "properties": {
        "sdk_installation_allowed": {
          "type": "boolean",
          "const": false
        },
        "paid_api_call_allowed": {
          "type": "boolean",
          "const": false
        },
        "shadow_or_canary_allowed": {
          "type": "boolean",
          "const": false
        },
        "production_routing_allowed": {
          "type": "boolean",
          "const": false
        },
        "destructive_operation_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
