{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tradecat.local/contracts/tradecat-auto-latest-decision-report.schema.json",
  "title": "TradeCat Auto Latest Decision Report",
  "description": "Latest auditable Agent/TradeCat paper decision text from the local service-cycle archive.",
  "type": "object",
  "required": [
    "schema",
    "schema_version",
    "ok",
    "error_code",
    "archive_path",
    "text",
    "provenance",
    "safety",
    "limitations"
  ],
  "properties": {
    "schema": {
      "const": "tradecat_auto.latest_decision_report.v1"
    },
    "schema_version": {
      "const": "1.0.0"
    },
    "ok": {
      "type": "boolean"
    },
    "error_code": {
      "type": [
        "string",
        "null"
      ]
    },
    "archive_path": {
      "type": "string"
    },
    "symbol": {
      "type": [
        "string",
        "null"
      ]
    },
    "direction": {
      "type": [
        "string",
        "null"
      ]
    },
    "risk_decision": {
      "type": [
        "string",
        "null"
      ]
    },
    "paper_execution_status": {
      "type": [
        "string",
        "null"
      ]
    },
    "text": {
      "type": "string"
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "title",
          "text"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "text": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "cycle_summary": {
      "$ref": "#/$defs/cycle_summary"
    },
    "cycle": {
      "type": "object",
      "additionalProperties": true
    },
    "provenance": {
      "type": "object",
      "required": [
        "source",
        "archive_path"
      ],
      "properties": {
        "source": {
          "const": "local_tradecat_cycle_archive"
        },
        "archive_path": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "safety": {
      "$ref": "#/$defs/safety"
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "additionalProperties": true,
  "$defs": {
    "cycle_summary": {
      "type": "object",
      "required": [
        "schema",
        "schema_version",
        "error_code",
        "provenance",
        "safety"
      ],
      "properties": {
        "schema": {
          "const": "tradecat_auto.latest_cycle_summary.v1"
        },
        "schema_version": {
          "const": "1.0.0"
        },
        "error_code": {
          "type": [
            "string",
            "null"
          ]
        },
        "provenance": {
          "type": "object",
          "required": [
            "source"
          ],
          "properties": {
            "source": {
              "const": "tradecat_auto.production_control.cycle_summary"
            }
          },
          "additionalProperties": true
        },
        "safety": {
          "$ref": "#/$defs/safety"
        }
      },
      "additionalProperties": true
    },
    "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
    }
  }
}
