{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://theamateur.co.uk/schemas/dpl/dpl.replan-1.schema.json",
  "title": "DPL replan result (dpl.replan/1)",
  "description": "What `dpl replan <plan> <constraints.json> --format json` writes: whether the shoot constraints were met, what was given up to meet them (each sacrifice with what it cost the edit), and the edit-readiness findings of the revised plan. When the constraints cannot be met, `unmet` says which limit failed and `unmet_fix` says by how much and what could be relaxed. Every member listed here is always written, or left out when null; nothing else appears.",
  "$comment": "`plan` is the path the revised plan was written to (`--out`), or \"(not written)\". `findings` is a dpl.findings/1 document, defined in dpl.findings-1.schema.json, which must be loaded under its id. The exit code is 0 when the constraints were met and 3 when not.",
  "type": "object",
  "properties": {
    "met": {
      "type": "boolean"
    },
    "unmet": {
      "type": [
        "string",
        "null"
      ]
    },
    "shots_before": {
      "type": "integer",
      "minimum": 0
    },
    "shots_after": {
      "type": "integer",
      "minimum": 0
    },
    "setups_before": {
      "type": "integer",
      "minimum": 0
    },
    "setups_after": {
      "type": "integer",
      "minimum": 0
    },
    "sacrifices": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Sacrifice"
      }
    },
    "kept": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "plan": {
      "type": "string"
    },
    "findings": {
      "description": "Edit-readiness of the revised plan: a dpl.findings/1 document.",
      "$ref": "https://theamateur.co.uk/schemas/dpl/dpl.findings-1.schema.json"
    },
    "unmet_fix": {
      "type": [
        "string",
        "null"
      ]
    },
    "limits": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "#/$defs/LimitReport"
      }
    },
    "format": {
      "type": "string",
      "const": "dpl.replan/1"
    }
  },
  "required": [
    "met",
    "shots_before",
    "shots_after",
    "setups_before",
    "setups_after",
    "sacrifices",
    "kept",
    "plan",
    "findings",
    "format"
  ],
  "additionalProperties": false,
  "$defs": {
    "CoveragePriority": {
      "type": "string",
      "description": "How much the edit depends on a shot: a must cannot be dropped without losing the scene's job.",
      "enum": [
        "must",
        "should",
        "nice"
      ]
    },
    "LimitReport": {
      "type": "object",
      "description": "One limit the shoot asked for, and where it stands: what was asked, what the plan needed before the replan, what it needs now, and whether it is met. Present only when the constraints asked for a limit that came with replan v2.",
      "properties": {
        "limit": {
          "type": "string"
        },
        "asked": {
          "type": "string"
        },
        "before": {
          "type": "string"
        },
        "after": {
          "type": "string"
        },
        "met": {
          "type": "boolean"
        }
      },
      "required": [
        "limit",
        "asked",
        "before",
        "after",
        "met"
      ],
      "additionalProperties": false
    },
    "Sacrifice": {
      "type": "object",
      "description": "One thing given up to meet the constraints, and what it cost the edit.",
      "properties": {
        "shots": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "scene": {
          "type": "string"
        },
        "purpose": {
          "type": "string"
        },
        "priority": {
          "$ref": "#/$defs/CoveragePriority"
        },
        "introduces": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "because": {
          "type": [
            "string",
            "null"
          ]
        },
        "scenes_dropped": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "shots",
        "scene",
        "purpose",
        "priority",
        "introduces"
      ],
      "additionalProperties": false
    }
  }
}
