{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bullpen.fi/reference/schemas/doctor.auth.schema.json",
  "title": "bullpen doctor auth JSON output",
  "description": "Initial stable schema for the documented logged-out auth diagnostic envelope.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "status",
    "credentials_valid",
    "token_valid",
    "keypair_valid",
    "wallet_ready",
    "onboarding_complete",
    "trade_auth_state",
    "trade_auth_blocked",
    "turnkey_signing_session_present",
    "turnkey_signing_session_expired",
    "pending_actions",
    "recovery_methods"
  ],
  "properties": {
    "status": {
      "enum": [
        "ok",
        "warning",
        "error"
      ]
    },
    "error_code": {
      "type": [
        "string",
        "null"
      ]
    },
    "credentials_valid": {
      "type": "boolean"
    },
    "credentials_error": {
      "type": [
        "string",
        "null"
      ]
    },
    "token_valid": {
      "type": "boolean"
    },
    "token_expires_in_secs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "refresh_token_expires_in_secs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "keypair_valid": {
      "type": "boolean"
    },
    "wallet_ready": {
      "type": "boolean"
    },
    "onboarding_complete": {
      "type": "boolean"
    },
    "trade_auth_state": {
      "type": "string",
      "minLength": 1
    },
    "trade_auth_blocked": {
      "type": "boolean"
    },
    "trade_auth_blocker_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "turnkey_signing_session_present": {
      "type": "boolean"
    },
    "turnkey_signing_session_expired": {
      "type": "boolean"
    },
    "pending_actions": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "recovery_methods": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "remediation": {
      "$ref": "#/$defs/remediation"
    },
    "bundle_decryptable": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "cli_api_key_metadata_present": {
      "type": "boolean"
    },
    "cli_api_key_rotation_due": {
      "type": "boolean"
    },
    "cli_api_key_state": {
      "type": "string"
    },
    "server_time_offset_ms": {
      "type": [
        "integer",
        "null"
      ]
    }
  },
  "$defs": {
    "remediation": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "action",
        "command",
        "message"
      ],
      "properties": {
        "action": {
          "type": "string",
          "minLength": 1
        },
        "command": {
          "type": "string",
          "minLength": 1
        },
        "message": {
          "type": "string",
          "minLength": 1
        }
      }
    }
  }
}
