{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://jkolantree.github.io/astra/schemas/claim-source-coverage-v1.schema.json",
  "title": "SPPT/ASTRA structured claim-to-source coverage record v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "title",
    "status",
    "reference_release",
    "generator",
    "input_files",
    "summary",
    "claims",
    "source_records",
    "discovered_aliases",
    "duplicate_evidence_rules",
    "known_gaps"
  ],
  "properties": {
    "schema": {
      "const": "https://jkolantree.github.io/astra/schemas/claim-source-coverage-v1.schema.json"
    },
    "title": {
      "type": "string",
      "minLength": 1
    },
    "status": {
      "enum": [
        "maintenance_draft",
        "maintenance_record",
        "candidate_only"
      ]
    },
    "reference_release": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "line",
        "version",
        "identity_status",
        "claim_matrix_path",
        "claim_matrix_sha256",
        "source_inventory_path",
        "source_inventory_sha256",
        "bibliography_path",
        "bibliography_sha256"
      ],
      "properties": {
        "line": {
          "const": "core"
        },
        "version": {
          "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"
        },
        "identity_status": {
          "const": "immutable_release_with_local_overlay"
        },
        "claim_matrix_path": {
          "const": "CLAIM_MATRIX.json"
        },
        "claim_matrix_sha256": {
          "$ref": "#/definitions/sha256"
        },
        "source_inventory_path": {
          "const": "SOURCE_INVENTORY.json"
        },
        "source_inventory_sha256": {
          "$ref": "#/definitions/sha256"
        },
        "bibliography_path": {
          "const": "manuscript/references.bib"
        },
        "bibliography_sha256": {
          "$ref": "#/definitions/sha256"
        }
      }
    },
    "generator": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "version",
        "runtime",
        "output_path"
      ],
      "properties": {
        "path": {
          "const": "tools/build_claim_source_coverage.py"
        },
        "version": {
          "const": "0.1.0"
        },
        "runtime": {
          "const": "python==3.12.10"
        },
        "output_path": {
          "const": "evidence/claim_source_coverage_v1.0.7.json"
        }
      }
    },
    "input_files": {
      "type": "array",
      "minItems": 3,
      "items": {
        "$ref": "#/definitions/inputFile"
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claim_count",
        "claims_with_support",
        "claims_with_current_path_support",
        "path_support_references",
        "unique_tracked_support_paths",
        "claims_with_supplied_input_hash_support",
        "claims_with_external_record_support",
        "claims_with_exact_locators",
        "claims_without_limitations",
        "source_record_count",
        "source_records_with_admitted_hash",
        "source_records_with_retrieval_date",
        "legacy_claim_fields_missing"
      ],
      "properties": {
        "claim_count": {
          "type": "integer",
          "minimum": 1
        },
        "claims_with_support": {
          "type": "integer",
          "minimum": 0
        },
        "claims_with_current_path_support": {
          "type": "integer",
          "minimum": 0
        },
        "path_support_references": {
          "type": "integer",
          "minimum": 0
        },
        "unique_tracked_support_paths": {
          "type": "integer",
          "minimum": 0
        },
        "claims_with_supplied_input_hash_support": {
          "type": "integer",
          "minimum": 0
        },
        "claims_with_external_record_support": {
          "type": "integer",
          "minimum": 0
        },
        "claims_with_exact_locators": {
          "type": "integer",
          "minimum": 0
        },
        "claims_without_limitations": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "source_record_count": {
          "type": "integer",
          "minimum": 0
        },
        "source_records_with_admitted_hash": {
          "type": "integer",
          "minimum": 0
        },
        "source_records_with_retrieval_date": {
          "type": "integer",
          "minimum": 0
        },
        "legacy_claim_fields_missing": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "claims": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/claim"
      }
    },
    "source_records": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/sourceRecord"
      }
    },
    "discovered_aliases": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "alias_id",
          "canonical_relative_path",
          "bytes",
          "sha256",
          "relationship"
        ],
        "properties": {
          "alias_id": {
            "type": "string",
            "minLength": 1
          },
          "canonical_relative_path": {
            "type": "string",
            "minLength": 1
          },
          "bytes": {
            "type": "integer",
            "minimum": 0
          },
          "sha256": {
            "$ref": "#/definitions/sha256"
          },
          "relationship": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "duplicate_evidence_rules": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "known_gaps": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    }
  },
  "definitions": {
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "nullableString": {
      "type": [
        "string",
        "null"
      ]
    },
    "inputFile": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "sha256",
        "bytes"
      ],
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1
        },
        "sha256": {
          "$ref": "#/definitions/sha256"
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "locator": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "path",
        "file_sha256",
        "locator",
        "precision"
      ],
      "properties": {
        "path": {
          "type": "string",
          "minLength": 1
        },
        "file_sha256": {
          "$ref": "#/definitions/sha256"
        },
        "locator": {
          "type": [
            "string",
            "null"
          ]
        },
        "precision": {
          "enum": [
            "named_locator",
            "file_level"
          ]
        }
      }
    },
    "sourceLink": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "reference",
        "raw_support",
        "admitted_path",
        "admitted_sha256",
        "supplied_input_sha256",
        "source_record_version",
        "retrieval_date",
        "entailment_status"
      ],
      "properties": {
        "kind": {
          "enum": [
            "tracked_file",
            "supplied_input",
            "external_record",
            "framework_statement",
            "provenance_record"
          ]
        },
        "reference": {
          "type": "string",
          "minLength": 1
        },
        "raw_support": {
          "type": "string",
          "minLength": 1
        },
        "admitted_path": {
          "$ref": "#/definitions/nullableString"
        },
        "admitted_sha256": {
          "anyOf": [
            {
              "$ref": "#/definitions/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "supplied_input_sha256": {
          "anyOf": [
            {
              "$ref": "#/definitions/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "source_record_version": {
          "$ref": "#/definitions/nullableString"
        },
        "retrieval_date": {
          "$ref": "#/definitions/nullableString"
        },
        "entailment_status": {
          "enum": [
            "structural_link_only",
            "historical_provenance_only",
            "not_reverified",
            "not_applicable"
          ]
        }
      }
    },
    "execution": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "status",
        "command",
        "runtime",
        "run_id"
      ],
      "properties": {
        "status": {
          "enum": [
            "not_recorded_in_claim_matrix",
            "not_applicable_to_legacy_record"
          ]
        },
        "command": {
          "$ref": "#/definitions/nullableString"
        },
        "runtime": {
          "$ref": "#/definitions/nullableString"
        },
        "run_id": {
          "$ref": "#/definitions/nullableString"
        }
      }
    },
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "statement",
        "claim_type",
        "hypotheses",
        "domain_units_signs_boundary_quantifiers",
        "evidence_class",
        "disposition",
        "limitations_or_counterexamples",
        "coverage_status",
        "claim_locators",
        "source_links",
        "execution",
        "coverage_notes"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "statement": {
          "type": "string",
          "minLength": 1
        },
        "claim_type": {
          "type": "string",
          "minLength": 1
        },
        "hypotheses": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "domain_units_signs_boundary_quantifiers": {
          "type": "string",
          "minLength": 1
        },
        "evidence_class": {
          "type": "string",
          "minLength": 1
        },
        "disposition": {
          "type": "string",
          "minLength": 1
        },
        "limitations_or_counterexamples": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "coverage_status": {
          "enum": [
            "tracked_structural",
            "mixed_tracked_external",
            "external_record_only",
            "historical_input_only",
            "framework_or_provenance",
            "proposed_or_deferred"
          ]
        },
        "claim_locators": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/locator"
          }
        },
        "source_links": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/sourceLink"
          }
        },
        "execution": {
          "$ref": "#/definitions/execution"
        },
        "coverage_notes": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "sourceRecord": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "artifact_id",
        "canonical_relative_path",
        "bytes",
        "supplied_sha256",
        "media_type",
        "displayed_attribution",
        "embedded_attribution",
        "license",
        "rights_status",
        "relationship",
        "admitted_path",
        "admitted_sha256",
        "source_record_version",
        "retrieval_date",
        "status"
      ],
      "properties": {
        "artifact_id": {
          "type": "string",
          "minLength": 1
        },
        "canonical_relative_path": {
          "type": "string",
          "minLength": 1
        },
        "bytes": {
          "type": "integer",
          "minimum": 0
        },
        "supplied_sha256": {
          "$ref": "#/definitions/sha256"
        },
        "media_type": {
          "type": "string",
          "minLength": 1
        },
        "displayed_attribution": {
          "type": [
            "string",
            "null"
          ]
        },
        "embedded_attribution": {
          "type": [
            "string",
            "null"
          ]
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "rights_status": {
          "type": "string",
          "minLength": 1
        },
        "relationship": {
          "type": "string",
          "minLength": 1
        },
        "admitted_path": {
          "$ref": "#/definitions/nullableString"
        },
        "admitted_sha256": {
          "anyOf": [
            {
              "$ref": "#/definitions/sha256"
            },
            {
              "type": "null"
            }
          ]
        },
        "source_record_version": {
          "$ref": "#/definitions/nullableString"
        },
        "retrieval_date": {
          "$ref": "#/definitions/nullableString"
        },
        "status": {
          "const": "historical_supplied_input"
        }
      }
    }
  }
}
