{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.bullpen.fi/reference/schemas/status.schema.json",
  "title": "bullpen status JSON output",
  "description": "Initial stable schema for the documented logged-out status diagnostics envelope.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "version",
    "environment",
    "credentials",
    "credential_storage",
    "session_recovery",
    "update_check",
    "account",
    "health",
    "trading_access",
    "trade_auth_state",
    "trade_auth_blocked",
    "pending_actions",
    "polymarket",
    "polymarket_wallet_evidence",
    "prediction_trading_readiness",
    "skills",
    "solana",
    "support",
    "community"
  ],
  "properties": {
    "version": {
      "type": "string",
      "minLength": 1
    },
    "environment": {
      "type": "string",
      "minLength": 1
    },
    "credentials": {
      "type": "string",
      "enum": [
        "file",
        "ephemeral"
      ],
      "description": "Stable credential-store backend label. Filesystem paths are never emitted."
    },
    "credential_storage": {
      "$ref": "#/$defs/credential_storage"
    },
    "session_recovery": {
      "oneOf": [
        {
          "$ref": "#/$defs/session_recovery"
        },
        {
          "type": "null"
        }
      ]
    },
    "update_check": {
      "$ref": "#/$defs/update_check"
    },
    "account": {
      "$ref": "#/$defs/account"
    },
    "health": {
      "$ref": "#/$defs/health"
    },
    "trading_access": {
      "$ref": "#/$defs/trading_access"
    },
    "trade_auth_state": {
      "type": "string",
      "minLength": 1
    },
    "trade_auth_blocked": {
      "type": "boolean"
    },
    "trade_auth_blocker_reason": {
      "type": [
        "string",
        "null"
      ]
    },
    "pending_actions": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "polymarket": {
      "$ref": "#/$defs/polymarket"
    },
    "polymarket_wallet_evidence": {
      "$ref": "#/$defs/polymarket_wallet_evidence"
    },
    "prediction_trading_readiness": {
      "$ref": "#/$defs/prediction_trading_readiness"
    },
    "polymarket_legacy_deposit_wallet_recovery": {
      "type": [
        "object",
        "null"
      ],
      "description": "Optional Polymarket legacy pre-beacon Deposit Wallet recovery state. When status is pending_recovery and code is PM_LEGACY_DEPOSIT_WALLET_PENDING_RECOVERY, funds are safe on-chain and the user should collect support evidence instead of retrying approve, activate, reregister, or trading for that wallet."
    },
    "polymarket_routing_warning": {
      "type": [
        "object",
        "null"
      ]
    },
    "multi_wallet": {
      "type": [
        "object",
        "null"
      ]
    },
    "split_brain_warning": {
      "type": [
        "object",
        "null"
      ]
    },
    "remediation": {
      "$ref": "#/$defs/remediation"
    },
    "skills": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/skill"
      }
    },
    "solana": {
      "$ref": "#/$defs/solana"
    },
    "support": {
      "$ref": "#/$defs/support"
    },
    "community": {
      "$ref": "#/$defs/community"
    },
    "update_available": {
      "type": [
        "object",
        "null"
      ]
    }
  },
  "$defs": {
    "http_url": {
      "type": "string",
      "pattern": "^https?://[^\\s]+$"
    },
    "credential_storage": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "backend",
        "format",
        "encrypted_credentials_present",
        "plaintext_credentials_present",
        "credentials_lock_present"
      ],
      "properties": {
        "backend": {
          "type": "string",
          "enum": [
            "file",
            "ephemeral",
            "unknown"
          ]
        },
        "format": {
          "type": "string",
          "enum": [
            "encrypted",
            "plaintext",
            "both",
            "none",
            "ephemeral",
            "unknown"
          ]
        },
        "encrypted_credentials_present": {
          "type": "boolean"
        },
        "plaintext_credentials_present": {
          "type": "boolean"
        },
        "credentials_lock_present": {
          "type": "boolean"
        },
        "probe_error": {
          "type": "string",
          "const": "probe_failed",
          "description": "Support-safe redaction used when local metadata probing fails."
        }
      }
    },
    "session_recovery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "state",
        "code",
        "requires_login",
        "safe_to_retry",
        "next_command"
      ],
      "properties": {
        "state": {
          "type": "string",
          "enum": [
            "missing_salt",
            "corrupt_salt",
            "copied_home_mismatch",
            "stale_jwt",
            "rejected_refresh",
            "turnkey_policy_denied",
            "credential_store_locked",
            "credential_store_unreadable",
            "login_required"
          ]
        },
        "code": {
          "type": "string",
          "pattern": "^auth_[a-z0-9_]+$"
        },
        "requires_login": {
          "type": "boolean"
        },
        "safe_to_retry": {
          "type": "boolean"
        },
        "next_command": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "update_check": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "detail",
        "next_command"
      ],
      "properties": {
        "status": {
          "type": "string",
          "const": "not_checked"
        },
        "detail": {
          "type": "string",
          "const": "Passive status does not contact release services."
        },
        "next_command": {
          "type": "string",
          "const": "bullpen upgrade"
        }
      }
    },
    "account": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "logged_in",
        "profile_next_command",
        "profile_status",
        "requires_login",
        "token_store",
        "turnkey_bundle_next_command",
        "turnkey_bundle_status"
      ],
      "properties": {
        "logged_in": {
          "type": "boolean"
        },
        "requires_login": {
          "type": "boolean"
        },
        "token_store": {
          "type": "string",
          "enum": [
            "file",
            "ephemeral"
          ]
        },
        "profile_status": {
          "type": "string",
          "enum": [
            "not_checked"
          ]
        },
        "profile_next_command": {
          "type": "string",
          "const": "bullpen doctor auth --output json"
        },
        "turnkey_bundle_status": {
          "type": "string",
          "enum": [
            "not_checked"
          ]
        },
        "turnkey_bundle_next_command": {
          "type": "string",
          "const": "bullpen doctor auth --output json"
        }
      }
    },
    "health": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "clob_api_key_present",
        "clob_readiness_next_command",
        "clob_readiness_status",
        "logged_in",
        "token_valid"
      ],
      "properties": {
        "logged_in": {
          "type": "boolean"
        },
        "token_valid": {
          "type": "boolean"
        },
        "clob_api_key_present": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Null in passive status because CLOB authentication is not checked."
        },
        "clob_readiness_status": {
          "type": "string",
          "enum": [
            "not_checked"
          ]
        },
        "clob_readiness_next_command": {
          "type": "string",
          "const": "bullpen polymarket wallet-audit --refresh --include-order-credit --output json"
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "polymarket_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "token_expires_in_seconds": {
          "type": [
            "integer",
            "null"
          ]
        },
        "token_timing": {
          "type": [
            "object",
            "null"
          ]
        },
        "wallet_kind": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "trading_access": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "proxy_routes_prediction_trades",
        "signer_source",
        "trade_server_url"
      ],
      "properties": {
        "proxy_routes_prediction_trades": {
          "type": "boolean"
        },
        "signer_source": {
          "type": "string",
          "minLength": 1
        },
        "trade_server_url": {
          "$ref": "#/$defs/http_url"
        },
        "deposit_wallet_address": {
          "type": [
            "string",
            "null"
          ]
        },
        "wallet_kind": {
          "type": [
            "string",
            "null"
          ]
        },
        "wallet_kind_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "note": {
          "type": "string"
        }
      }
    },
    "polymarket": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "components",
        "detail",
        "next_command",
        "status",
        "status_url"
      ],
      "properties": {
        "status": {
          "type": "string",
          "const": "not_checked"
        },
        "status_url": {
          "$ref": "#/$defs/http_url"
        },
        "components": {
          "type": "array",
          "maxItems": 0,
          "items": {
            "$ref": "#/$defs/status_component"
          }
        },
        "detail": {
          "type": "string"
        },
        "next_command": {
          "type": "string",
          "const": "bullpen polymarket status --output json"
        }
      }
    },
    "status_component": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "name",
        "status"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "polymarket_wallet_evidence": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "status",
        "source_command"
      ],
      "properties": {
        "status": {
          "type": "string",
          "minLength": 1
        },
        "source_command": {
          "type": "string",
          "minLength": 1
        },
        "reason": {
          "type": "string"
        },
        "report": {
          "$ref": "#/$defs/wallet_audit_report"
        }
      }
    },
    "wallet_audit_report": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "selected_wallet_trade_readiness": {
          "$ref": "#/$defs/selected_wallet_trade_readiness"
        },
        "clob_route_readiness": {
          "$ref": "#/$defs/clob_route_readiness"
        }
      }
    },
    "selected_wallet_trade_readiness": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "status",
        "authenticated_selected_client_binding",
        "balances_checked",
        "allowances_checked",
        "approvals_checked",
        "close_only_policy_checked",
        "deployment_checked",
        "relayer_checked",
        "agreements_checked",
        "api_key_checked"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "complete"
          ]
        },
        "authenticated_selected_client_binding": {
          "type": "boolean",
          "const": true
        },
        "balances_checked": {
          "type": "boolean",
          "const": true
        },
        "allowances_checked": {
          "type": "boolean",
          "const": true
        },
        "approvals_checked": {
          "type": "boolean",
          "const": true
        },
        "close_only_policy_checked": {
          "type": "boolean",
          "const": true
        },
        "deployment_checked": {
          "type": "boolean",
          "const": true
        },
        "relayer_checked": {
          "type": "boolean",
          "const": true
        },
        "agreements_checked": {
          "type": "boolean",
          "const": true
        },
        "api_key_checked": {
          "type": "boolean",
          "const": true
        }
      }
    },
    "clob_route_readiness": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "status": {
          "type": "string"
        },
        "trade_ready": {
          "type": "boolean"
        },
        "checked": {
          "type": "boolean"
        },
        "order_credit_status": {
          "type": "string"
        },
        "order_credit_checked": {
          "type": "boolean"
        }
      }
    },
    "prediction_trading_readiness": {
      "type": "object",
      "additionalProperties": true,
      "description": "Evidence-backed prediction-trading readiness shared by JSON, table, and TUI status. Passive status does not initiate signer-backed order-credit authentication; next_command names the explicit diagnostic when that evidence is absent.",
      "required": [
        "status",
        "label",
        "detail",
        "next_command"
      ],
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "ready",
            "not_checked",
            "action_needed"
          ]
        },
        "label": {
          "type": "string",
          "enum": [
            "Ready",
            "Not checked",
            "Action needed"
          ]
        },
        "detail": {
          "type": [
            "string",
            "null"
          ]
        },
        "next_command": {
          "type": "string",
          "pattern": "^bullpen ",
          "minLength": 1
        }
      }
    },
    "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
        }
      }
    },
    "skill": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "name",
        "outdated",
        "version"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "outdated": {
          "type": "boolean"
        },
        "version": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "solana": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "enabled"
      ],
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "jupiter_base_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "referral_account": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "support": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "docs",
        "bug_reports",
        "file_a_ticket"
      ],
      "properties": {
        "docs": {
          "$ref": "#/$defs/http_url"
        },
        "bug_reports": {
          "$ref": "#/$defs/http_url"
        },
        "file_a_ticket": {
          "$ref": "#/$defs/http_url"
        }
      }
    },
    "community": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "discord",
        "x"
      ],
      "properties": {
        "discord": {
          "$ref": "#/$defs/http_url"
        },
        "x": {
          "$ref": "#/$defs/http_url"
        }
      }
    }
  }
}
