{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/control.schema.json",
  "title": "control",
  "type": "object",
  "required": [
    "max",
    "current",
    "mode"
  ],
  "properties": {
    "max": {
      "description": "The autonomy ceiling a person set, 0 to 5 (Part 2, Section 7). Changed with PUT /heart/v1/tending/autonomy. Stop sets it to 2.",
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "x-heart-privacy": "public"
    },
    "current": {
      "description": "Autonomy Level right now: the lowest of max, the promised level and what the system can deliver now (Pulse autonomy.current).",
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "x-heart-privacy": "public"
    },
    "mode": {
      "enum": [
        "observe",
        "suggest",
        "act"
      ],
      "x-heart-privacy": "public",
      "description": "Read only, worked out from current: 0 to 2 observe, 3 suggest, 4 and 5 act.",
      "readOnly": true
    },
    "stoppedAt": {
      "$ref": "common.schema.json#/$defs/timestamp",
      "x-heart-privacy": "public"
    },
    "reason": {
      "type": "string",
      "x-heart-privacy": "internal"
    },
    "stoppedBy": {
      "type": "string",
      "x-heart-privacy": "private"
    },
    "ext": {
      "$ref": "common.schema.json#/$defs/ext",
      "x-heart-privacy": "private"
    },
    "allowlist": {
      "description": "Write actions that may run without asking each time (Part 6, Section 2.3). Never destructive. An entry matches an Action when it names the target, the Action's initiator kind is in initiators, and every argument the Action changes is inside the envelope. An entry for a target with no arguments needs no envelope. Changed with PUT /heart/v1/tending/allowlist.",
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "target",
          "initiators"
        ],
        "additionalProperties": false,
        "properties": {
          "target": {
            "type": "string"
          },
          "initiators": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "rule",
                "ai",
                "peer"
              ]
            }
          },
          "envelope": {
            "$ref": "common.schema.json#/$defs/changeEnvelope"
          }
        }
      },
      "x-heart-privacy": "internal"
    },
    "approvalTimeoutSec": {
      "description": "How long an Action waits for approval before it expires (its expiresAt).",
      "type": "integer",
      "minimum": 60,
      "default": 86400,
      "x-heart-privacy": "internal"
    },
    "remoteSitePhysical": {
      "description": "True if the owner, on the device, allowed approvals by a remote site (presence method remote-site) for physical Actions. Default false.",
      "type": "boolean",
      "default": false,
      "x-heart-privacy": "internal"
    },
    "fleetPhysical": {
      "description": "True if the owner, on the device, allowed fleet approvals signed by the pinned Gateway (presence method fleet) for physical Actions. Default false.",
      "type": "boolean",
      "default": false,
      "x-heart-privacy": "internal"
    }
  }
}
