{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.freightutils.com/schema/adr-code.v1.json",
  "title": "FreightUtils ADR code registry record (v1)",
  "description": "The meaning of one code printed in ADR 2025 Table A (ECE/TRANS/352), written in FreightUtils' own words from the free UNECE publication and cited to the volume, section and PDF page. Only `title` is the publication's own wording (a heading of at most 12 words); everything else is paraphrase. `verification_status` says whether a person has reviewed the paraphrase against the source.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "code", "family", "table_a_columns", "edition", "publication", "section", "source", "title", "title_verbatim",
    "summary", "meaning", "parameters", "applies_to", "references", "row_count", "verification_status", "reviewed", "notes"
  ],
  "definitions": {
    "threshold": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "unit", "applies_when"],
      "properties": {
        "value": { "type": ["number", "string"], "description": "As the source gives it, never rounded." },
        "unit": { "type": ["string", "null"] },
        "applies_when": { "type": "string" }
      }
    },
    "packaging": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "code"],
      "properties": {
        "type": { "type": "string", "description": "e.g. drums, jerricans, boxes, bags, composite packagings, IBC, large packaging." },
        "code": { "type": ["string", "null"], "description": "UN packaging code(s) as printed, e.g. 1A1, 4G." },
        "packing_groups": { "type": "array", "items": { "type": "string", "enum": ["I", "II", "III"] } },
        "max_capacity_l": { "type": ["number", "string", "null"] },
        "max_net_mass_kg": { "type": ["number", "string", "null"] },
        "inner": { "type": ["string", "null"], "description": "Inner packagings, for combination packagings." }
      }
    },
    "digit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["digit", "meaning"],
      "properties": { "digit": { "type": "string" }, "meaning": { "type": "string" } }
    },
    "tank_part": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "meaning"],
      "properties": { "value": { "type": "string" }, "meaning": { "type": "string" } }
    }
  },
  "properties": {
    "code": { "type": "string", "minLength": 1, "maxLength": 24 },
    "family": {
      "type": "string",
      "enum": ["sp", "pi", "spp", "mp", "t", "bk", "tp", "tank_code", "tsp", "v", "vc", "ap", "cv", "s", "label", "vehicle", "hin"]
    },
    "table_a_columns": {
      "type": "array",
      "minItems": 1,
      "items": { "type": "string", "enum": ["5", "6", "8", "9a", "9b", "10", "11", "12", "13", "14", "16", "17", "18", "19", "20"] }
    },
    "edition": { "const": "ADR 2025" },
    "publication": { "const": "ECE/TRANS/352" },
    "section": { "type": "string", "minLength": 3, "description": "Pinpoint, e.g. \"3.3.1, special provision 188\"; \"4.1.4.1, P001\"." },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["volume", "page", "anchor"],
      "properties": {
        "volume": { "type": "string", "enum": ["I", "II"] },
        "page": { "type": "integer", "minimum": 1, "description": "PDF page index (data-staging/adr/SOURCES.md says which file each volume's pages refer to)." },
        "anchor": { "type": "string", "minLength": 1, "description": "The exact token the anchor lint finds on that page." }
      }
    },
    "title": { "type": ["string", "null"], "maxLength": 120 },
    "title_verbatim": { "type": "boolean" },
    "summary": { "type": "string", "minLength": 10, "maxLength": 160 },
    "meaning": { "type": "string", "minLength": 20, "maxLength": 1600 },
    "parameters": {
      "type": ["object", "null"],
      "additionalProperties": false,
      "properties": {
        "thresholds": { "type": "array", "items": { "$ref": "#/definitions/threshold" } },
        "conditions": { "type": "array", "items": { "type": "string" } },
        "permitted_packagings": { "type": "array", "items": { "$ref": "#/definitions/packaging" } },
        "special_packing_provisions_referenced": { "type": "array", "items": { "type": "string" } },
        "test_pressure_bar": { "type": ["number", "string", "null"] },
        "min_shell_thickness_mm": { "type": ["number", "string", "null"] },
        "pressure_relief": { "type": ["string", "null"] },
        "bottom_openings": { "type": ["string", "null"] },
        "equipment": { "type": "array", "items": { "type": "string" } },
        "documents": { "type": "array", "items": { "type": "string" } },
        "digits": { "type": "array", "items": { "$ref": "#/definitions/digit" } },
        "parts": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "tank_type": { "$ref": "#/definitions/tank_part" },
            "calculation_pressure": { "$ref": "#/definitions/tank_part" },
            "openings": { "$ref": "#/definitions/tank_part" },
            "safety_valves": { "$ref": "#/definitions/tank_part" },
            "suffix": { "$ref": "#/definitions/tank_part" }
          }
        },
        "label_name": { "type": "string" },
        "symbol": { "type": "string" }
      }
    },
    "applies_to": { "type": "string", "enum": ["packages", "tanks", "bulk", "vehicle", "documentation", "classification", "all"] },
    "references": { "type": "array", "items": { "type": "string" } },
    "row_count": { "type": "integer", "minimum": 1 },
    "verification_status": { "type": "string", "enum": ["paraphrase_unreviewed", "machine_reviewed", "contested", "owner_reviewed", "dg_reviewed", "needs_fix"], "description": "Derived from lib/data/adr-codes/reviews.json. machine_reviewed: two independent model readings of the UNECE text agreed with this record (G2); it is not a person's review. contested: the machine readings disagreed with the record and the owner adjudicates. owner_reviewed / dg_reviewed: a person's review." },
    "reviewed": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["by", "date", "status"],
        "properties": {
          "by": { "type": "string", "enum": ["owner", "dg_reviewer", "machine_reader"] },
          "date": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
          "status": { "type": "string", "enum": ["ok", "needs_fix", "split"] },
          "note": { "type": ["string", "null"] },
          "readers": { "type": "array", "items": { "type": "string" }, "description": "machine_reader entries only: the model ids that read the record." },
          "run": { "type": "string", "description": "machine_reader entries only: the machine-review run (docs/audit/adr-code-registry/machine-review-<run>.json)." }
        }
      }
    },
    "notes": { "type": ["string", "null"] },
    "amended_in_2027": {
      "type": "object",
      "description": "Build 1 (2026-10-30): present only when the ADR 2027 amendment documents (ECE/TRANS/WP.15/274, Add.1, Corr.1) amend the provision this code stands for. The meaning above is the ADR 2025 text; no ADR 2027 meaning is written until the consolidated text is published.",
      "required": ["documents", "note"],
      "additionalProperties": false,
      "properties": {
        "documents": { "type": "array", "minItems": 1, "items": { "type": "string" }, "description": "The amending documents, each with its PDF page." },
        "note": { "type": "string" }
      }
    }
  }
}
