{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://teamshift.io/human-api/task-spec/v1/common.schema.json",
  "title": "Shared definitions for the open physical task spec v1",
  "$defs": {
    "zip": {
      "type": "string",
      "pattern": "^[0-9]{5}$",
      "description": "US ZIP code."
    },
    "location": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "address",
        "zip"
      ],
      "properties": {
        "address": {
          "type": "string",
          "minLength": 5,
          "maxLength": 300,
          "description": "Street address. Shown only to the person who takes the task."
        },
        "zip": {
          "$ref": "#/$defs/zip"
        },
        "site": {
          "$ref": "#/$defs/site"
        }
      }
    },
    "site": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "lat",
        "lng"
      ],
      "description": "The point the geofence is measured from.",
      "properties": {
        "lat": {
          "type": "number",
          "minimum": -90,
          "maximum": 90
        },
        "lng": {
          "type": "number",
          "minimum": -180,
          "maximum": 180
        },
        "radius_m": {
          "type": "integer",
          "minimum": 25,
          "maximum": 5000,
          "default": 250
        }
      }
    },
    "window": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "start",
        "end"
      ],
      "description": "When the task may be done.",
      "properties": {
        "start": {
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "instructions": {
      "type": "string",
      "maxLength": 1000
    },
    "proof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "shots"
      ],
      "description": "What counts as proof and how it is captured.",
      "properties": {
        "shots": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10,
          "description": "Distinct photos required. Reused photos never count."
        },
        "shot_list": {
          "type": "array",
          "maxItems": 10,
          "items": {
            "type": "string",
            "maxLength": 120
          },
          "description": "What each photo should show, in order."
        },
        "geofence_radius_m": {
          "type": "integer",
          "minimum": 25,
          "maximum": 5000,
          "default": 250,
          "description": "A photo located farther than this from the site is flagged."
        },
        "capture_window": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "not_before": {
              "const": "dispatch",
              "default": "dispatch",
              "description": "Photos taken before the task went out are flagged."
            },
            "not_after": {
              "type": "string",
              "format": "date-time"
            }
          }
        },
        "channel": {
          "enum": [
            "capture_link",
            "mms"
          ],
          "default": "capture_link",
          "description": "capture_link: a signed page that records time and browser location. mms: a photo reply by text, which usually loses photo metadata."
        }
      }
    },
    "risk_tier": {
      "enum": [
        "exterior",
        "interior",
        "entry"
      ],
      "description": "exterior: from public ground or the yard. interior: inside a building. entry: the person gets a key, code or lockbox. Interior and entry need a background check from the last 365 days and at least $1M liability insurance."
    },
    "note": {
      "type": "string",
      "maxLength": 1000
    }
  }
}
