{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/electronics-architect-com/json-schema/electronics-architect-com-compare-response-schema.json",
  "title": "CompareResponse",
  "x-generated": "2026-11-06",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/electronics-architect-com-openapi.json#/components/schemas/CompareResponse",
  "type": "object",
  "properties": {
    "a": {
      "$ref": "#/$defs/CompareSide"
    },
    "b": {
      "$ref": "#/$defs/CompareSide"
    },
    "changes": {
      "type": "object",
      "description": "The document diff, layout ignored.",
      "properties": {
        "nodes": {
          "type": "object",
          "properties": {
            "added": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  }
                }
              }
            },
            "removed": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  }
                }
              }
            },
            "changed": {
              "type": "array",
              "items": {
                "type": "object",
                "description": "id, name, type, then only the parts that differ: `properties` (key → { from, to }), `part` ({ from, to } MPN), `typeChange`, `nameChange`, `tolerances`, `portDirections`."
              }
            }
          }
        },
        "connections": {
          "type": "object",
          "properties": {
            "added": {
              "type": "array",
              "items": {
                "type": "object"
              }
            },
            "removed": {
              "type": "array",
              "items": {
                "type": "object"
              }
            }
          }
        },
        "identical": {
          "type": "boolean"
        }
      }
    },
    "delta": {
      "type": "object",
      "properties": {
        "totalSourcePower": {
          "$ref": "#/$defs/Delta"
        },
        "totalLoadPower": {
          "$ref": "#/$defs/Delta"
        },
        "totalDissipation": {
          "$ref": "#/$defs/Delta"
        },
        "efficiency": {
          "$ref": "#/$defs/Delta"
        },
        "warnings": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/Delta"
          }
        }
      }
    },
    "nodes": {
      "type": "array",
      "description": "Every node present in both whose voltage, current, power or junction temperature moved by more than 1e-9.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "voltage": {
            "$ref": "#/$defs/Delta"
          },
          "current": {
            "$ref": "#/$defs/Delta"
          },
          "power": {
            "$ref": "#/$defs/Delta"
          },
          "temperature": {
            "$ref": "#/$defs/Delta"
          }
        }
      }
    },
    "stages": {
      "type": "array",
      "description": "Converters whose dissipation or efficiency moved.",
      "items": {
        "type": "object",
        "properties": {
          "nodeId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "pdiss": {
            "$ref": "#/$defs/Delta"
          },
          "eff": {
            "$ref": "#/$defs/Delta"
          }
        }
      }
    },
    "warnings": {
      "type": "object",
      "properties": {
        "resolved": {
          "type": "array",
          "items": {
            "type": "object"
          }
        },
        "introduced": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      }
    },
    "yield": {
      "type": "object",
      "description": "Only with options.monteCarlo: trials, thermalViolationRate, protectionTripRate, failedTrials, efficiencyMean, efficiencyP1, powerMean, powerP99 — each a Delta.",
      "additionalProperties": {
        "$ref": "#/$defs/Delta"
      }
    },
    "meta": {
      "type": "object",
      "properties": {
        "schemaVersion": {
          "type": "integer"
        },
        "corner": {
          "type": "string"
        },
        "ambientTemperature": {
          "type": [
            "number",
            "null"
          ]
        },
        "metered": {
          "type": "boolean"
        },
        "feature": {
          "type": "string"
        },
        "monteCarlo": {
          "type": "object"
        },
        "elapsedMs": {
          "type": "number"
        },
        "release": {
          "type": "string"
        }
      }
    }
  },
  "$defs": {
    "CompareSide": {
      "type": "object",
      "description": "One side of a comparison as solved.",
      "properties": {
        "source": {
          "type": "string",
          "description": "\"design\", \"design:<id>\" or \"template:<id>\"."
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "designHash": {
          "type": "string"
        },
        "converged": {
          "type": "boolean"
        },
        "totalSourcePower": {
          "type": [
            "number",
            "null"
          ]
        },
        "totalLoadPower": {
          "type": [
            "number",
            "null"
          ]
        },
        "totalDissipation": {
          "type": [
            "number",
            "null"
          ]
        },
        "efficiency": {
          "type": [
            "number",
            "null"
          ]
        },
        "warnings": {
          "type": "object",
          "properties": {
            "total": {
              "type": "integer"
            },
            "critical": {
              "type": "integer"
            },
            "warning": {
              "type": "integer"
            },
            "caution": {
              "type": "integer"
            },
            "info": {
              "type": "integer"
            }
          }
        }
      }
    },
    "Delta": {
      "type": "object",
      "description": "{ a, b, delta } — delta is b − a, null when either side is missing.",
      "properties": {
        "a": {
          "type": [
            "number",
            "null"
          ]
        },
        "b": {
          "type": [
            "number",
            "null"
          ]
        },
        "delta": {
          "type": [
            "number",
            "null"
          ]
        }
      }
    }
  }
}