{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "slow_bloom_bom.schema.json",
  "title": "slow_bloom_bom",
  "description": "Roll up and validate a Slow Bloom bill of materials: per-category and grand totals, plus a check that every line carries a real part number, a real price and a source link. Input is the BOM document itself (docs/slow-bloom-bom.json) or an object wrapping it under 'bom'.",
  "type": "object",
  "properties": {
    "design": {
      "type": "string",
      "description": "Name of the design the BOM belongs to."
    },
    "effective": {
      "type": "string",
      "description": "Date the prices were read (ISO date)."
    },
    "include_alternates": {
      "type": "boolean",
      "description": "Count lines whose role is 'alternate' in the grand total as well. Default false: alternates are priced but excluded, so the same build cannot be priced twice.",
      "default": false
    },
    "items": {
      "type": "array",
      "description": "One entry per purchasable line.",
      "minItems": 1,
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Short line key, unique within the BOM (e.g. 'B1')." },
          "category": { "type": "string", "description": "Grouping label, e.g. 'A. Foundation and mast'." },
          "item": { "type": "string", "description": "What the thing is, in words." },
          "used_for": { "type": "string", "description": "Where it goes in the build." },
          "part_number": { "type": "string", "description": "Real vendor or manufacturer part number. Must be non-empty." },
          "price_usd": { "type": "number", "description": "Unit price in US dollars. Must be > 0.", "exclusiveMinimum": 0 },
          "unit": { "type": "string", "description": "Unit the price applies to, e.g. 'each' or 'per 10-pack'." },
          "qty": { "type": "integer", "description": "How many units are bought.", "minimum": 1 },
          "vendor": { "type": "string", "description": "Who sells it." },
          "url": { "type": "string", "description": "Source link. Must start with http." },
          "verified": {
            "type": "string",
            "description": "How the price was confirmed: 'page' (read off the vendor page), 'listing' (vendor listing/snippet), 'store' (real product, vendor publishes no online price), 'quote' (vendor quotes on request; the figure carried is an allowance, not a quotation).",
            "enum": ["page", "listing", "store", "quote"]
          },
          "role": {
            "type": "string",
            "description": "'primary' counts toward the total; 'alternate' is a priced alternative for the same slot.",
            "enum": ["primary", "alternate"]
          },
          "notes": { "type": "string", "description": "Sourcing caveats, alternates, why this part." }
        },
        "required": ["id", "category", "item", "part_number", "price_usd", "qty", "vendor", "url", "verified", "role"],
        "additionalProperties": true
      }
    }
  },
  "required": ["items"],
  "additionalProperties": true
}
