{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "SW R06 geometry handoff",
  "type": "object",
  "required": [
    "schema_version",
    "package_id",
    "status",
    "acceptance",
    "coordinate_frames",
    "features",
    "meshes",
    "engine_adapter",
    "axis_controls",
    "source_topology",
    "target_register"
  ],
  "properties": {
    "schema_version": {
      "const": "1.0.0"
    },
    "package_id": {
      "const": "SW-GEOMETRY-HANDOFF-R06"
    },
    "status": {
      "const": "TEST_ONLY_REVIEW_HANDOFF"
    },
    "features": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/feature"
      }
    },
    "meshes": {
      "type": "array",
      "minItems": 3,
      "items": {
        "$ref": "#/$defs/mesh"
      }
    }
  },
  "$defs": {
    "point": {
      "type": "array",
      "minItems": 2,
      "maxItems": 3,
      "items": {
        "type": "number"
      }
    },
    "geometry": {
      "type": "object",
      "required": [
        "type",
        "coordinates"
      ],
      "properties": {
        "type": {
          "enum": [
            "Point",
            "LineString",
            "Polygon"
          ]
        },
        "coordinates": {
          "type": "array"
        }
      }
    },
    "feature": {
      "type": "object",
      "required": [
        "id",
        "role",
        "frame_id",
        "classification",
        "geometry",
        "source_ids",
        "approved_for_construction"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string"
        },
        "frame_id": {
          "enum": [
            "MASTER-PIXELS-20261010",
            "SW-CK-AUTHORING-R03",
            "SW-R06-SPECIMEN-LOCAL-M"
          ]
        },
        "classification": {
          "enum": [
            "source_pixel",
            "historical_metric",
            "proposed_metric",
            "test_only",
            "measured_metric"
          ]
        },
        "geometry": {
          "$ref": "#/$defs/geometry"
        },
        "source_ids": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        },
        "approved_for_construction": {
          "const": false
        }
      }
    },
    "mesh": {
      "type": "object",
      "required": [
        "id",
        "feature_id",
        "classification",
        "vertices_m",
        "triangles"
      ],
      "properties": {
        "classification": {
          "const": "test_only"
        },
        "vertices_m": {
          "type": "array",
          "minItems": 3,
          "items": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "type": "number"
            }
          }
        },
        "triangles": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      }
    }
  },
  "$comment": "Semantic checks (finite coordinates, IDs, closed rings, topology, unit/axis rules, source hashes, analytic grades/clearance, target counts, unscaled historical context and acceptance gates) are enforced by tools/sw_geometry/validate.py."
}
