{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openrxm.org/corpus/transport/rail/v1/scenario-a-sggmrs-container/schema.json",
  "title": "Open Rail Corpus v1 -- Scenario A bundle schema",
  "description": "Sggmrs container wagon, structured against the BAV Catalogue of irregularities (Fehlerkatalog)",
  "type": "object",
  "required": [
    "spec",
    "scenario",
    "version",
    "entity",
    "failure_modes"
  ],
  "properties": {
    "spec": {
      "const": "open-rail-corpus-v1"
    },
    "scenario": {
      "const": "scenario-a-sggmrs-container"
    },
    "title": {
      "type": "string"
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "license": {
      "type": "string"
    },
    "attribution": {
      "type": "string"
    },
    "entity": {
      "type": "object",
      "required": [
        "asset_id",
        "name",
        "asset_class"
      ],
      "properties": {
        "identifier": {
          "type": "string",
          "pattern": "^kerne\\.systems/"
        },
        "resolver": {
          "type": "string",
          "format": "uri"
        },
        "asset_id": {
          "type": "string",
          "pattern": "^ASSET-[a-f0-9]+$"
        },
        "name": {
          "type": "string"
        },
        "asset_class": {
          "type": "string"
        },
        "industry": {
          "type": [
            "string",
            "null"
          ]
        },
        "world": {
          "type": [
            "string",
            "null"
          ]
        },
        "fleet_template_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "manufacturer_template": {
          "type": "string"
        },
        "public_catalog_url": {
          "type": "string",
          "format": "uri"
        },
        "corpus_source": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "regulatory_anchors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "catalog",
          "section_ref"
        ],
        "properties": {
          "catalog": {
            "type": "string"
          },
          "catalog_title_en": {
            "type": "string"
          },
          "catalog_title_de": {
            "type": "string"
          },
          "catalog_version": {
            "type": "string"
          },
          "section_ref": {
            "type": "string"
          },
          "section_title_en": {
            "type": "string"
          },
          "section_title_de": {
            "type": "string"
          },
          "publisher_url": {
            "type": "string",
            "format": "uri"
          },
          "catalog_token": {
            "type": "string",
            "description": "Internal catalog identifier (also available as 'catalog' alias for back-compat)"
          },
          "catalog_iri": {
            "type": "string",
            "description": "Canonical IRI for the regulatory catalog (kerne.systems/earth/regulation/...)"
          },
          "catalog_url": {
            "type": "string",
            "format": "uri",
            "description": "Public URL where the catalog source document lives"
          },
          "catalog_effective": {
            "type": "string",
            "format": "date",
            "description": "Effective date of the catalog edition"
          },
          "section_iri": {
            "type": "string",
            "description": "Canonical IRI for the catalog section (kerne.systems/earth/regulation/.../section/...)"
          }
        }
      }
    },
    "failure_modes": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "fm_uid",
          "entity_ref",
          "rds_component",
          "failure_mode"
        ],
        "properties": {
          "fm_uid": {
            "type": "string",
            "pattern": "^FM-[a-f0-9]+$"
          },
          "identifier": {
            "type": "string",
            "pattern": "^kerne\\.systems/earth/fm/"
          },
          "entity_ref": {
            "type": "string"
          },
          "rds_component": {
            "type": "string"
          },
          "failure_mode": {
            "type": "string"
          },
          "cause": {
            "type": "string"
          },
          "effect": {
            "type": "string"
          },
          "severity": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 5
          },
          "likelihood": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 5
          },
          "risk_index": {
            "type": [
              "string",
              "null"
            ]
          },
          "detect_method": {
            "type": "string"
          },
          "resolution": {
            "type": "string"
          },
          "rcm_task_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "corpus_source": {
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ]
          },
          "regulatory_anchor": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "catalog": {
                "type": "string"
              },
              "section_ref": {
                "type": "string"
              },
              "catalog_token": {
                "type": "string",
                "description": "Internal catalog identifier (also available as 'catalog' alias for back-compat)"
              },
              "catalog_iri": {
                "type": "string",
                "description": "Canonical IRI for the regulatory catalog (kerne.systems/earth/regulation/...)"
              },
              "catalog_url": {
                "type": "string",
                "format": "uri",
                "description": "Public URL where the catalog source document lives"
              },
              "catalog_effective": {
                "type": "string",
                "format": "date",
                "description": "Effective date of the catalog edition"
              },
              "section_iri": {
                "type": "string",
                "description": "Canonical IRI for the catalog section (kerne.systems/earth/regulation/.../section/...)"
              }
            }
          },
          "resolver_url": {
            "type": "string",
            "format": "uri",
            "description": "Stable HTTPS URL to fetch this single FM via api.php"
          },
          "uid_scheme": {
            "type": "string",
            "description": "Identifier scheme version describing how fm_uid is derived"
          },
          "entity_iri": {
            "type": "string",
            "description": "Canonical IRI of the entity this FM applies to (kerne.systems/earth/entity/...)"
          },
          "entity_resolver_url": {
            "type": "string",
            "format": "uri",
            "description": "Stable HTTPS URL to fetch the entity"
          },
          "supersedes": {
            "type": [
              "string",
              "null"
            ],
            "description": "fm_uid of the FM this one replaces (regulatory edition transition); null in v1.0.0"
          },
          "superseded_by": {
            "type": [
              "string",
              "null"
            ],
            "description": "fm_uid of the FM that replaces this one; null in v1.0.0"
          },
          "attribution": {
            "type": "string",
            "description": "Per-FM attribution string echoing CC BY 4.0 license requirements"
          }
        }
      }
    }
  }
}
