{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ghrisx.com/schemas/verified-public-artifact-v1.json",
  "title": "Ghrisx Verified Public Artifact v1",
  "description": "Privacy-minimized reviewed projections, public lifecycle tombstones, and permanently non-countable references. Private intake, owner capabilities, reviewer identities, private notes, and concealed consent evidence are outside this contract.",
  "oneOf": [
    {"$ref": "#/$defs/reviewed_projection"},
    {"$ref": "#/$defs/terminal_tombstone"},
    {"$ref": "#/$defs/reference_projection"}
  ],
  "$defs": {
    "public_id": {"type": "string", "pattern": "^pub_[a-f0-9]{32}$"},
    "reference_id": {"type": "string", "pattern": "^ref_[a-z0-9_-]{1,64}$"},
    "nullable_public_id": {"oneOf": [{"$ref": "#/$defs/public_id"}, {"type": "null"}]},
    "utc_date": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"},
    "nullable_utc_date": {"oneOf": [{"$ref": "#/$defs/utc_date"}, {"type": "null"}]},
    "sha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
    "nullable_sha256": {"oneOf": [{"$ref": "#/$defs/sha256"}, {"type": "null"}]},
    "lineage_key": {"type": "string", "pattern": "^arkey_[a-f0-9]{32}$"},
    "nullable_lineage_key": {"oneOf": [{"$ref": "#/$defs/lineage_key"}, {"type": "null"}]},
    "artifact_type": {"enum": ["ark_manifest", "skill_map_record", "build_lab_canvas", "local_ark_charter", "transition_field_guide", "resilience_ledger_receipt", "wheel_contribution_record"]},
    "artifact_classification": {"enum": ["artifact", "reference", "demo"]},
    "content": {
      "oneOf": [
        {"type": "string", "minLength": 1, "maxLength": 49152},
        {"type": "object"},
        {"type": "array"}
      ]
    },
    "bounded_statements": {
      "type": "array", "maxItems": 12, "uniqueItems": true,
      "items": {"type": "string", "minLength": 1, "maxLength": 512}
    },
    "countability": {
      "type": "object", "additionalProperties": false,
      "required": ["eligible", "reason", "decision_at"],
      "properties": {
        "eligible": {"type": "boolean"},
        "reason": {"type": "string", "minLength": 1, "maxLength": 1000},
        "decision_at": {"$ref": "#/$defs/nullable_utc_date"}
      }
    },
    "history": {
      "type": "array", "minItems": 1, "maxItems": 32,
      "items": {
        "type": "object", "additionalProperties": false,
        "required": ["at", "event", "reason"],
        "properties": {
          "at": {"$ref": "#/$defs/nullable_utc_date"},
          "event": {"enum": ["published_reviewed", "disputed", "correction_pending", "superseded", "withdrawn", "expired", "reference_published"]},
          "reason": {"type": "string", "minLength": 1, "maxLength": 1000}
        }
      }
    },
    "verification": {
      "type": "object", "additionalProperties": false,
      "required": ["human_reviewed", "distinct_human_reviewers_minimum", "publication_approved", "reference_or_demo"],
      "properties": {
        "human_reviewed": {"type": "boolean"},
        "distinct_human_reviewers_minimum": {"type": "integer", "minimum": 0, "maximum": 16},
        "publication_approved": {"type": "boolean"},
        "reference_or_demo": {"type": "boolean"}
      }
    },
    "details": {
      "type": "object", "additionalProperties": false,
      "required": ["generalized_location", "originating_instrument", "action_circle_relationship", "capacity_state", "health_state", "evidence_state", "claim_lanes", "sources", "responsible_public_role", "testing_method", "observed_result", "failure_record", "unresolved_questions", "reproduction_instructions", "accessibility_notes", "privacy_review_receipt", "consent_publication_receipt", "license", "correction_channel", "withdrawal_channel", "hazard_class", "qualified_review_receipt"],
      "properties": {
        "generalized_location": {"oneOf": [{"type": "null"}, {"type": "string", "minLength": 1, "maxLength": 160}]},
        "originating_instrument": {"enum": ["action_circles", "ark", "skill_map", "build_labs", "local_arks", "transition_field_guides", "resilience_ledger", "wheel"]},
        "action_circle_relationship": {"oneOf": [{"type": "null"}, {"type": "string", "minLength": 1, "maxLength": 512}]},
        "capacity_state": {"enum": ["proposed", "built", "tested", "taught", "replicated", "restored"]},
        "health_state": {"enum": ["active", "at_risk", "failed", "disputed", "expired", "retired"]},
        "evidence_state": {"enum": ["unreviewed", "evidence_reviewed", "verified", "rejected", "disputed", "reference_only", "unknown"]},
        "claim_lanes": {
          "type": "array", "minItems": 1, "maxItems": 12, "uniqueItems": true,
          "items": {"enum": ["observed_record", "primary_source", "historical_analogy", "scientific_inference", "theology_interpretation", "amianism_cosmology", "speculative_scenario", "speculative_fiction", "fiction", "disputed_claim", "unknown", "modern_synthesis", "ancient_history", "amianism_doctrine", "hypothesis", "empirical_evidence", "qualified_technical_guidance"]}
        },
        "sources": {"$ref": "#/$defs/bounded_statements"},
        "responsible_public_role": {"type": "string", "minLength": 1, "maxLength": 160},
        "testing_method": {"type": "string", "minLength": 1, "maxLength": 2000},
        "observed_result": {"type": "string", "minLength": 1, "maxLength": 2000},
        "failure_record": {"type": "string", "minLength": 1, "maxLength": 2000},
        "unresolved_questions": {"$ref": "#/$defs/bounded_statements"},
        "reproduction_instructions": {"type": "string", "minLength": 1, "maxLength": 4000},
        "accessibility_notes": {"type": "string", "minLength": 1, "maxLength": 2000},
        "privacy_review_receipt": {"type": "string", "minLength": 1, "maxLength": 2000},
        "consent_publication_receipt": {"type": "string", "minLength": 1, "maxLength": 2000},
        "license": {"enum": ["CC-BY-4.0", "CC0-1.0", "MIT", "Apache-2.0", "GPL-3.0-or-later", "All-Rights-Reserved"]},
        "correction_channel": {"type": "string", "minLength": 1, "maxLength": 512},
        "withdrawal_channel": {"type": "string", "minLength": 1, "maxLength": 512},
        "hazard_class": {"enum": ["ordinary", "medical", "structural", "electrical", "agricultural", "water", "emergency", "life_critical_other"]},
        "qualified_review_receipt": {"oneOf": [{"type": "null"}, {"type": "string", "minLength": 1, "maxLength": 2000}]}
      },
      "allOf": [{
        "if": {"properties": {"hazard_class": {"not": {"const": "ordinary"}}}, "required": ["hazard_class"]},
        "then": {"properties": {"qualified_review_receipt": {"type": "string", "minLength": 1}}}
      }]
    },
    "decision": {
      "type": "object", "additionalProperties": false,
      "required": ["stage", "decision", "at", "reason"],
      "properties": {
        "stage": {"enum": ["accept_for_projection", "approve_publication", "publish"]},
        "decision": {"enum": ["projection_accepted", "publication_approved", "published_reviewed"]},
        "at": {"$ref": "#/$defs/utc_date"},
        "reason": {"type": "string", "minLength": 1, "maxLength": 1000}
      }
    },
    "review_receipt": {
      "type": "object", "additionalProperties": false,
      "required": ["decisions", "human_reviewer_count", "human_reviewer_minimum", "privacy_review_complete", "conflict_process_complete", "contributor_projection_approval_complete", "approved_projection_sha256", "qualified_review_complete", "qualified_hazard_class"],
      "properties": {
        "decisions": {"type": "array", "maxItems": 3, "items": {"$ref": "#/$defs/decision"}},
        "human_reviewer_count": {"type": "integer", "minimum": 0, "maximum": 3},
        "human_reviewer_minimum": {"const": 2},
        "privacy_review_complete": {"type": "boolean"},
        "conflict_process_complete": {"type": "boolean"},
        "contributor_projection_approval_complete": {"type": "boolean"},
        "approved_projection_sha256": {"$ref": "#/$defs/nullable_sha256"},
        "qualified_review_complete": {"type": "boolean"},
        "qualified_hazard_class": {"oneOf": [{"type": "null"}, {"enum": ["medical", "structural", "electrical", "agricultural", "water", "emergency", "life_critical_other"]}]}
      }
    },
    "integrity": {
      "type": "object", "additionalProperties": false,
      "required": ["algorithm", "digest"],
      "properties": {"algorithm": {"const": "SHA-256"}, "digest": {"$ref": "#/$defs/sha256"}}
    },
    "base_header": {
      "type": "object",
      "required": ["$schema", "contract", "schema_version", "public_id", "status", "source_kind", "title", "last_reviewed_at", "updated_at", "supersedes_public_id", "superseded_by_public_id", "countable", "countability", "history", "integrity"],
      "properties": {
        "$schema": {"const": "https://ghrisx.com/schemas/verified-public-artifact-v1.json"},
        "contract": {"const": "ghrisx.verified-artifact-intake.v1"},
        "schema_version": {"const": "1.0"},
        "public_id": {"oneOf": [{"$ref": "#/$defs/public_id"}, {"$ref": "#/$defs/reference_id"}]},
        "status": {"type": "string"}, "source_kind": {"type": "string"},
        "title": {"type": "string", "minLength": 1, "maxLength": 160},
        "last_reviewed_at": {"$ref": "#/$defs/utc_date"}, "updated_at": {"$ref": "#/$defs/nullable_utc_date"},
        "supersedes_public_id": {"$ref": "#/$defs/nullable_public_id"}, "superseded_by_public_id": {"$ref": "#/$defs/nullable_public_id"},
        "countable": {"type": "boolean"}, "countability": {"$ref": "#/$defs/countability"},
        "history": {"$ref": "#/$defs/history"}, "integrity": {"$ref": "#/$defs/integrity"}
      }
    },
    "full_projection_fields": {
      "type": "object",
      "required": ["artifact_type", "artifact_classification", "locale", "summary", "artifact_created_at", "submitted_at", "content_type", "content", "evidence", "limitations", "details", "artifact_lineage_key", "duplicate_review_receipt", "published_at", "expires_at", "verification", "review_receipt"],
      "properties": {
        "artifact_type": {"$ref": "#/$defs/artifact_type"}, "artifact_classification": {"$ref": "#/$defs/artifact_classification"},
        "locale": {"enum": ["en-US", "es-US"]}, "summary": {"type": "string", "minLength": 1, "maxLength": 2000},
        "artifact_created_at": {"$ref": "#/$defs/utc_date"}, "submitted_at": {"$ref": "#/$defs/utc_date"},
        "content_type": {"enum": ["text/plain", "application/json"]}, "content": {"$ref": "#/$defs/content"},
        "evidence": {"$ref": "#/$defs/bounded_statements"}, "limitations": {"$ref": "#/$defs/bounded_statements"},
        "details": {"$ref": "#/$defs/details"}, "artifact_lineage_key": {"$ref": "#/$defs/nullable_lineage_key"},
        "duplicate_review_receipt": {"oneOf": [{"type": "null"}, {"type": "string", "minLength": 1, "maxLength": 1000}]},
        "published_at": {"$ref": "#/$defs/nullable_utc_date"}, "expires_at": {"$ref": "#/$defs/nullable_utc_date"},
        "verification": {"$ref": "#/$defs/verification"}, "review_receipt": {"$ref": "#/$defs/review_receipt"}
      },
      "allOf": [
        {"if": {"properties": {"content_type": {"const": "text/plain"}}, "required": ["content_type"]}, "then": {"properties": {"content": {"type": "string"}}}},
        {"if": {"properties": {"content_type": {"const": "application/json"}}, "required": ["content_type"]}, "then": {"properties": {"content": {"oneOf": [{"type": "object"}, {"type": "array"}]}}}}
      ]
    },
    "reviewed_projection": {
      "allOf": [
        {"$ref": "#/$defs/base_header"}, {"$ref": "#/$defs/full_projection_fields"},
        {
          "type": "object",
          "properties": {
            "public_id": {"$ref": "#/$defs/public_id"}, "status": {"enum": ["published_reviewed", "disputed", "correction_pending"]},
            "source_kind": {"const": "reviewed_projection"},
            "verification": {"properties": {"human_reviewed": {"const": true}, "distinct_human_reviewers_minimum": {"minimum": 2}, "publication_approved": {"const": true}}},
            "review_receipt": {"properties": {
              "decisions": {"minItems": 3, "maxItems": 3, "prefixItems": [
                {"properties": {"stage": {"const": "accept_for_projection"}, "decision": {"const": "projection_accepted"}}},
                {"properties": {"stage": {"const": "approve_publication"}, "decision": {"const": "publication_approved"}}},
                {"properties": {"stage": {"const": "publish"}, "decision": {"const": "published_reviewed"}}}
              ]},
              "human_reviewer_count": {"minimum": 2}, "privacy_review_complete": {"const": true}, "conflict_process_complete": {"const": true},
              "contributor_projection_approval_complete": {"const": true}, "approved_projection_sha256": {"$ref": "#/$defs/sha256"}, "qualified_review_complete": {"const": true}
            }}
          },
          "allOf": [
            {"if": {"properties": {"status": {"const": "published_reviewed"}, "artifact_classification": {"const": "artifact"}}, "required": ["status", "artifact_classification"]}, "then": {"properties": {
              "artifact_lineage_key": {"$ref": "#/$defs/lineage_key"}, "duplicate_review_receipt": {"type": "string", "minLength": 1},
              "expires_at": {"$ref": "#/$defs/utc_date"}, "evidence": {"minItems": 1}, "countable": {"const": true},
              "countability": {"properties": {"eligible": {"const": true}}}, "verification": {"properties": {"reference_or_demo": {"const": false}}}
            }}},
            {"if": {"properties": {"status": {"enum": ["disputed", "correction_pending"]}}, "required": ["status"]}, "then": {"properties": {"countable": {"const": false}, "countability": {"properties": {"eligible": {"const": false}}}}}},
            {"if": {"properties": {"artifact_classification": {"enum": ["reference", "demo"]}}, "required": ["artifact_classification"]}, "then": {"properties": {"countable": {"const": false}, "countability": {"properties": {"eligible": {"const": false}}}, "verification": {"properties": {"reference_or_demo": {"const": true}}}}}}
          ]
        }
      ],
      "unevaluatedProperties": false
    },
    "terminal_tombstone": {
      "type": "object", "additionalProperties": false,
      "required": ["$schema", "contract", "schema_version", "public_id", "status", "source_kind", "artifact_classification", "artifact_lineage_key", "title", "last_reviewed_at", "updated_at", "supersedes_public_id", "superseded_by_public_id", "withdrawal_kind", "countable", "countability", "history", "integrity"],
      "properties": {
        "$schema": {"const": "https://ghrisx.com/schemas/verified-public-artifact-v1.json"}, "contract": {"const": "ghrisx.verified-artifact-intake.v1"}, "schema_version": {"const": "1.0"},
        "public_id": {"$ref": "#/$defs/public_id"}, "status": {"enum": ["superseded", "withdrawn", "expired"]}, "source_kind": {"const": "lifecycle_tombstone"},
        "artifact_classification": {"$ref": "#/$defs/artifact_classification"}, "artifact_lineage_key": {"$ref": "#/$defs/nullable_lineage_key"},
        "title": {"type": "string", "minLength": 1, "maxLength": 160}, "last_reviewed_at": {"$ref": "#/$defs/utc_date"}, "updated_at": {"$ref": "#/$defs/utc_date"},
        "supersedes_public_id": {"$ref": "#/$defs/nullable_public_id"}, "superseded_by_public_id": {"$ref": "#/$defs/nullable_public_id"},
        "withdrawal_kind": {"type": ["string", "null"], "enum": ["owner_consent_revoked", "administrative_concealment", null]},
        "countable": {"const": false}, "countability": {"allOf": [{"$ref": "#/$defs/countability"}, {"properties": {"eligible": {"const": false}}}]},
        "history": {"$ref": "#/$defs/history"}, "integrity": {"$ref": "#/$defs/integrity"}
      },
      "allOf": [
        {"if": {"properties": {"status": {"const": "withdrawn"}}, "required": ["status"]}, "then": {"properties": {"withdrawal_kind": {"enum": ["owner_consent_revoked", "administrative_concealment"]}}}},
        {"if": {"properties": {"status": {"enum": ["expired", "superseded"]}}, "required": ["status"]}, "then": {"properties": {"withdrawal_kind": {"type": "null"}}}},
        {"if": {"properties": {"artifact_classification": {"const": "artifact"}}, "required": ["artifact_classification"]}, "then": {"properties": {"artifact_lineage_key": {"$ref": "#/$defs/lineage_key"}}}},
        {"if": {"properties": {"artifact_classification": {"enum": ["reference", "demo"]}}, "required": ["artifact_classification"]}, "then": {"properties": {"artifact_lineage_key": {"type": "null"}}}}
      ]
    },
    "reference_projection": {
      "allOf": [
        {"$ref": "#/$defs/base_header"}, {"$ref": "#/$defs/full_projection_fields"},
        {"type": "object", "properties": {
          "public_id": {"$ref": "#/$defs/reference_id"}, "status": {"const": "reference"}, "source_kind": {"const": "reference_example"},
          "artifact_classification": {"const": "reference"}, "artifact_lineage_key": {"type": "null"}, "duplicate_review_receipt": {"type": "null"}, "expires_at": {"type": "null"},
          "countable": {"const": false}, "countability": {"properties": {"eligible": {"const": false}}},
          "verification": {"properties": {"human_reviewed": {"const": false}, "distinct_human_reviewers_minimum": {"const": 0}, "publication_approved": {"const": false}, "reference_or_demo": {"const": true}}},
          "review_receipt": {"properties": {"decisions": {"maxItems": 0}, "human_reviewer_count": {"const": 0}, "privacy_review_complete": {"const": true}, "conflict_process_complete": {"const": false}, "contributor_projection_approval_complete": {"const": false}, "approved_projection_sha256": {"type": "null"}, "qualified_review_complete": {"const": false}, "qualified_hazard_class": {"type": "null"}}},
          "details": {"properties": {"evidence_state": {"const": "reference_only"}}}
        }}
      ],
      "unevaluatedProperties": false
    }
  }
}
