{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://chillspace.love/operations/mirror-garden/contract.schema.json",
  "title": "Mirror Garden public operations contract",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "id",
    "version",
    "updated",
    "purpose",
    "posture",
    "public_categories",
    "evidence_states",
    "response_clock",
    "action_contract",
    "public_record",
    "private_evidence",
    "artifact_binding",
    "learning_loop",
    "coverage",
    "non_claims"
  ],
  "properties": {
    "schema": {"const": "kingdom.karma.operations-contract/v1"},
    "id": {"const": "mirror-garden-karma"},
    "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
    "updated": {"type": "string", "format": "date"},
    "purpose": {"type": "string", "minLength": 1, "maxLength": 512},
    "posture": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "live_classifier",
        "live_incident_ingestion",
        "live_telemetry",
        "automatic_actuation",
        "synthetic_mirror",
        "public_incident_claims",
        "provider_logging",
        "authority",
        "private_evidence_default"
      ],
      "properties": {
        "mode": {"const": "static-transparency-and-readiness"},
        "live_classifier": {"const": "disabled"},
        "live_incident_ingestion": {"const": "disabled"},
        "live_telemetry": {"const": "disabled"},
        "automatic_actuation": {"const": "disabled"},
        "synthetic_mirror": {"const": "offline-only"},
        "public_incident_claims": {"const": "none-published"},
        "provider_logging": {"const": "unknown"},
        "authority": {"const": "human-separate-and-explicit"},
        "private_evidence_default": {"const": "derived-categories-only"}
      }
    },
    "public_categories": {
      "type": "array",
      "minItems": 7,
      "maxItems": 7,
      "items": {"$ref": "#/$defs/category"}
    },
    "evidence_states": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {"$ref": "#/$defs/evidenceState"}
    },
    "response_clock": {
      "type": "array",
      "minItems": 3,
      "maxItems": 3,
      "items": {"$ref": "#/$defs/responseWindow"}
    },
    "action_contract": {
      "type": "object",
      "additionalProperties": false,
      "required": ["automatic", "human_authorization_required", "always_forbidden"],
      "properties": {
        "automatic": {"$ref": "#/$defs/nonEmptyStrings"},
        "human_authorization_required": {"$ref": "#/$defs/nonEmptyStrings"},
        "always_forbidden": {"$ref": "#/$defs/nonEmptyStrings"}
      }
    },
    "public_record": {
      "type": "object",
      "additionalProperties": false,
      "required": ["may_include", "must_exclude"],
      "properties": {
        "may_include": {"$ref": "#/$defs/nonEmptyStrings"},
        "must_exclude": {"$ref": "#/$defs/nonEmptyStrings"}
      }
    },
    "private_evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["default", "raw_request_retention", "separate_exception_requires", "must_never_retain"],
      "properties": {
        "default": {"const": "derived-categories-only"},
        "raw_request_retention": {"const": "forbidden-by-this-contract"},
        "separate_exception_requires": {"$ref": "#/$defs/nonEmptyStrings"},
        "must_never_retain": {"$ref": "#/$defs/nonEmptyStrings"}
      }
    },
    "artifact_binding": {
      "type": "object",
      "additionalProperties": false,
      "required": ["manifest", "scope", "source_and_provider_binding", "provider_parity"],
      "properties": {
        "manifest": {"const": "manifest.json"},
        "scope": {"const": "all-public-operation-files-except-the-manifest-itself"},
        "source_and_provider_binding": {"const": "private-release-receipt"},
        "provider_parity": {"const": "must-be-verified-per-release"}
      }
    },
    "learning_loop": {"$ref": "#/$defs/nonEmptyStrings"},
    "coverage": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "items": {"$ref": "#/$defs/coverage"}
    },
    "non_claims": {"$ref": "#/$defs/nonEmptyStrings"}
  },
  "$defs": {
    "nonEmptyStrings": {
      "type": "array",
      "minItems": 1,
      "items": {"type": "string", "minLength": 1, "maxLength": 512}
    },
    "category": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "meaning", "not_a_claim"],
      "properties": {
        "id": {
          "enum": [
            "availability-pressure",
            "protocol-invalid",
            "authority-confusion",
            "provenance-drift",
            "privacy-risk",
            "content-boundary",
            "novel-or-ambiguous"
          ]
        },
        "meaning": {"type": "string", "minLength": 1, "maxLength": 512},
        "not_a_claim": {"type": "string", "minLength": 1, "maxLength": 512}
      }
    },
    "evidenceState": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "meaning"],
      "properties": {
        "id": {"enum": ["reported", "synthetically-reproduced", "control-verified", "corrected"]},
        "meaning": {"type": "string", "minLength": 1, "maxLength": 512}
      }
    },
    "responseWindow": {
      "type": "object",
      "additionalProperties": false,
      "required": ["window", "goal", "actions", "exit_evidence"],
      "properties": {
        "window": {"enum": ["first-5-minutes", "first-15-minutes", "first-60-minutes"]},
        "goal": {"type": "string", "minLength": 1, "maxLength": 256},
        "actions": {"$ref": "#/$defs/nonEmptyStrings"},
        "exit_evidence": {"type": "string", "minLength": 1, "maxLength": 512}
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["surface", "delivery", "incident_observation", "provider_metadata", "gap"],
      "properties": {
        "surface": {"type": "string", "minLength": 1, "maxLength": 128},
        "delivery": {"type": "string", "minLength": 1, "maxLength": 256},
        "incident_observation": {"enum": ["disabled", "not-available"]},
        "provider_metadata": {"const": "unknown"},
        "gap": {"type": "string", "minLength": 1, "maxLength": 512}
      }
    }
  }
}
