{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tradecat.local/contracts/tradecat-auto-paper-ops-report.schema.json",
  "title": "TradeCat Auto Paper Ops Report",
  "description": "Local operations preflight report for the public-readonly paper/watch auto-paper runtime.",
  "type": "object",
  "required": [
    "schema",
    "schema_version",
    "ok",
    "mode",
    "command",
    "action",
    "generated_at",
    "dependency_chain",
    "runtime",
    "systemd",
    "checks",
    "blocking_checks",
    "operations",
    "safety"
  ],
  "properties": {
    "schema": {
      "const": "tradecat_auto.paper_ops_report.v1"
    },
    "schema_version": {
      "const": "1.0.0"
    },
    "ok": {
      "type": "boolean"
    },
    "mode": {
      "const": "paper"
    },
    "command": {
      "const": "auto-paper-service"
    },
    "action": {
      "const": "ops-check"
    },
    "generated_at": {
      "type": "string"
    },
    "dependency_chain": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "runtime": {
      "type": "object",
      "required": ["runtime_dir", "state_path", "ledger_path", "archive_path", "journal_path", "log_file", "pid_file"],
      "additionalProperties": true
    },
    "systemd": {
      "type": "object",
      "required": [
        "user_dir",
        "service_unit",
        "timer_unit",
        "start_limit_burst",
        "start_limit_interval_seconds",
        "restart_sec",
        "timeout_start_seconds",
        "limit_nofile",
        "tasks_max"
      ],
      "additionalProperties": true
    },
    "checks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "ok", "severity", "message"],
        "properties": {
          "id": {
            "type": "string"
          },
          "ok": {
            "type": "boolean"
          },
          "severity": {
            "enum": ["info", "warn", "block"]
          },
          "message": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "blocking_checks": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "operations": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "safety": {
      "type": "object",
      "required": [
        "public_readonly_market_data",
        "public_readonly",
        "paper_or_watch_only",
        "real_orders",
        "signed_requests",
        "reads_api_keys",
        "binance_account_state"
      ],
      "properties": {
        "public_readonly_market_data": {
          "const": true
        },
        "public_readonly": {
          "const": true
        },
        "paper_or_watch_only": {
          "const": true
        },
        "real_orders": {
          "const": false
        },
        "signed_requests": {
          "const": false
        },
        "reads_api_keys": {
          "const": false
        },
        "binance_account_state": {
          "const": false
        }
      },
      "additionalProperties": true
    },
    "error": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
