{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://teamshift.io/human-api/task-spec/v1/site_check.schema.json",
  "title": "Site check with a checklist",
  "description": "Up to 30 minutes on site, including going inside with access you arrange.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "task_type",
    "spec_version",
    "risk_tier",
    "inputs",
    "proof"
  ],
  "properties": {
    "task_type": {
      "const": "site_check"
    },
    "spec_version": {
      "const": "1"
    },
    "risk_tier": {
      "enum": [
        "exterior",
        "interior",
        "entry"
      ],
      "default": "interior"
    },
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "location",
        "checklist"
      ],
      "properties": {
        "location": {
          "$ref": "common.schema.json#/$defs/location"
        },
        "window": {
          "$ref": "common.schema.json#/$defs/window"
        },
        "instructions": {
          "$ref": "common.schema.json#/$defs/instructions"
        },
        "checklist": {
          "type": "array",
          "minItems": 1,
          "maxItems": 30,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "question",
              "answer"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[a-z][a-z0-9_]{0,39}$",
                "examples": [
                  "gate_closed"
                ]
              },
              "question": {
                "type": "string",
                "maxLength": 200,
                "examples": [
                  "Is the back gate closed and latched?"
                ]
              },
              "answer": {
                "enum": [
                  "boolean",
                  "number",
                  "text",
                  "choice"
                ]
              },
              "choices": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 60
                },
                "maxItems": 10
              }
            }
          }
        },
        "access": {
          "type": "string",
          "maxLength": 300,
          "description": "Who meets the person or where to check in, for interior and entry. Leave door codes and lockbox numbers out."
        }
      }
    },
    "proof": {
      "allOf": [
        {
          "$ref": "common.schema.json#/$defs/proof"
        }
      ],
      "default": {
        "shots": 3,
        "geofence_radius_m": 250,
        "capture_window": {
          "not_before": "dispatch"
        },
        "channel": "capture_link"
      }
    },
    "output": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "answers"
      ],
      "properties": {
        "answers": {
          "type": "object",
          "maxProperties": 30,
          "description": "One value per checklist id, typed by its answer kind, for example {\"gate_closed\": true}.",
          "propertyNames": {
            "pattern": "^[a-z][a-z0-9_]{0,39}$"
          },
          "additionalProperties": {
            "type": [
              "boolean",
              "number",
              "string"
            ],
            "maxLength": 500
          }
        },
        "note": {
          "$ref": "common.schema.json#/$defs/note"
        }
      }
    }
  }
}
