{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Veriformatics scoped verification catalog",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "snapshot_date", "publication_state", "statuses", "entries"],
  "properties": {
    "schema_version": {"const": "1.0.0"},
    "snapshot_date": {"type": "string", "format": "date"},
    "publication_state": {"enum": ["integration_candidate", "owner_reviewed"]},
    "statuses": {
      "type": "object", "additionalProperties": false,
      "required": ["in_progress", "model_only", "runtime_checked", "refinement_proved"],
      "properties": {
        "in_progress": {"$ref": "#/$defs/statusDescription"},
        "model_only": {"$ref": "#/$defs/statusDescription"},
        "runtime_checked": {"$ref": "#/$defs/statusDescription"},
        "refinement_proved": {"$ref": "#/$defs/statusDescription"}
      }
    },
    "entries": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/entry"}}
  },
  "$defs": {
    "text": {"type": "string", "minLength": 1},
    "hash": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
    "link": {"type": "string", "pattern": "^(https://[^\\s]+|(evidence|history)/[a-zA-Z0-9_./-]+)$"},
    "statusDescription": {
      "type": "object", "additionalProperties": false, "required": ["label", "description"],
      "properties": {"label": {"$ref": "#/$defs/text"}, "description": {"$ref": "#/$defs/text"}}
    },
    "artifact": {
      "type": "object", "additionalProperties": false, "required": ["label", "href", "sha256"],
      "properties": {"label": {"$ref": "#/$defs/text"}, "href": {"$ref": "#/$defs/link"}, "sha256": {"$ref": "#/$defs/hash"}}
    },
    "artifacts": {"type": "array", "items": {"$ref": "#/$defs/artifact"}},
    "strings": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/text"}},
    "entry": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "revision", "software", "kind", "area", "title", "status", "lifecycle", "review_date", "review_basis", "version", "official_source", "property", "assumptions", "exclusions", "proof_artifact", "runtime_evidence", "execution_bridge", "execution_environment", "trusted_base", "next_step", "history", "withdrawal"],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z][a-z0-9-]+$"},
        "revision": {"type": "integer", "minimum": 1},
        "software": {"$ref": "#/$defs/text"}, "area": {"$ref": "#/$defs/text"}, "title": {"$ref": "#/$defs/text"},
        "kind": {"enum": ["existing_software", "own_component"]},
        "status": {"enum": ["in_progress", "model_only", "runtime_checked", "refinement_proved"]},
        "lifecycle": {"enum": ["active", "withdrawn", "superseded"]},
        "review_date": {"type": "string", "format": "date"}, "review_basis": {"$ref": "#/$defs/text"},
        "version": {
          "type": "object", "additionalProperties": false,
          "required": ["label", "identity_state", "hash_algorithm", "hash", "hash_scope"],
          "properties": {"label": {"$ref": "#/$defs/text"}, "identity_state": {"const": "pinned"}, "hash_algorithm": {"const": "sha256"}, "hash": {"$ref": "#/$defs/hash"}, "hash_scope": {"$ref": "#/$defs/text"}}
        },
        "official_source": {
          "type": "object", "additionalProperties": false, "required": ["kind", "label", "url", "pinned_url"],
          "properties": {"kind": {"enum": ["official_upstream", "authoring_snapshot"]}, "label": {"$ref": "#/$defs/text"}, "url": {"$ref": "#/$defs/link"}, "pinned_url": {"$ref": "#/$defs/link"}}
        },
        "property": {
          "type": "object", "additionalProperties": false, "required": ["state", "summary", "formal_statement"],
          "properties": {"state": {"enum": ["proposed", "established_model", "observed_runtime", "established_implementation"]}, "summary": {"$ref": "#/$defs/text"}, "formal_statement": {"$ref": "#/$defs/text"}}
        },
        "assumptions": {"$ref": "#/$defs/strings"}, "exclusions": {"$ref": "#/$defs/strings"}, "trusted_base": {"$ref": "#/$defs/strings"}, "next_step": {"$ref": "#/$defs/text"},
        "proof_artifact": {
          "type": "object", "additionalProperties": false, "required": ["state", "summary", "artifacts", "declarations"],
          "properties": {"state": {"enum": ["pending", "available", "not_applicable"]}, "summary": {"$ref": "#/$defs/text"}, "artifacts": {"$ref": "#/$defs/artifacts"}, "declarations": {"type": "array", "items": {"$ref": "#/$defs/text"}}},
          "allOf": [{"if": {"properties": {"state": {"const": "available"}}}, "then": {"properties": {"artifacts": {"minItems": 1}, "declarations": {"minItems": 1}}}}]
        },
        "runtime_evidence": {
          "type": "object", "additionalProperties": false, "required": ["state", "summary", "artifacts"],
          "properties": {"state": {"enum": ["not_established", "available"]}, "summary": {"$ref": "#/$defs/text"}, "artifacts": {"$ref": "#/$defs/artifacts"}},
          "allOf": [{"if": {"properties": {"state": {"const": "available"}}}, "then": {"properties": {"artifacts": {"minItems": 1}}}}]
        },
        "execution_bridge": {
          "type": "object", "additionalProperties": false, "required": ["state", "summary", "artifacts"],
          "properties": {"state": {"enum": ["not_established", "model_internal_only", "runtime_observed", "proved"]}, "summary": {"$ref": "#/$defs/text"}, "artifacts": {"$ref": "#/$defs/artifacts"}}
        },
        "execution_environment": {
          "type": ["object", "null"], "additionalProperties": false,
          "required": ["api", "orientation", "backends", "packages", "upstream_commits", "configuration", "bounds"],
          "properties": {
            "api": {"$ref": "#/$defs/text"}, "orientation": {"$ref": "#/$defs/text"}, "backends": {"$ref": "#/$defs/strings"}, "bounds": {"$ref": "#/$defs/strings"},
            "packages": {"type": "object", "minProperties": 1, "additionalProperties": {"$ref": "#/$defs/text"}},
            "upstream_commits": {"type": "object", "minProperties": 1, "additionalProperties": {"type": "string", "pattern": "^[a-f0-9]{40}$"}},
            "configuration": {"type": "object", "minProperties": 1, "additionalProperties": {"type": ["string", "number", "boolean"]}}
          }
        },
        "history": {
          "type": "array", "minItems": 1,
          "items": {"type": "object", "additionalProperties": false, "required": ["date", "revision", "action", "reason"], "properties": {"date": {"type": "string", "format": "date"}, "revision": {"type": "integer", "minimum": 1}, "action": {"enum": ["created", "corrected", "withdrawn", "superseded", "reinstated"]}, "reason": {"$ref": "#/$defs/text"}, "previous_record": {"$ref": "#/$defs/artifact"}}}
        },
        "withdrawal": {
          "oneOf": [{"type": "null"}, {"type": "object", "additionalProperties": false, "required": ["date", "reason", "replacement_id"], "properties": {"date": {"type": "string", "format": "date"}, "reason": {"$ref": "#/$defs/text"}, "replacement_id": {"type": ["string", "null"], "pattern": "^[a-z][a-z0-9-]+$"}}}]
        }
      },
      "allOf": [
        {"if": {"properties": {"kind": {"const": "existing_software"}}}, "then": {"properties": {"official_source": {"properties": {"kind": {"const": "official_upstream"}, "url": {"pattern": "^https://"}, "pinned_url": {"pattern": "^https://"}}}}}},
        {"if": {"properties": {"kind": {"const": "own_component"}}}, "then": {"properties": {"official_source": {"properties": {"kind": {"const": "authoring_snapshot"}}}}}},
        {"if": {"properties": {"status": {"const": "in_progress"}}}, "then": {"properties": {"property": {"properties": {"state": {"const": "proposed"}}}, "proof_artifact": {"properties": {"state": {"const": "pending"}, "artifacts": {"maxItems": 0}, "declarations": {"maxItems": 0}}}, "runtime_evidence": {"properties": {"state": {"const": "not_established"}, "artifacts": {"maxItems": 0}}}, "execution_bridge": {"properties": {"state": {"const": "not_established"}, "artifacts": {"maxItems": 0}}}}}},
        {"if": {"properties": {"status": {"const": "model_only"}}}, "then": {"properties": {"property": {"properties": {"state": {"const": "established_model"}}}, "proof_artifact": {"properties": {"state": {"const": "available"}}}, "execution_bridge": {"properties": {"state": {"enum": ["not_established", "model_internal_only"]}}}}}},
        {"if": {"properties": {"status": {"const": "runtime_checked"}}}, "then": {"properties": {"property": {"properties": {"state": {"const": "observed_runtime"}}}, "runtime_evidence": {"properties": {"state": {"const": "available"}}}, "execution_environment": {"type": "object"}, "execution_bridge": {"properties": {"state": {"const": "runtime_observed"}}}}}},
        {"if": {"properties": {"status": {"const": "refinement_proved"}}}, "then": {"properties": {"property": {"properties": {"state": {"const": "established_implementation"}}}, "proof_artifact": {"properties": {"state": {"const": "available"}}}, "execution_bridge": {"properties": {"state": {"const": "proved"}, "artifacts": {"minItems": 1}}}}}},
        {"if": {"properties": {"lifecycle": {"const": "active"}}}, "then": {"properties": {"withdrawal": {"type": "null"}}}, "else": {"properties": {"withdrawal": {"type": "object"}}}}
      ]
    }
  }
}
