{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://k4cell.com/schemas/k4-claim-observability-inventory-v1.json",
  "title": "K4 claim observability inventory",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "artifact_status",
    "recorded_at_utc",
    "source",
    "scope",
    "classification_policy",
    "claims",
    "summary",
    "next_acceptance"
  ],
  "properties": {
    "schema": { "const": "K4-CLAIM-OBSERVABILITY-INVENTORY-v1" },
    "artifact_status": { "const": "INITIAL_PUBLIC_LEDGER_SCOPE" },
    "recorded_at_utc": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository_url", "commit_sha", "path", "sha256"],
      "properties": {
        "repository_url": { "type": "string", "format": "uri" },
        "commit_sha": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "path": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
      }
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["description", "total_rows", "global_k4_coverage"],
      "properties": {
        "description": { "type": "string", "minLength": 1 },
        "total_rows": { "const": 11 },
        "global_k4_coverage": { "const": false }
      }
    },
    "classification_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["classes", "rule"],
      "properties": {
        "classes": {
          "const": [
            "RETROSPECTIVE",
            "PREDICTION_CANDIDATE",
            "NOT_YET_OBSERVABLE"
          ]
        },
        "rule": { "type": "string", "minLength": 1 }
      }
    },
    "claims": {
      "type": "array",
      "minItems": 11,
      "maxItems": 11,
      "items": { "$ref": "#/$defs/claim" }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "retrospective",
        "prediction_candidate",
        "not_yet_observable",
        "registry_eligible"
      ],
      "properties": {
        "retrospective": { "type": "integer", "minimum": 0 },
        "prediction_candidate": { "type": "integer", "minimum": 0 },
        "not_yet_observable": { "type": "integer", "minimum": 0 },
        "registry_eligible": { "type": "integer", "minimum": 0 }
      }
    },
    "next_acceptance": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 1 }
    }
  },
  "$defs": {
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "claim_id",
        "source_row_id",
        "source_lane",
        "observable",
        "predicted_text",
        "observed_or_constraint_text",
        "uncertainty_text",
        "classification",
        "reason",
        "interfaces",
        "review_targets",
        "registry_eligible",
        "next_bridge"
      ],
      "properties": {
        "claim_id": { "type": "string", "pattern": "^K4-OBS-[0-9]{4}$" },
        "source_row_id": { "type": "string", "minLength": 1 },
        "source_lane": { "enum": ["GAUSSIAN", "DIAGNOSTIC", "BOUND"] },
        "observable": { "type": "string", "minLength": 1 },
        "predicted_text": { "type": "string", "minLength": 1 },
        "observed_or_constraint_text": { "type": ["string", "null"] },
        "uncertainty_text": { "type": ["string", "null"] },
        "classification": {
          "enum": [
            "RETROSPECTIVE",
            "PREDICTION_CANDIDATE",
            "NOT_YET_OBSERVABLE"
          ]
        },
        "reason": { "type": "string", "minLength": 1 },
        "interfaces": {
          "type": "array",
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 1 }
        },
        "review_targets": {
          "type": "array",
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 1 }
        },
        "registry_eligible": { "type": "boolean" },
        "next_bridge": { "type": "string", "minLength": 1 }
      }
    }
  }
}
