{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:ai-agent-automation-inventory-snapshot-v1",
  "title": "AWOOOI AI Agent 自動化盤點快照 v1",
  "description": "AI Agent 自動化盤點快照合約。此 schema 只描述只讀盤點、狀態、關卡、證據與工作清單，不授權任何生產執行。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "status_taxonomy",
    "agent_roles",
    "asset_domains",
    "assets",
    "workstreams",
    "tasks",
    "task_approval_boundary_rollup",
    "evidence",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "ai_agent_automation_inventory_snapshot_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"
      ],
      "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
    },
    "status_taxonomy": {
      "type": "object",
      "required": [
        "task_statuses",
        "gate_statuses",
        "priorities"
      ],
      "properties": {
        "task_statuses": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "planned",
              "in_progress",
              "blocked",
              "ready_for_review",
              "done",
              "deferred",
              "rejected"
            ]
          }
        },
        "gate_statuses": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "enum": [
              "read_only_allowed",
              "dry_run_required",
              "approval_required",
              "cost_approval_required",
              "dependency_approval_required",
              "production_change_blocked",
              "shadow_canary_blocked",
              "blocked_by_evidence",
              "ready_for_operator_review"
            ]
          }
        },
        "priorities": {
          "type": "array",
          "minItems": 4,
          "items": {
            "type": "string",
            "enum": ["P0", "P1", "P2", "P3"]
          }
        }
      },
      "additionalProperties": false
    },
    "agent_roles": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "agent_id",
          "display_name",
          "primary_role",
          "allowed_actions",
          "blocked_actions"
        ],
        "properties": {
          "agent_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "primary_role": {
            "type": "string",
            "minLength": 1
          },
          "allowed_actions": {
            "type": "array",
            "items": {"type": "string", "minLength": 1}
          },
          "blocked_actions": {
            "type": "array",
            "items": {"type": "string", "minLength": 1}
          }
        },
        "additionalProperties": false
      }
    },
    "asset_domains": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "domain_id",
          "display_name",
          "description"
        ],
        "properties": {
          "domain_id": {
            "type": "string",
            "enum": [
              "services",
              "tools",
              "packages",
              "backup_targets",
              "ai_providers",
              "workflows",
              "observability",
              "security"
            ]
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "assets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "asset_id",
          "domain_id",
          "display_name",
          "asset_type",
          "status",
          "gate_status",
          "owner_agent",
          "risk_level",
          "evidence_refs",
          "next_action"
        ],
        "properties": {
          "asset_id": {
            "type": "string",
            "minLength": 1
          },
          "domain_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "asset_type": {
            "type": "string",
            "enum": [
              "api",
              "web",
              "worker",
              "k8s_workload",
              "database",
              "cache",
              "ai_provider",
              "workflow",
              "script",
              "backup_target",
              "package_set",
              "container_image",
              "observability_tool",
              "security_tool",
              "external_service"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "planned",
              "in_progress",
              "blocked",
              "ready_for_review",
              "done",
              "deferred",
              "rejected"
            ]
          },
          "gate_status": {
            "type": "string",
            "minLength": 1
          },
          "owner_agent": {
            "type": "string",
            "minLength": 1
          },
          "risk_level": {
            "type": "string",
            "enum": ["low", "medium", "high", "critical"]
          },
          "evidence_refs": {
            "type": "array",
            "items": {"type": "string", "minLength": 1}
          },
          "next_action": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "workstreams": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "workstream_id",
          "display_name",
          "completion_percent",
          "status",
          "next_task_id"
        ],
        "properties": {
          "workstream_id": {
            "type": "string",
            "minLength": 1
          },
          "display_name": {
            "type": "string",
            "minLength": 1
          },
          "completion_percent": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "next_task_id": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "tasks": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "task_id",
          "priority",
          "status",
          "completion_percent",
          "owner_agent",
          "title",
          "output",
          "gate_status",
          "approval_boundary",
          "next_action"
        ],
        "properties": {
          "task_id": {
            "type": "string",
            "minLength": 1
          },
          "priority": {
            "type": "string",
            "enum": ["P0", "P1", "P2", "P3"]
          },
          "status": {
            "type": "string",
            "minLength": 1
          },
          "completion_percent": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "owner_agent": {
            "type": "string",
            "minLength": 1
          },
          "title": {
            "type": "string",
            "minLength": 1
          },
          "output": {
            "type": "string",
            "minLength": 1
          },
          "gate_status": {
            "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_action": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "task_approval_boundary_rollup": {
      "type": "object",
      "required": [
        "total_tasks",
        "by_mode",
        "tasks_requiring_explicit_approval",
        "tasks_with_blocked_operations"
      ],
      "properties": {
        "total_tasks": {
          "type": "integer",
          "minimum": 0
        },
        "by_mode": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "tasks_requiring_explicit_approval": {
          "type": "array",
          "items": {"type": "string", "minLength": 1}
        },
        "tasks_with_blocked_operations": {
          "type": "array",
          "items": {"type": "string", "minLength": 1}
        }
      },
      "additionalProperties": false
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "evidence_id",
          "kind",
          "ref",
          "result"
        ],
        "properties": {
          "evidence_id": {
            "type": "string",
            "minLength": 1
          },
          "kind": {
            "type": "string",
            "enum": ["schema", "test", "browser", "api", "build", "doc", "runtime"]
          },
          "ref": {
            "type": "string",
            "minLength": 1
          },
          "result": {
            "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
}
