{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/reason-request.schema.json",
  "title": "Reason request",
  "description": "Provider-neutral reasoning call. Trusted instructions and untrusted context are structurally separate.",
  "type": "object",
  "required": [
    "task",
    "instructions"
  ],
  "properties": {
    "task": {
      "description": "Short label such as diagnose, explain, summarize, plan.",
      "type": "string"
    },
    "instructions": {
      "description": "Trusted text written by the system. Never contains peer, user or log content.",
      "type": "string"
    },
    "context": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "trust",
          "privacy",
          "content"
        ],
        "properties": {
          "label": {
            "type": "string"
          },
          "trust": {
            "enum": [
              "trusted",
              "untrusted"
            ]
          },
          "privacy": {
            "$ref": "common.schema.json#/$defs/messageLevel"
          },
          "content": {
            "type": [
              "string",
              "object",
              "array"
            ]
          }
        }
      }
    },
    "conversation": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "enum": [
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string"
          }
        }
      }
    },
    "tools": {
      "type": "array",
      "items": {
        "$ref": "card.schema.json#/$defs/capability"
      }
    },
    "output": {
      "type": "object",
      "required": [
        "format"
      ],
      "properties": {
        "format": {
          "enum": [
            "text",
            "json"
          ]
        },
        "schema": {
          "type": "object"
        }
      }
    },
    "modelPolicy": {
      "type": "object",
      "properties": {
        "prefer": {
          "enum": [
            "quality",
            "cost",
            "speed"
          ]
        },
        "pinned": {
          "type": "object",
          "required": [
            "provider",
            "model"
          ],
          "properties": {
            "provider": {
              "type": "string"
            },
            "model": {
              "type": "string"
            }
          }
        },
        "allowFallback": {
          "type": "boolean",
          "default": true
        },
        "regions": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "maxCostUsd": {
          "type": "number",
          "minimum": 0
        },
        "maxLatencyMs": {
          "type": "integer",
          "minimum": 1
        },
        "maxOutputTokens": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "receiptId": {
      "$ref": "common.schema.json#/$defs/uuid"
    },
    "receiptSalt": {
      "description": "Salt for the Valve receipt's commitment, so the recipient can let an auditor check it (API Standard 4.5).",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{43,}$"
    }
  }
}
