{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "nt-crossing-class.v0.schema.json",
  "title": "Neverthought crossing class v0",
  "description": "What a domain must declare before its crossings can be evaluated: typed states, actions, a versioned policy, invariants with tolerances, evidence and authority requirements, relevant archetypes and underwritability notes.",
  "$defs": {
    "tier": { "description": "Evidence tier, crossing-graph-spec v0.4 §1.6: E1 self-attested < E2 single-source < E3 corroborated < E4 independently verified < E5 adversarially tested.", "enum": ["E1", "E2", "E3", "E4", "E5"] }
  },
  "type": "object",
  "required": ["class_version", "id", "version", "title", "domain", "evidence_status", "summary", "state_fields", "action_types", "policy", "invariants", "evidence_requirements", "authority_requirements", "archetypes", "descriptors", "profiles", "consequence", "consequence_paths", "structural_tests", "failure_mode", "non_claims"],
  "additionalProperties": false,
  "properties": {
    "class_version": { "const": "nt-crossing-class:v0" },
    "id": { "type": "string", "pattern": "^[a-z]+\\.[a-z0-9-]+$" },
    "version": { "type": "string" },
    "title": { "type": "string" },
    "domain": { "type": "string" },
    "evidence_status": { "enum": ["proposed", "preprint", "tested", "published"] },
    "summary": { "type": "string" },
    "state_fields": { "type": "object", "required": ["before", "proposed"],
      "properties": { "before": { "type": "array", "items": { "type": "string" } }, "proposed": { "type": "array", "items": { "type": "string" } } } },
    "action_types": { "type": "array", "minItems": 1, "items": { "type": "string" } },
    "policy": {
      "type": "object",
      "required": ["id", "version", "authored_by", "parameters", "note"],
      "properties": {
        "id": { "type": "string" }, "version": { "type": "string" }, "authored_by": { "type": "string" }, "note": { "type": "string" },
        "parameters": {
          "type": "object", "additionalProperties": false,
          "properties": {
            "max_review_ratio": { "type": "number", "exclusiveMinimum": 0 },
            "max_delegation_depth": { "type": "integer", "minimum": 0 },
            "evidence_max_age_days": { "type": "number", "exclusiveMinimum": 0 },
            "reachable_retention_min": { "type": "number", "minimum": 0, "maximum": 1 },
            "max_loop_gain": { "type": "number", "minimum": 0 }
          }
        }
      }
    },
    "invariants": { "type": "array", "items": { "type": "object", "required": ["id", "label", "measure", "params", "tolerance"],
      "properties": { "id": { "type": "string" }, "label": { "type": "string" }, "measure": { "enum": ["double_entry_balance", "routes_preserved", "evaluation_coverage", "mappings_agree", "path_executable"] },
        "params": { "type": "object" }, "tolerance": { "type": "number", "minimum": 0 }, "register": { "enum": ["value", "structure"] } } } },
    "evidence_requirements": { "type": "array", "items": { "type": "object", "required": ["subject", "min_tier", "required_to_resolve"],
      "properties": { "subject": { "type": "string" }, "min_tier": { "$ref": "#/$defs/tier" }, "required_to_resolve": { "type": "string" } } } },
    "authority_requirements": { "type": "object", "required": ["independent_trust_root", "segregation_of_duties"],
      "properties": { "independent_trust_root": { "type": "boolean" }, "segregation_of_duties": { "type": "boolean" } } },
    "archetypes": { "type": "array", "items": { "type": "string", "pattern": "^RA-[A-Z-]+$" } },
    "descriptors": {
      "description": "Class dimensions from crossing-graph-spec v0.4 §1.2. authority_kind is the type of authority, never its identity.",
      "type": "object", "additionalProperties": false, "required": ["stake", "action", "authority_kind", "freshness"],
      "properties": {
        "stake": { "enum": ["material", "symbolic", "reputational", "existential", "none"] },
        "action": { "enum": ["irreversible", "reversible", "partial", "compensable"] },
        "authority_kind": { "enum": ["explicit", "implicit", "delegated", "emergent", "none"] },
        "freshness": { "enum": ["bounded", "perpetual", "session", "one-shot", "stale"] }
      }
    },
    "profiles": {
      "description": "Recording and underwriting profiles the class uses. Source I2 requires a recorder profile for explicit authority and an underwriting profile for material stake.",
      "type": "object", "additionalProperties": false, "required": ["recorder", "underwriting"],
      "properties": { "recorder": { "type": ["string", "null"] }, "underwriting": { "type": ["string", "null"] } }
    },
    "consequence": {
      "description": "Whether the worst consequence of one crossing has a ceiling. Declared by the class author.",
      "type": "object", "additionalProperties": false, "required": ["bound", "ceiling", "rationale"],
      "properties": { "bound": { "enum": ["bounded", "unbounded"] }, "ceiling": { "type": ["string", "null"] }, "rationale": { "type": "string" } },
      "if": { "properties": { "bound": { "const": "bounded" } } },
      "then": { "properties": { "ceiling": { "type": "string" } } },
      "else": { "properties": { "ceiling": { "type": "null" } } }
    },
    "consequence_paths": {
      "description": "Consequence paths the class can represent. An observed consequence following none of them challenges the model's structure.",
      "type": "array", "minItems": 1,
      "items": { "type": "object", "additionalProperties": false, "required": ["id", "description"],
        "properties": { "id": { "type": "string", "pattern": "^[a-z_]+$" }, "description": { "type": "string" } } }
    },
    "structural_tests": {
      "description": "Tests built to produce effects the declared paths cannot express. Structure is 'supported' only after one has run and passed.",
      "type": "array",
      "items": { "type": "object", "additionalProperties": false, "required": ["test_id", "ran_at", "result", "artifact"],
        "properties": { "test_id": { "type": "string" }, "ran_at": { "type": "string" }, "result": { "enum": ["passed", "failed"] }, "artifact": { "type": "string" } } }
    },
    "failure_mode": {
      "description": "What the deployment does when the gate holds or cannot be reached. fail-closed: the action does not proceed. fail-safe: the system reverts to a declared safe state. fail-open: the action proceeds. fail-silent: the action proceeds and no record is kept. Irreversible crossings require fail-closed.",
      "type": "object", "additionalProperties": false, "required": ["mode", "rationale"],
      "properties": { "mode": { "enum": ["fail-closed", "fail-safe", "fail-open", "fail-silent"] }, "rationale": { "type": "string", "minLength": 1 } }
    },
    "underwritability": { "type": "object", "required": ["what_an_underwriter_would_need", "conditions", "exclusions"],
      "properties": {
        "what_an_underwriter_would_need": { "type": "array", "items": { "type": "string" } },
        "conditions": { "type": "array", "items": { "type": "string" } },
        "exclusions": { "type": "array", "items": { "type": "string" } } } },
    "non_claims": { "type": "array", "minItems": 1, "items": { "type": "string" } }
  }
}
