{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "shot_aware_bg_render_plan_v1",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "graph": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "nodes": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "bg_id": {"type": "string", "minLength": 1},
              "node_index": {"type": "integer", "minimum": 0},
              "mode": {
                "type": "string",
                "enum": [
                  "fp_seeded_anchor",
                  "reference_derived",
                  "style_reference_new_space",
                  "two_refs_distinct_spaces"
                ]
              },
              "is_dwelling_identity_anchor": {"type": "boolean"},
              "rationale": {"type": "string", "minLength": 1},
              "reference_decision": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "selected_refs": {
                    "type": "array",
                    "maxItems": 2,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "ref_bg_id": {"type": "string", "minLength": 1},
                        "physical_space_id": {"type": "string", "minLength": 1},
                        "space_description": {
                          "type": ["string", "null"]
                        }
                      },
                      "required": ["ref_bg_id", "physical_space_id"]
                    }
                  },
                  "rejected_refs": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "ref_bg_id": {"type": "string", "minLength": 1},
                        "reason": {"type": "string", "minLength": 1}
                      },
                      "required": ["ref_bg_id", "reason"]
                    }
                  },
                  "same_physical_space_dedup_decision": {"type": "string"},
                  "why_single_ref_or_two_refs": {"type": "string"},
                  "physical_space_id_per_ref": {
                    "type": "array",
                    "maxItems": 2,
                    "items": {"type": "string", "minLength": 1}
                  }
                },
                "required": [
                  "selected_refs",
                  "rejected_refs",
                  "same_physical_space_dedup_decision",
                  "why_single_ref_or_two_refs",
                  "physical_space_id_per_ref"
                ]
              },
              "camera_decision": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "camera_unit": {"type": "integer"},
                  "camera_cell": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": {"type": "integer", "minimum": 0}
                  },
                  "look_at_unit": {"type": "integer"},
                  "look_at_cell": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": {"type": "integer", "minimum": 0}
                  },
                  "lens_enum": {
                    "type": "string",
                    "enum": ["wide", "normal", "telephoto"]
                  },
                  "fov_deg": {"type": "integer", "minimum": 1, "maximum": 180},
                  "framing_notes": {"type": "string"}
                },
                "required": [
                  "camera_unit",
                  "camera_cell",
                  "look_at_unit",
                  "look_at_cell",
                  "lens_enum",
                  "fov_deg"
                ]
              }
            },
            "required": [
              "bg_id",
              "node_index",
              "mode",
              "is_dwelling_identity_anchor",
              "rationale",
              "reference_decision",
              "camera_decision"
            ]
          }
        }
      },
      "required": ["nodes"]
    }
  },
  "required": ["graph"]
}
