{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:altium-monkey:schema:realized_net_sources_c0",
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "const": "altium_monkey.realized_net_sources.c0"
    },
    "target": {
      "$ref": "#/$defs/NetOccurrence"
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/RealizedSourceOccurrence"
      }
    },
    "issues": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CompilationIssue"
      }
    }
  },
  "required": [
    "schema",
    "target",
    "sources",
    "issues"
  ],
  "unevaluatedProperties": {
    "not": {}
  },
  "$defs": {
    "NetOccurrence": {
      "type": "object",
      "properties": {
        "instance_path": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Identity"
          }
        },
        "net_ref": {
          "$ref": "#/$defs/Identity"
        }
      },
      "required": [
        "instance_path",
        "net_ref"
      ],
      "unevaluatedProperties": {
        "not": {}
      },
      "description": "Query paths traverse composite instances from the loaded root."
    },
    "RealizedSourceOccurrence": {
      "type": "object",
      "properties": {
        "source": {
          "$ref": "#/$defs/SourceOccurrence"
        },
        "realized_page_ref": {
          "$ref": "#/$defs/NullableIdentity"
        }
      },
      "required": [
        "source",
        "realized_page_ref"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "CompilationIssue": {
      "type": "object",
      "properties": {
        "source": {
          "$ref": "#/$defs/SourceOccurrence"
        },
        "target": {
          "$ref": "#/$defs/NetOccurrence"
        },
        "realized_page_ref": {
          "$ref": "#/$defs/CompilationIdentity"
        },
        "reason": {
          "$ref": "#/$defs/CompilationReason"
        }
      },
      "required": [
        "reason"
      ],
      "unevaluatedProperties": {
        "not": {}
      },
      "description": "When present, complete-product page scope names a realized drawing page."
    },
    "Identity": {
      "type": "string",
      "minLength": 1
    },
    "SourceOccurrence": {
      "type": "object",
      "properties": {
        "instance_path": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Identity"
          }
        },
        "source_key": {
          "$ref": "#/$defs/CompiledSourceKey"
        }
      },
      "required": [
        "instance_path",
        "source_key"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "NullableIdentity": {
      "anyOf": [
        {
          "$ref": "#/$defs/Identity"
        },
        {
          "type": "null"
        }
      ]
    },
    "CompilationIdentity": {
      "type": "string",
      "minLength": 1,
      "description": "Opaque local identity; native source selectors are not model references."
    },
    "CompilationReason": {
      "type": "string",
      "minLength": 1
    },
    "CompiledSourceKey": {
      "anyOf": [
        {
          "$ref": "#/$defs/SchematicSourceKey"
        },
        {
          "$ref": "#/$defs/SystemSourceKey"
        },
        {
          "$ref": "#/$defs/SystemDrawingSourceKey"
        }
      ]
    },
    "SchematicSourceKey": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "schematic"
        },
        "document_path": {
          "type": "string"
        },
        "locator": {
          "$ref": "#/$defs/OwnedSourceLocator"
        }
      },
      "required": [
        "kind",
        "document_path",
        "locator"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "SystemSourceKey": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "system"
        },
        "document_path": {
          "type": "string"
        },
        "object_kind": {
          "$ref": "#/$defs/SystemObjectKind"
        },
        "owner_path": {
          "type": "array",
          "items": {
            "type": "integer",
            "minimum": -2147483648,
            "maximum": 2147483647
          },
          "minItems": 1
        }
      },
      "required": [
        "kind",
        "document_path",
        "object_kind",
        "owner_path"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "SystemDrawingSourceKey": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "system_drawing"
        },
        "document_path": {
          "type": "string"
        },
        "page_member": {
          "type": "string"
        },
        "item_id": {
          "type": "integer",
          "minimum": -2147483648,
          "maximum": 2147483647
        }
      },
      "required": [
        "kind",
        "document_path",
        "page_member",
        "item_id"
      ],
      "unevaluatedProperties": {
        "not": {}
      },
      "description": "Authored MBS drawing item, distinct from a logical pin or connection."
    },
    "OwnedSourceLocator": {
      "anyOf": [
        {
          "$ref": "#/$defs/PersistedUidLocator"
        },
        {
          "$ref": "#/$defs/SourceOrdinalLocator"
        }
      ]
    },
    "SystemObjectKind": {
      "anyOf": [
        {
          "type": "string",
          "const": "module"
        },
        {
          "type": "string",
          "const": "entry"
        },
        {
          "type": "string",
          "const": "pin"
        },
        {
          "type": "string",
          "const": "connection"
        },
        {
          "type": "string",
          "const": "physical_connection"
        },
        {
          "type": "string",
          "const": "pin_pair"
        }
      ],
      "description": "Native logical kinds already admitted by the System source inventory."
    },
    "PersistedUidLocator": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "persisted_uid"
        },
        "owner_source_key": {
          "$ref": "#/$defs/NullableSourceKey"
        },
        "record_kind": {
          "$ref": "#/$defs/RecordKind"
        },
        "unique_id": {
          "type": "string"
        }
      },
      "required": [
        "kind",
        "owner_source_key",
        "record_kind",
        "unique_id"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "SourceOrdinalLocator": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "const": "source_ordinal"
        },
        "owner_source_key": {
          "$ref": "#/$defs/NullableSourceKey"
        },
        "record_kind": {
          "$ref": "#/$defs/RecordKind"
        },
        "source_ordinal": {
          "$ref": "#/$defs/Nat"
        }
      },
      "required": [
        "kind",
        "owner_source_key",
        "record_kind",
        "source_ordinal"
      ],
      "unevaluatedProperties": {
        "not": {}
      }
    },
    "NullableSourceKey": {
      "anyOf": [
        {
          "$ref": "#/$defs/SourceKey"
        },
        {
          "type": "null"
        }
      ]
    },
    "RecordKind": {
      "anyOf": [
        {
          "type": "string",
          "const": "line"
        },
        {
          "type": "string",
          "const": "rectangle"
        },
        {
          "type": "string",
          "const": "round_rectangle"
        },
        {
          "type": "string",
          "const": "ellipse"
        },
        {
          "type": "string",
          "const": "arc"
        },
        {
          "type": "string",
          "const": "elliptical_arc"
        },
        {
          "type": "string",
          "const": "polygon"
        },
        {
          "type": "string",
          "const": "polyline"
        },
        {
          "type": "string",
          "const": "bezier"
        },
        {
          "type": "string",
          "const": "pie_chart"
        },
        {
          "type": "string",
          "const": "component"
        },
        {
          "type": "string",
          "const": "pin"
        },
        {
          "type": "string",
          "const": "ieee_symbol"
        },
        {
          "type": "string",
          "const": "label"
        },
        {
          "type": "string",
          "const": "parameter"
        },
        {
          "type": "string",
          "const": "designator"
        },
        {
          "type": "string",
          "const": "image"
        },
        {
          "type": "string",
          "const": "note"
        },
        {
          "type": "string",
          "const": "text_frame"
        },
        {
          "type": "string",
          "const": "wire"
        },
        {
          "type": "string",
          "const": "bus"
        },
        {
          "type": "string",
          "const": "bus_entry"
        },
        {
          "type": "string",
          "const": "junction"
        },
        {
          "type": "string",
          "const": "net_label"
        },
        {
          "type": "string",
          "const": "power_port"
        },
        {
          "type": "string",
          "const": "port"
        },
        {
          "type": "string",
          "const": "no_erc"
        },
        {
          "type": "string",
          "const": "sheet_symbol"
        },
        {
          "type": "string",
          "const": "sheet_entry"
        },
        {
          "type": "string",
          "const": "sheet"
        },
        {
          "type": "string",
          "const": "sheet_name"
        },
        {
          "type": "string",
          "const": "file_name"
        },
        {
          "type": "string",
          "const": "implementation_list"
        },
        {
          "type": "string",
          "const": "implementation"
        },
        {
          "type": "string",
          "const": "map_definer"
        },
        {
          "type": "string",
          "const": "harness_connector"
        },
        {
          "type": "string",
          "const": "harness_entry"
        },
        {
          "type": "string",
          "const": "harness_type"
        },
        {
          "type": "string",
          "const": "signal_harness"
        },
        {
          "type": "string",
          "const": "harness_splice"
        },
        {
          "type": "string",
          "const": "harness_layout_label"
        },
        {
          "type": "string",
          "const": "harness_layout_connection_point"
        },
        {
          "type": "string",
          "const": "harness_bundle"
        },
        {
          "type": "string",
          "const": "harness_covering"
        },
        {
          "type": "string",
          "const": "template"
        },
        {
          "type": "string",
          "const": "parameter_set"
        },
        {
          "type": "string",
          "const": "compile_mask"
        },
        {
          "type": "string",
          "const": "blanket"
        },
        {
          "type": "string",
          "const": "hyperlink"
        },
        {
          "type": "string",
          "const": "file_header"
        },
        {
          "type": "string",
          "const": "map_definer_list"
        },
        {
          "type": "string",
          "const": "impl_params"
        }
      ]
    },
    "Nat": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "JSON-safe nonnegative integer."
    },
    "SourceKey": {
      "type": "string",
      "pattern": "^source:sha256:[0-9a-f]{64}$",
      "description": "Document-scoped source identity digest."
    }
  }
}
