#!/usr/bin/env bash
# Three-case probe, corrected for engine v0.3.1:
#   agent_id -> actor, resource is an object, confidence is top-level, bearer key required.
set -u
BASE="$1"
KEY="${2:-}"
probe() {
  name="$1"
  body="$2"
  printf '\n=== %s ===\nRequest: %s\nResponse:\n' "$name" "$body"
  curl -sS -w '\nHTTP %{http_code}\n' \
    -H 'Content-Type: application/json' \
    ${KEY:+-H "Authorization: Bearer $KEY"} \
    -X POST "$BASE/v1/agent/authorize" \
    --data "$body"
}
probe destructive '{"actor":"lab-agent","action":"delete_all_records","resource":{"table":"customer_database"},"confidence":0.99}'
probe low_confidence '{"actor":"lab-agent","action":"send_customer_email","resource":{"customer":"42"},"confidence":0.31}'
probe routine_read '{"actor":"lab-agent","action":"read_record","resource":{"customer":"42"},"confidence":0.99}'
