# Automation Profile YAML Schema
# Defines the expected structure for automation profile configuration files.
# See docs/specification.md Section "Automation Profiles" for full details.

type: object
required:
  - name
additionalProperties: false
properties:
  name:
    type: string
    minLength: 1
    pattern: "^[a-zA-Z0-9_-]+(/[a-zA-Z0-9_-]+)?$"
    description: >
      Profile name: bare built-in name (e.g. 'manual')
      or namespaced 'namespace/name' (e.g. 'acme/strict')
  description:
    type: string
    description: "Human-readable description of the profile"
  schema_version:
    type: string
    default: "1.0"
    description: "Schema version for forward compatibility"

  # Task-type confidence thresholds (0.0 = auto, 1.0 = human)
  decompose_task:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic task decomposition"
  create_tool:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic tool creation"
  select_tool:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic tool selection"

  edit_code:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic code editing"
  execute_command:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic command execution"

  create_file:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic file creation"
  delete_content:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic content deletion"
  access_network:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic network access"

  install_dependency:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic dependency installation"
  modify_config:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic configuration modification"
  approve_plan:
    type: number
    minimum: 0.0
    maximum: 1.0
    default: 0.0
    description: "Threshold for automatic plan approval"

  # Optional automation guards (runtime enforcement hooks)
  guards:
    type: ["object", "null"]
    description: "Optional AutomationGuard sub-model with per-invocation runtime constraints"
    properties:
      max_tool_calls_per_step:
        type: ["integer", "null"]
        minimum: 0
        default: null
        description: "Maximum tool invocations per step before requiring approval"
      max_total_cost:
        type: ["number", "null"]
        minimum: 0.0
        default: null
        description: "Maximum cumulative invocation cost before requiring approval"
      tool_allowlist:
        type: ["array", "null"]
        items:
          type: string
        default: null
        description: "Only these tools may proceed automatically (null = all tools)"
      tool_denylist:
        type: ["array", "null"]
        items:
          type: string
        default: null
        description: "These tools always require approval (null = no denied tools)"
      require_approval_for_writes:
        type: boolean
        default: false
        description: "Require approval for write operations"
      require_approval_for_apply:
        type: boolean
        default: false
        description: "Require approval before apply phase"

  # Safety profile (composed sub-model)
  safety:
    type: object
    description: "Composed SafetyProfile sub-model with hard safety constraints"
    properties:
      require_sandbox:
        type: boolean
        default: true
        description: "Whether a sandbox is required for execution"
      require_checkpoints:
        type: boolean
        default: true
        description: "Whether checkpoints are required"
      allow_unsafe_tools:
        type: boolean
        default: false
        description: "Whether unsafe tools may be used"
      require_human_approval:
        type: boolean
        default: false
        description: "Whether human approval is required before each action step"
      allowed_skill_categories:
        type: array
        items:
          type: string
        default: []
        description: "Skill categories permitted for execution (empty = all allowed)"
      max_cost_per_plan:
        type: ["number", "null"]
        minimum: 0.0
        default: null
        description: "Maximum cost in USD per plan execution (null = no limit)"
      max_total_cost:
        type: ["number", "null"]
        minimum: 0.0
        default: null
        description: "Maximum total cost in USD across all plans (null = no limit)"
      max_retries_per_step:
        type: integer
        minimum: 0
        maximum: 100
        default: 3
        description: "Maximum retry attempts per action step"
