{
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "const": "briked.scope-pack",
      "description": "Format identifier; always \"briked.scope-pack\"."
    },
    "specVersion": {
      "type": "string",
      "const": "1.0",
      "description": "Spec version this document conforms to (the v1 line)."
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "Opaque, stable identifier for this sealed pack version."
    },
    "project": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "Opaque project identifier."
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false,
      "description": "The project this scope belongs to."
    },
    "version": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "description": "The pack's own version number (increments on re-seal)."
    },
    "sealedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601 timestamp when the pack was sealed (evidence-grade)."
    },
    "defaultTier": {
      "type": "string",
      "enum": [
        "good",
        "better",
        "best"
      ],
      "description": "The project-wide default quality tier the pack was sealed under."
    },
    "spaces": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Opaque, stable identifier for this space."
          },
          "name": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "description": "English name (canonical, always present)."
              },
              "ar": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Arabic name — optional; omit or send null when not provided."
              }
            },
            "required": [
              "en"
            ],
            "additionalProperties": false,
            "description": "Localized space name (e.g. \"Kitchen\")."
          },
          "type": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "site",
                  "building",
                  "floor",
                  "unit",
                  "zone",
                  "room",
                  "bathroom",
                  "kitchen",
                  "bedroom",
                  "living",
                  "corridor",
                  "balcony",
                  "external",
                  "roof",
                  "other"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Space kind, or null if unspecified."
          },
          "floorArea": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Magnitude of the measure."
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Unit label, e.g. \"m²\"."
                  }
                },
                "required": [
                  "value",
                  "unit"
                ],
                "additionalProperties": false,
                "description": "A quantity with its unit."
              },
              {
                "type": "null"
              }
            ],
            "description": "Floor area at seal time, or null if unsized."
          },
          "sizeBand": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "small",
                  "typical",
                  "large"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Relatable size band (small / typical / large), or null."
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "floorArea",
          "sizeBand"
        ],
        "additionalProperties": false
      },
      "description": "Every space (room) in the scope."
    },
    "jobs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Opaque, stable identifier for this job."
          },
          "name": {
            "type": "object",
            "properties": {
              "en": {
                "type": "string",
                "description": "English name (canonical, always present)."
              },
              "ar": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Arabic name — optional; omit or send null when not provided."
              }
            },
            "required": [
              "en"
            ],
            "additionalProperties": false,
            "description": "Localized job name (e.g. \"Renovate kitchen\")."
          },
          "type": {
            "type": "string",
            "enum": [
              "room",
              "trade"
            ],
            "description": "Whole-room job or single trade."
          },
          "tier": {
            "type": "string",
            "enum": [
              "good",
              "better",
              "best"
            ],
            "description": "Whole-job quality level: good, better, or best."
          },
          "spaces": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "Opaque, stable identifier."
                },
                "name": {
                  "type": "object",
                  "properties": {
                    "en": {
                      "type": "string",
                      "description": "English name (canonical, always present)."
                    },
                    "ar": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Arabic name — optional; omit or send null when not provided."
                    }
                  },
                  "required": [
                    "en"
                  ],
                  "additionalProperties": false,
                  "description": "Resolved localized name (English canonical, Arabic optional)."
                }
              },
              "required": [
                "id",
                "name"
              ],
              "additionalProperties": false
            },
            "description": "The spaces this job applies to (opaque id + name)."
          },
          "quantity": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Magnitude of the measure."
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Unit label, e.g. \"m²\"."
                  },
                  "assumed": {
                    "type": "boolean",
                    "description": "True when nobody has established this figure — a calibrated default, or a quantity an AI proposed that no person confirmed (disclosed, never gated). Omitted on documents from before this field existed — absence means UNKNOWN, not \"confirmed measured\"."
                  }
                },
                "required": [
                  "value",
                  "unit"
                ],
                "additionalProperties": false,
                "description": "A quantity with its unit."
              },
              {
                "type": "null"
              }
            ],
            "description": "Aggregate quantity across the job's spaces, or null if unsized."
          },
          "selections": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "object",
                  "properties": {
                    "en": {
                      "type": "string",
                      "description": "English name (canonical, always present)."
                    },
                    "ar": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Arabic name — optional; omit or send null when not provided."
                    }
                  },
                  "required": [
                    "en"
                  ],
                  "additionalProperties": false,
                  "description": "Localized question / attribute label."
                },
                "value": {
                  "type": "object",
                  "properties": {
                    "en": {
                      "type": "string",
                      "description": "English name (canonical, always present)."
                    },
                    "ar": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Arabic name — optional; omit or send null when not provided."
                    }
                  },
                  "required": [
                    "en"
                  ],
                  "additionalProperties": false,
                  "description": "Localized chosen value (never a price)."
                }
              },
              "required": [
                "label",
                "value"
              ],
              "additionalProperties": false
            },
            "description": "Recap of the homeowner's answered choices."
          },
          "finishes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "category": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Opaque, stable identifier."
                    },
                    "name": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string",
                          "description": "English name (canonical, always present)."
                        },
                        "ar": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Arabic name — optional; omit or send null when not provided."
                        }
                      },
                      "required": [
                        "en"
                      ],
                      "additionalProperties": false,
                      "description": "Resolved localized name (English canonical, Arabic optional)."
                    }
                  },
                  "required": [
                    "id",
                    "name"
                  ],
                  "additionalProperties": false,
                  "description": "The finish category (e.g. \"Cabinets\")."
                },
                "choice": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "description": "Opaque, stable identifier."
                    },
                    "name": {
                      "type": "object",
                      "properties": {
                        "en": {
                          "type": "string",
                          "description": "English name (canonical, always present)."
                        },
                        "ar": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "description": "Arabic name — optional; omit or send null when not provided."
                        }
                      },
                      "required": [
                        "en"
                      ],
                      "additionalProperties": false,
                      "description": "Resolved localized name (English canonical, Arabic optional)."
                    }
                  },
                  "required": [
                    "id",
                    "name"
                  ],
                  "additionalProperties": false,
                  "description": "The selected option (e.g. \"Solid oak\")."
                },
                "tier": {
                  "type": "string",
                  "enum": [
                    "budget",
                    "economy",
                    "standard",
                    "premium",
                    "luxury"
                  ],
                  "description": "The option's quality band (a value, never its price)."
                }
              },
              "required": [
                "category",
                "choice",
                "tier"
              ],
              "additionalProperties": false
            },
            "description": "Chosen finishes (by name + tier; never price)."
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "tier",
          "spaces",
          "quantity",
          "selections",
          "finishes"
        ],
        "additionalProperties": false
      },
      "description": "Every job (piece of work) in the scope."
    },
    "assumedQuantityCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Count of jobs with a calibrated-default quantity (quantity.assumed === true). Omitted on documents from before this field existed."
    }
  },
  "required": [
    "format",
    "specVersion",
    "id",
    "project",
    "version",
    "sealedAt",
    "defaultTier",
    "spaces",
    "jobs"
  ],
  "additionalProperties": false,
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://briked.com/.well-known/scope-pack/v1/schema.json",
  "title": "Scope Pack Exchange Format v1",
  "description": "Open, versioned interchange format for a sealed Scope Pack — a values-only renovation scope (spaces, jobs, quality tiers, selections, finishes). Contains no prices, formulas, or recipes; all references are opaque ids with resolved names."
}
