{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spacecontext-app/json-schema/spacecontext-app-space-diff-schema.json",
  "title": "SpaceDiff",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spacecontext-app-openapi.json#/components/schemas/SpaceDiff",
  "type": "object",
  "required": [
    "object",
    "space_id",
    "from",
    "to",
    "level",
    "linked",
    "summary",
    "areas",
    "items",
    "issues"
  ],
  "properties": {
    "object": {
      "type": "string",
      "const": "space_diff"
    },
    "space_id": {
      "type": "string"
    },
    "from": {
      "type": "object",
      "required": [
        "scan_id",
        "analyzed_at"
      ],
      "properties": {
        "scan_id": {
          "type": "string"
        },
        "analyzed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "to": {
      "type": "object",
      "required": [
        "scan_id",
        "analyzed_at"
      ],
      "properties": {
        "scan_id": {
          "type": "string"
        },
        "analyzed_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "level": {
      "type": "string",
      "enum": [
        "base",
        "deep"
      ]
    },
    "linked": {
      "type": "boolean",
      "description": "True when `to` was checked against `from` itself (consecutive scans of a space created through the API): its links and confirmed removals are used. Otherwise records are matched by content only, and nothing can be confirmed removed or resolved."
    },
    "summary": {
      "type": "object",
      "required": [
        "areas_added",
        "areas_removed",
        "items_added",
        "items_removed",
        "items_not_seen",
        "items_moved",
        "items_changed",
        "issues_new",
        "issues_resolved",
        "issues_not_seen"
      ],
      "properties": {
        "areas_added": {
          "type": "integer",
          "minimum": 0
        },
        "areas_removed": {
          "type": "integer",
          "minimum": 0
        },
        "items_added": {
          "type": "integer",
          "minimum": 0
        },
        "items_removed": {
          "type": "integer",
          "minimum": 0
        },
        "items_not_seen": {
          "type": "integer",
          "minimum": 0
        },
        "items_moved": {
          "type": "integer",
          "minimum": 0
        },
        "items_changed": {
          "type": "integer",
          "minimum": 0
        },
        "issues_new": {
          "type": "integer",
          "minimum": 0
        },
        "issues_resolved": {
          "type": "integer",
          "minimum": 0
        },
        "issues_not_seen": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "areas": {
      "type": "object",
      "required": [
        "added",
        "removed",
        "condition_changed"
      ],
      "properties": {
        "added": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "removed": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "condition_changed": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "area",
              "from",
              "to"
            ],
            "properties": {
              "area": {
                "type": "string"
              },
              "from": {
                "type": "string",
                "enum": [
                  "new",
                  "excellent",
                  "good",
                  "fair",
                  "poor",
                  "damaged",
                  "not_working",
                  "unknown"
                ]
              },
              "to": {
                "type": "string",
                "enum": [
                  "new",
                  "excellent",
                  "good",
                  "fair",
                  "poor",
                  "damaged",
                  "not_working",
                  "unknown"
                ]
              }
            }
          }
        }
      }
    },
    "items": {
      "type": "object",
      "required": [
        "added",
        "removed",
        "not_seen",
        "moved",
        "quantity_changed",
        "condition_changed"
      ],
      "properties": {
        "added": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "removed": {
          "type": "array",
          "description": "Confirmed gone: a frame of `to` shows the place without it.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence",
              "note"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "not_seen": {
          "type": "array",
          "description": "In `from`, not in `to`, not confirmed gone: it may be gone, or its place was not filmed.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "moved": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence",
              "from_area"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              },
              "from_area": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "quantity_changed": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence",
              "from_quantity"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              },
              "from_quantity": {
                "type": "integer"
              }
            }
          }
        },
        "condition_changed": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "canonical_name",
              "area",
              "quantity",
              "evidence",
              "from_condition",
              "to_condition"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "canonical_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "quantity": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              },
              "from_condition": {
                "type": "string",
                "enum": [
                  "new",
                  "excellent",
                  "good",
                  "fair",
                  "poor",
                  "damaged",
                  "not_working",
                  "unknown"
                ]
              },
              "to_condition": {
                "type": "string",
                "enum": [
                  "new",
                  "excellent",
                  "good",
                  "fair",
                  "poor",
                  "damaged",
                  "not_working",
                  "unknown"
                ]
              }
            }
          }
        }
      }
    },
    "issues": {
      "type": "object",
      "required": [
        "new",
        "resolved",
        "not_seen"
      ],
      "properties": {
        "new": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "title",
              "area",
              "severity",
              "evidence"
            ],
            "properties": {
              "title": {
                "type": "string"
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "severity": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "low",
                  "medium",
                  "high",
                  "critical",
                  null
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "resolved": {
          "type": "array",
          "description": "Confirmed fixed: a frame of `to` shows the place without the defect.",
          "items": {
            "type": "object",
            "required": [
              "title",
              "area",
              "severity",
              "evidence",
              "note"
            ],
            "properties": {
              "title": {
                "type": "string"
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "severity": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "low",
                  "medium",
                  "high",
                  "critical",
                  null
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              },
              "note": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "not_seen": {
          "type": "array",
          "description": "In `from`, not reported in `to`, not confirmed fixed.",
          "items": {
            "type": "object",
            "required": [
              "title",
              "area",
              "severity",
              "evidence"
            ],
            "properties": {
              "title": {
                "type": "string"
              },
              "area": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "severity": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "low",
                  "medium",
                  "high",
                  "critical",
                  null
                ]
              },
              "evidence": {
                "type": "object",
                "description": "Frames of each scan that show the record. For a removal or a resolution, `to` shows the place without it.",
                "required": [
                  "from",
                  "to"
                ],
                "properties": {
                  "from": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  },
                  "to": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "frame_id",
                        "timestamp_ms",
                        "url"
                      ],
                      "properties": {
                        "frame_id": {
                          "type": "string"
                        },
                        "timestamp_ms": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        },
                        "url": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Signed URL of the original frame; null when this key may not see it."
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}