{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:dependency-upgrade-approval-package-template-v1",
  "title": "AWOOOI dependency upgrade approval package template v1",
  "description": "依賴升級、base image digest pin、binary checksum、publish boundary 與外部來源啟用的只讀批准包模板。此 schema 不授權套件升級、lockfile 寫入、Dockerfile 修改、docker build、image pull、image rebuild、registry push、package publish、SDK 安裝、付費 API、shadow/canary 或生產路由變更。",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "program_status",
    "source_refs",
    "rollups",
    "approval_fields",
    "package_templates",
    "decision_gate_contract",
    "operation_boundaries",
    "approval_boundaries"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "dependency_upgrade_approval_package_template_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
    },
    "source_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "rollups": {
      "type": "object",
      "required": [
        "total_templates",
        "by_domain",
        "template_ready_ids",
        "hitl_required_template_ids"
      ],
      "properties": {
        "total_templates": {
          "type": "integer",
          "minimum": 1
        },
        "by_domain": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "template_ready_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "hitl_required_template_ids": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "additionalProperties": false
    },
    "approval_fields": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["field_id", "required", "description"],
        "properties": {
          "field_id": {
            "type": "string",
            "minLength": 1
          },
          "required": {
            "type": "boolean",
            "const": true
          },
          "description": {
            "type": "string",
            "minLength": 1
          }
        },
        "additionalProperties": false
      }
    },
    "package_templates": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "template_id",
          "domain",
          "status",
          "owner_agent",
          "purpose",
          "required_evidence",
          "required_decisions",
          "required_tests",
          "rollback_requirements",
          "manual_approvals",
          "prohibited_without_approval",
          "evidence_refs"
        ],
        "properties": {
          "template_id": {
            "type": "string",
            "minLength": 1
          },
          "domain": {
            "type": "string",
            "enum": ["python", "javascript", "docker", "external_sources", "agent_market"]
          },
          "status": {
            "type": "string",
            "enum": ["template_ready"]
          },
          "owner_agent": {
            "type": "string",
            "enum": ["openclaw", "hermes", "nemotron"]
          },
          "purpose": {
            "type": "string",
            "minLength": 1
          },
          "required_evidence": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "required_decisions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "required_tests": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "rollback_requirements": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "manual_approvals": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "prohibited_without_approval": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "evidence_refs": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "additionalProperties": false
      }
    },
    "decision_gate_contract": {
      "type": "object",
      "required": [
        "openclaw_role",
        "hermes_role",
        "nemotron_role",
        "hitl_required",
        "expires_after"
      ],
      "properties": {
        "openclaw_role": {
          "type": "string",
          "minLength": 1
        },
        "hermes_role": {
          "type": "string",
          "minLength": 1
        },
        "nemotron_role": {
          "type": "string",
          "minLength": 1
        },
        "hitl_required": {
          "type": "boolean",
          "const": true
        },
        "expires_after": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "operation_boundaries": {
      "type": "object",
      "required": [
        "read_only_template_allowed",
        "external_source_activation_allowed",
        "sdk_installation_allowed",
        "paid_api_call_allowed",
        "package_installation_allowed",
        "package_upgrade_allowed",
        "lockfile_write_allowed",
        "manifest_write_allowed",
        "dockerfile_write_allowed",
        "docker_build_allowed",
        "image_pull_allowed",
        "image_rebuild_allowed",
        "registry_push_allowed",
        "package_publish_allowed",
        "shadow_or_canary_allowed",
        "production_routing_allowed"
      ],
      "properties": {
        "read_only_template_allowed": {
          "type": "boolean",
          "const": true
        },
        "external_source_activation_allowed": {
          "type": "boolean",
          "const": false
        },
        "sdk_installation_allowed": {
          "type": "boolean",
          "const": false
        },
        "paid_api_call_allowed": {
          "type": "boolean",
          "const": false
        },
        "package_installation_allowed": {
          "type": "boolean",
          "const": false
        },
        "package_upgrade_allowed": {
          "type": "boolean",
          "const": false
        },
        "lockfile_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "manifest_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "dockerfile_write_allowed": {
          "type": "boolean",
          "const": false
        },
        "docker_build_allowed": {
          "type": "boolean",
          "const": false
        },
        "image_pull_allowed": {
          "type": "boolean",
          "const": false
        },
        "image_rebuild_allowed": {
          "type": "boolean",
          "const": false
        },
        "registry_push_allowed": {
          "type": "boolean",
          "const": false
        },
        "package_publish_allowed": {
          "type": "boolean",
          "const": false
        },
        "shadow_or_canary_allowed": {
          "type": "boolean",
          "const": false
        },
        "production_routing_allowed": {
          "type": "boolean",
          "const": false
        }
      },
      "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
}
