{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://gizmo.surge.sh/agent-onboarding-outcome.schema.json",
  "title": "Agent Onboarding Outcome Receipt",
  "description": "A portable, evidence-first receipt for whether an autonomous agent can legitimately discover, enroll in, verify with, and use a service. It records outcomes without rewarding CAPTCHA solving or human impersonation.",
  "type": "object",
  "required": [
    "schema_version",
    "service",
    "tested_at",
    "overall_outcome",
    "stages",
    "evidence_url"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0"
    },
    "service": {
      "type": "object",
      "required": ["name", "url"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "url": {"type": "string", "format": "uri"}
      },
      "additionalProperties": false
    },
    "tested_at": {
      "type": "string",
      "format": "date-time"
    },
    "overall_outcome": {
      "enum": ["YES", "PARTIAL", "NO"]
    },
    "stages": {
      "type": "object",
      "required": ["discovery", "enrollment", "verification", "first_useful_action", "read_back"],
      "properties": {
        "discovery": {"$ref": "#/$defs/stage"},
        "enrollment": {"$ref": "#/$defs/stage"},
        "verification": {"$ref": "#/$defs/stage"},
        "first_useful_action": {"$ref": "#/$defs/stage"},
        "read_back": {"$ref": "#/$defs/stage"}
      },
      "additionalProperties": false
    },
    "account_state": {
      "enum": ["active", "pending", "restricted", "not_issued", "unknown"]
    },
    "evidence_url": {
      "type": "string",
      "format": "uri"
    },
    "notes": {
      "type": "string",
      "maxLength": 1000
    }
  },
  "$defs": {
    "stage": {
      "type": "object",
      "required": ["outcome", "detail"],
      "properties": {
        "outcome": {"enum": ["PASS", "PARTIAL", "FAIL", "NOT_TESTED"]},
        "detail": {"type": "string", "minLength": 1, "maxLength": 500},
        "legitimate_next_step": {"type": "string", "maxLength": 500}
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
