{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/proposal.schema.json",
  "title": "proposal",
  "description": "A change a brain suggests (Core Standard, Section 7.3). Never a command: the Core checks it, reads the current values itself, and it passes the gate as an Action with initiator 'ai'.",
  "type": "object",
  "required": [
    "id",
    "target",
    "arguments",
    "expect",
    "undoIf",
    "basis",
    "createdAt"
  ],
  "properties": {
    "id": {
      "$ref": "common.schema.json#/$defs/uuid",
      "x-heart-privacy": "internal"
    },
    "consultationId": {
      "$ref": "common.schema.json#/$defs/uuid",
      "x-heart-privacy": "internal"
    },
    "problemCode": {
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "target": {
      "type": "string",
      "x-heart-privacy": "internal",
      "description": "A capability in the System Map whose callers include 'ai'."
    },
    "arguments": {
      "type": "object",
      "x-heart-privacy": "internal",
      "description": "The final value or values. The last step, if steps are given, MUST equal these."
    },
    "steps": {
      "description": "How to get there in stages. Absent: one step.",
      "type": "array",
      "minItems": 1,
      "maxItems": 20,
      "items": {
        "type": "object",
        "required": [
          "arguments"
        ],
        "properties": {
          "arguments": {
            "type": "object"
          },
          "waitSec": {
            "type": "integer",
            "minimum": 0,
            "maximum": 86400,
            "description": "How long to wait after this step before the next one."
          }
        },
        "additionalProperties": false
      },
      "x-heart-privacy": "internal"
    },
    "expect": {
      "description": "All must hold for the change to be kept.",
      "type": "array",
      "minItems": 1,
      "maxItems": 8,
      "items": {
        "$ref": "common.schema.json#/$defs/check"
      },
      "x-heart-privacy": "internal"
    },
    "undoIf": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": false,
      "properties": {
        "any": {
          "description": "Undo if any of these holds while watching.",
          "type": "array",
          "maxItems": 8,
          "items": {
            "$ref": "common.schema.json#/$defs/check"
          }
        },
        "newAlert": {
          "description": "Undo if an alert of at least this severity appears.",
          "$ref": "common.schema.json#/$defs/severity"
        }
      },
      "x-heart-privacy": "internal"
    },
    "basis": {
      "description": "Why, in plain language.",
      "type": "string",
      "maxLength": 1000,
      "x-heart-privacy": "internal"
    },
    "confidence": {
      "$ref": "common.schema.json#/$defs/confidence",
      "x-heart-privacy": "internal"
    },
    "brain": {
      "type": "object",
      "properties": {
        "tier": {
          "description": "Where the brain is: local, gateway, cloud or fleet.",
          "$ref": "common.schema.json#/$defs/tier"
        },
        "model": {
          "type": "string"
        },
        "receiptId": {
          "$ref": "common.schema.json#/$defs/uuid"
        }
      },
      "x-heart-privacy": "internal",
      "additionalProperties": false
    },
    "createdAt": {
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "internal"
    },
    "signed": {
      "$ref": "common.schema.json#/$defs/brainSignature",
      "description": "Set by a Command Center: this Proposal is its signed answer to the Consultation consultationId (API Standard 7.4 rule 5). A system with the brain module refuses a Proposal without it."
    },
    "ext": {
      "$ref": "common.schema.json#/$defs/ext",
      "x-heart-privacy": "private"
    }
  },
  "additionalProperties": false
}
