{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vedika-io/json-schema/vedika-io-vastu-plan-analyze-request-schema.json",
  "title": "VastuPlanAnalyzeRequest",
  "description": "Source-derived request for plan/analyze. Fields not listed here are ignored. Explicit units/inputUnits is recommended for interchange. Omitted units retain legacy coordinate behavior.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vedika-io-openapi.json#/components/schemas/VastuPlanAnalyzeRequest",
  "type": "object",
  "required": [
    "rooms"
  ],
  "properties": {
    "rooms": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Room name as written or drawn; shown back unchanged. When it is not a known room type, room, roomType, label and type are tried in that order and the first known one classifies the room."
          },
          "room": {
            "type": "string"
          },
          "roomType": {
            "type": "string",
            "description": "Clean room type (for example kitchen). Used to classify the room when name is a drawing label the model cannot read, such as a CAD abbreviation or text in another language."
          },
          "label": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "Alias for roomType, tried last."
          },
          "zone": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "x": {
            "type": "number"
          },
          "y": {
            "type": "number"
          },
          "w": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "h": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "width": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "height": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true
          },
          "polygon": {
            "type": "array",
            "minItems": 3,
            "items": {
              "oneOf": [
                {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": {
                    "type": "number"
                  }
                },
                {
                  "type": "object",
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "description": "A simple (non-self-crossing) room outline inside the plot frame."
          },
          "outline": {
            "type": "array",
            "minItems": 3,
            "items": {
              "oneOf": [
                {
                  "type": "array",
                  "minItems": 2,
                  "maxItems": 2,
                  "items": {
                    "type": "number"
                  }
                },
                {
                  "type": "object",
                  "required": [
                    "x",
                    "y"
                  ],
                  "properties": {
                    "x": {
                      "type": "number"
                    },
                    "y": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false
                }
              ]
            },
            "description": "A simple (non-self-crossing) room outline inside the plot frame."
          },
          "area": {
            "type": "number",
            "minimum": 0
          },
          "headingErrorDeg": {
            "type": "number",
            "minimum": 0,
            "maximum": 180,
            "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
          },
          "positionErrorM": {
            "type": "number",
            "minimum": 0,
            "maximum": 10000,
            "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
          },
          "holes": {
            "type": "array",
            "maxItems": 64,
            "items": {
              "$ref": "#/$defs/VastuPlanPolygon"
            }
          },
          "multipolygons": {
            "type": "array",
            "minItems": 1,
            "maxItems": 32,
            "items": {
              "$ref": "#/$defs/VastuPlanRegion"
            },
            "description": "Disjoint filled wings. Send either polygon with holes or multipolygons."
          }
        },
        "additionalProperties": false,
        "anyOf": [
          {
            "required": [
              "name"
            ]
          },
          {
            "required": [
              "room"
            ]
          },
          {
            "required": [
              "roomType"
            ]
          },
          {
            "required": [
              "label"
            ]
          }
        ],
        "description": "Each room needs a label and EITHER a zone/direction, a rectangle {x, y, w, h} (w/h may be sent as width/height) that lies inside the plot frame (1% tolerance), or a polygon/outline. If a room carries both a zone and geometry (a rectangle or a polygon) that lies in a different zone of the plot, the geometry decides the zone: the room is scored there, roomByRoom shows statedZone and zoneConflict, and warnings lists it."
      }
    },
    "plot": {
      "type": "object",
      "additionalProperties": true
    },
    "zoneResolution": {
      "type": "integer",
      "enum": [
        8,
        16,
        32
      ],
      "default": 8,
      "description": "Compass subdivisions for the traced-outline sector reading (tracedGeometry). Used only with plot.polygon."
    },
    "headingErrorDeg": {
      "type": "number",
      "minimum": 0,
      "maximum": 180,
      "description": "Symmetric heading bound in degrees. Optional; absent preserves existing output exactly."
    },
    "positionErrorM": {
      "type": "number",
      "minimum": 0,
      "maximum": 10000,
      "description": "Euclidean position-disc radius in metres. Requires point geometry and an explicit plot frame. Metre geometry is the default; plot.units=ft converts coordinates using the international foot. The plot frame is held fixed."
    },
    "importReview": {
      "type": "object",
      "properties": {
        "northKnown": {
          "type": "boolean"
        },
        "scaleKnown": {
          "type": "boolean"
        },
        "analysisReady": {
          "type": "boolean"
        },
        "coordinateFrame": {
          "type": "string",
          "enum": [
            "north-up",
            "drawing-up"
          ]
        },
        "units": {
          "type": "string",
          "enum": [
            "m",
            "drawing-units"
          ]
        }
      },
      "required": [
        "northKnown",
        "scaleKnown",
        "analysisReady",
        "coordinateFrame",
        "units"
      ]
    },
    "merchantCatalogId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_-]{1,128}$"
    },
    "rulesVersion": {
      "type": "string",
      "enum": [
        "vastu-rules-2026-09-23",
        "vastu-rules-2026-10-04",
        "vastu-rules-2026-10-18",
        "vastu-rules-2026-10-20"
      ],
      "description": "Pin an immutable retained room-placement ruleset; omitted selects current. Geometry normalization is shared. vastu-rules-2026-09-23 is deprecated: it stays accepted until its sunset on 2027-01-31, so move to vastu-rules-2026-10-20. A response that applied it carries Deprecation, Sunset and Link headers."
    },
    "receipt": {
      "type": "boolean",
      "default": false,
      "description": "Return a signed Ed25519 JWS receipt. Missing signing key returns 503 before billing."
    },
    "propertyId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "tenantRef": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_.\\-/]+$",
      "description": "Buyer-supplied non-secret attribution identifier. Account-scoped; does not grant property access."
    },
    "units": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    },
    "inputUnits": {
      "type": "string",
      "enum": [
        "m",
        "ft",
        "mm",
        "in"
      ],
      "description": "Linear plan coordinates and unsuffixed dimensions use this unit. area fields use its square. Internally normalized once to metres; fields explicitly suffixed M/M2 remain metres."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "VastuPlanPolygon": {
      "type": "array",
      "minItems": 3,
      "items": {
        "oneOf": [
          {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          },
          {
            "type": "object",
            "required": [
              "x",
              "y"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              }
            },
            "additionalProperties": true
          }
        ]
      },
      "description": "Traced ring as [x, y] pairs or {x, y} objects. Coordinates must be finite numbers. Runtime also requires at least three distinct corners enclosing nonzero area."
    },
    "VastuPlanRegion": {
      "type": "object",
      "required": [
        "polygon"
      ],
      "properties": {
        "polygon": {
          "$ref": "#/$defs/VastuPlanPolygon"
        },
        "holes": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "$ref": "#/$defs/VastuPlanPolygon"
          }
        }
      },
      "description": "Filled outer boundary minus disjoint interior rings. Voids must lie strictly inside."
    }
  }
}