version: "1"

defaults:
  risk_level: medium
  approval: approve

rules:
  # Read-only operations are safe to auto-execute
  - name: read_operations
    match:
      type: read
    risk_level: low
    approval: auto

  - name: navigate
    match:
      type: navigate
    risk_level: low
    approval: auto

  - name: screenshot
    match:
      type: screenshot
    risk_level: low
    approval: auto

  # Single-write operations require approval
  - name: click_action
    match:
      type: click
    risk_level: medium
    approval: approve

  - name: fill_form
    match:
      type: fill
    risk_level: medium
    approval: approve

  - name: single_write
    match:
      type: write
    risk_level: medium
    approval: approve

  # Bulk operations: escalate when count > 100
  - name: bulk_update_large
    match:
      type: bulk_update
    conditions:
      param_gt: { count: 100 }
    risk_level: critical
    approval: block

  - name: bulk_update
    match:
      type: bulk_update
    risk_level: high
    approval: approve

  # Block writes after business hours (UTC)
  - name: after_hours_write_block
    match:
      type: "write*"
    conditions:
      time_after: "18:00"
    risk_level: critical
    approval: block

  # Restrict deploys to weekdays only
  - name: weekday_deploys_only
    match:
      type: "deploy*"
    conditions:
      weekdays: [1, 2, 3, 4, 5]
    risk_level: medium
    approval: approve

  # Destructive operations: always blocked
  - name: delete_blocked
    match:
      type: delete
    risk_level: critical
    approval: block
