{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://matrixnetwork.me/schemas/y-theory-formation-mind-runtime-v1.json",
  "title": "Y-Theory bounded Formation Mind kernel run",
  "description": "Exact top-level and structural contract emitted by FormationRun.to_dict(). Event payload meaning is checked by the deterministic validator and event-chain tests. This schema does not approve semantics, theory truth, physical astronomy, observerhood, or consciousness.",
  "type": "object",
  "additionalProperties": false,
  "required": ["kernel_version", "source", "config", "pattern_threads", "basins", "events", "summary", "guardrails", "run_digest"],
  "properties": {
    "kernel_version": {"const": "FMK-2026.09.01.2"},
    "source": {"$ref": "#/$defs/source"},
    "config": {"$ref": "#/$defs/config"},
    "pattern_threads": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/patternThread"}},
    "basins": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/basin"}},
    "events": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/event"}},
    "summary": {"$ref": "#/$defs/summary"},
    "guardrails": {"$ref": "#/$defs/guardrails"},
    "run_digest": {"$ref": "#/$defs/sha256"}
  },
  "$defs": {
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "nonEmptyString": {"type": "string", "minLength": 1},
    "integerVector3": {"type": "array", "minItems": 3, "maxItems": 3, "items": {"type": "integer"}},
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["relative_path", "content_address", "sha256", "byte_count", "token_count", "encoding", "tokenizer_version", "scope", "formation_content"],
      "properties": {
        "relative_path": {"const": "canonical/16_ENGINE_FORMATION.md"},
        "content_address": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
        "sha256": {"$ref": "#/$defs/sha256"},
        "byte_count": {"type": "integer", "minimum": 1},
        "token_count": {"type": "integer", "minimum": 1},
        "encoding": {"const": "utf-8"},
        "tokenizer_version": {"const": "unicode-word-symbol-v2-markdown-body"},
        "scope": {"const": "one_canonical_chapter_only"},
        "formation_content": {
          "type": "object",
          "additionalProperties": false,
          "required": ["selection_rule", "byte_start", "byte_end", "byte_count", "sha256"],
          "properties": {
            "selection_rule": {"const": "markdown_body_excluding_opening_yaml_front_matter"},
            "byte_start": {"type": "integer", "minimum": 0},
            "byte_end": {"type": "integer", "minimum": 1},
            "byte_count": {"type": "integer", "minimum": 1},
            "sha256": {"$ref": "#/$defs/sha256"}
          }
        }
      }
    },
    "config": {
      "type": "object",
      "additionalProperties": false,
      "required": ["source_relpath", "context_window", "coordinate_bound", "velocity_bound", "phase_modulus", "force_divisor", "maximum_pull", "minimum_persistence_occurrences", "maximum_tokens"],
      "properties": {
        "source_relpath": {"const": "canonical/16_ENGINE_FORMATION.md"},
        "context_window": {"type": "integer", "minimum": 1},
        "coordinate_bound": {"type": "integer", "minimum": 1},
        "velocity_bound": {"type": "integer", "minimum": 1},
        "phase_modulus": {"type": "integer", "minimum": 1},
        "force_divisor": {"type": "integer", "minimum": 1},
        "maximum_pull": {"type": "integer", "minimum": 1},
        "minimum_persistence_occurrences": {"type": "integer", "minimum": 1},
        "maximum_tokens": {"type": ["integer", "null"]}
      }
    },
    "sourceOccurrence": {
      "type": "object",
      "additionalProperties": false,
      "required": ["ordinal", "byte_start", "byte_end", "char_start", "char_end", "label", "normalized_pattern", "token_sha256", "source_sha256", "address"],
      "properties": {
        "ordinal": {"type": "integer", "minimum": 0},
        "byte_start": {"type": "integer", "minimum": 0},
        "byte_end": {"type": "integer", "minimum": 1},
        "char_start": {"type": "integer", "minimum": 0},
        "char_end": {"type": "integer", "minimum": 1},
        "label": {"$ref": "#/$defs/nonEmptyString"},
        "normalized_pattern": {"$ref": "#/$defs/nonEmptyString"},
        "token_sha256": {"$ref": "#/$defs/sha256"},
        "source_sha256": {"$ref": "#/$defs/sha256"},
        "address": {"type": "string", "pattern": "^ytocc:sha256:[0-9a-f]{64}#bytes=[0-9]+:[0-9]+;token=[0-9]+;token_sha256=[0-9a-f]{64}$"}
      }
    },
    "role": {
      "type": "object",
      "additionalProperties": false,
      "required": ["role", "refs", "structural_reading", "semantic_binding"],
      "properties": {
        "role": {"enum": ["inside", "outside", "relation"]},
        "refs": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"$ref": "#/$defs/nonEmptyString"}},
        "structural_reading": {"$ref": "#/$defs/nonEmptyString"},
        "semantic_binding": {"const": "unresolved_candidate"}
      }
    },
    "mindCell": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "reference_scope", "roles", "authority_state", "semantic_relation_approved", "referent_identity_established", "capability_boundary"],
      "properties": {
        "id": {"$ref": "#/$defs/nonEmptyString"},
        "reference_scope": {"$ref": "#/$defs/nonEmptyString"},
        "roles": {
          "type": "object",
          "additionalProperties": false,
          "required": ["inside", "outside", "relation"],
          "properties": {
            "inside": {"$ref": "#/$defs/role"},
            "outside": {"$ref": "#/$defs/role"},
            "relation": {"$ref": "#/$defs/role"}
          }
        },
        "authority_state": {"const": "computational_candidate_only"},
        "semantic_relation_approved": {"const": false},
        "referent_identity_established": {"const": false},
        "capability_boundary": {"$ref": "#/$defs/nonEmptyString"}
      }
    },
    "patternThread": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "occurrence", "prior_occurrence_address", "context_fingerprint", "mind_cell"],
      "properties": {
        "id": {"type": "string", "pattern": "^THREAD::[0-9a-f]{24}$"},
        "occurrence": {"$ref": "#/$defs/sourceOccurrence"},
        "prior_occurrence_address": {"type": ["string", "null"]},
        "context_fingerprint": {"type": "integer", "minimum": 0},
        "mind_cell": {"$ref": "#/$defs/mindCell"}
      }
    },
    "structuralState": {
      "type": "object",
      "additionalProperties": false,
      "required": ["position", "velocity", "phase_tick", "mass", "support", "residue_total", "context_fingerprint", "member_count", "child_count", "relation_count", "last_step", "state"],
      "properties": {
        "position": {"$ref": "#/$defs/integerVector3"},
        "velocity": {"$ref": "#/$defs/integerVector3"},
        "phase_tick": {"type": "integer", "minimum": 0},
        "mass": {"type": "integer", "minimum": 0},
        "support": {"type": "integer", "minimum": 0},
        "residue_total": {"type": "integer", "minimum": 0},
        "context_fingerprint": {"type": "integer", "minimum": 0},
        "member_count": {"type": "integer", "minimum": 0},
        "child_count": {"type": "integer", "minimum": 0},
        "relation_count": {"type": "integer", "minimum": 0},
        "last_step": {"type": "integer", "minimum": 0},
        "state": {"enum": ["structural_root", "active_candidate", "retired_candidate"]}
      }
    },
    "authority": {
      "type": "object",
      "additionalProperties": false,
      "required": ["authority_state", "proof_status", "validation_state", "canonical_approval", "semantic_relation_approved", "guardrail"],
      "properties": {
        "authority_state": {"const": "computational_candidate_only"},
        "proof_status": {"const": "not_proof"},
        "validation_state": {"const": "unreviewed_computational_candidate"},
        "canonical_approval": {"const": false},
        "semantic_relation_approved": {"const": false},
        "guardrail": {"$ref": "#/$defs/nonEmptyString"}
      }
    },
    "basin": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "basin_kind", "parent_id", "depth", "pattern_sha256", "label", "member_refs", "child_basin_ids", "relation_refs", "first_step", "last_step", "state", "structural_state", "mind_cell", "authority"],
      "properties": {
        "id": {"type": "string", "pattern": "^BASIN::(ROOT|PATTERN|RELATION)::[0-9a-f]{24}$"},
        "basin_kind": {"enum": ["formation_root", "pattern_candidate", "relation_candidate"]},
        "parent_id": {"type": ["string", "null"]},
        "depth": {"type": "integer", "minimum": 0, "maximum": 2},
        "pattern_sha256": {"$ref": "#/$defs/sha256"},
        "label": {"$ref": "#/$defs/nonEmptyString"},
        "member_refs": {"type": "array", "items": {"$ref": "#/$defs/nonEmptyString"}},
        "child_basin_ids": {"type": "array", "uniqueItems": true, "items": {"$ref": "#/$defs/nonEmptyString"}},
        "relation_refs": {"type": "array", "uniqueItems": true, "items": {"$ref": "#/$defs/nonEmptyString"}},
        "first_step": {"type": "integer", "minimum": 0},
        "last_step": {"type": "integer", "minimum": 0},
        "state": {"enum": ["structural_root", "active_candidate", "retired_candidate"]},
        "structural_state": {"$ref": "#/$defs/structuralState"},
        "mind_cell": {"$ref": "#/$defs/mindCell"},
        "authority": {"$ref": "#/$defs/authority"}
      }
    },
    "event": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sequence", "fixed_step", "event_type", "payload", "previous_event_hash", "event_hash"],
      "properties": {
        "sequence": {"type": "integer", "minimum": 0},
        "fixed_step": {"type": "integer", "minimum": 0},
        "event_type": {"enum": ["formation_started", "pattern_observed", "candidate_branch", "candidate_attach", "candidate_deform", "candidate_retire", "prediction_issued", "prediction_scored"]},
        "payload": {"type": "object"},
        "previous_event_hash": {"$ref": "#/$defs/sha256"},
        "event_hash": {"$ref": "#/$defs/sha256"}
      }
    },
    "scoreCounts": {
      "type": "object",
      "additionalProperties": false,
      "required": ["hit", "miss", "abstain"],
      "properties": {
        "hit": {"type": "integer", "minimum": 0},
        "miss": {"type": "integer", "minimum": 0},
        "abstain": {"type": "integer", "minimum": 0}
      }
    },
    "modelScore": {
      "type": "object",
      "additionalProperties": false,
      "required": ["hit", "miss", "abstain", "issued_score_rate_milli", "all_target_score_rate_milli"],
      "properties": {
        "hit": {"type": "integer", "minimum": 0},
        "miss": {"type": "integer", "minimum": 0},
        "abstain": {"type": "integer", "minimum": 0},
        "issued_score_rate_milli": {"type": "integer", "minimum": 0, "maximum": 1000},
        "all_target_score_rate_milli": {"type": "integer", "minimum": 0, "maximum": 1000}
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["fixed_steps", "pattern_thread_count", "basin_count", "pattern_candidate_count", "relation_candidate_count", "maximum_recursive_depth", "active_candidate_count", "retired_candidate_count", "event_count", "event_chain_head", "event_chain_verified", "predictions_issued", "predictions_scored", "prediction_outcomes", "prediction_model_scores", "relational_geometry_predictive_lift_evaluated", "predictive_wisdom_earned", "prediction_protocol"],
      "properties": {
        "fixed_steps": {"type": "integer", "minimum": 1},
        "pattern_thread_count": {"type": "integer", "minimum": 1},
        "basin_count": {"type": "integer", "minimum": 1},
        "pattern_candidate_count": {"type": "integer", "minimum": 1},
        "relation_candidate_count": {"type": "integer", "minimum": 0},
        "maximum_recursive_depth": {"type": "integer", "minimum": 0},
        "active_candidate_count": {"type": "integer", "minimum": 0},
        "retired_candidate_count": {"type": "integer", "minimum": 0},
        "event_count": {"type": "integer", "minimum": 1},
        "event_chain_head": {"$ref": "#/$defs/sha256"},
        "event_chain_verified": {"const": true},
        "predictions_issued": {"type": "integer", "minimum": 0},
        "predictions_scored": {"type": "integer", "minimum": 0},
        "prediction_outcomes": {"$ref": "#/$defs/scoreCounts"},
        "prediction_model_scores": {
          "type": "object",
          "additionalProperties": false,
          "required": ["relational_position_nearest_neighbor_v1", "transition_frequency_v1", "persistence_v1"],
          "properties": {
            "relational_position_nearest_neighbor_v1": {"$ref": "#/$defs/modelScore"},
            "transition_frequency_v1": {"$ref": "#/$defs/modelScore"},
            "persistence_v1": {"$ref": "#/$defs/modelScore"}
          }
        },
        "relational_geometry_predictive_lift_evaluated": {"const": true},
        "predictive_wisdom_earned": {"const": false},
        "prediction_protocol": {"const": "issue_from_prior_state_then_observe_then_score_then_learn_transition"}
      }
    },
    "guardrails": {
      "type": "object",
      "additionalProperties": false,
      "required": ["semantic_inference_performed", "semantic_promotion_performed", "identity_referent_established", "prediction_is_wisdom", "geometry_is_proof", "llm_used", "embedding_used", "category_gravity_used", "claim"],
      "properties": {
        "semantic_inference_performed": {"const": false},
        "semantic_promotion_performed": {"const": false},
        "identity_referent_established": {"const": false},
        "prediction_is_wisdom": {"const": false},
        "geometry_is_proof": {"const": false},
        "llm_used": {"const": false},
        "embedding_used": {"const": false},
        "category_gravity_used": {"const": false},
        "claim": {"$ref": "#/$defs/nonEmptyString"}
      }
    }
  }
}
