{
  "$defs": {
    "Evidence": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "maxLength": 80,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "title": "Id",
          "type": "string"
        },
        "kind": {
          "enum": [
            "independent_response",
            "assisted_response",
            "corrected_response",
            "repetition_request",
            "explanation_request",
            "observed_error",
            "completed_exercise",
            "demonstrated_understanding",
            "contextual_use",
            "tutor_correction",
            "oral_production",
            "retention_check"
          ],
          "title": "Kind",
          "type": "string"
        },
        "actor": {
          "enum": [
            "learner",
            "tutor",
            "unknown"
          ],
          "title": "Actor",
          "type": "string"
        },
        "autonomy": {
          "enum": [
            "independent",
            "assisted",
            "corrected",
            "unknown",
            "not_applicable"
          ],
          "title": "Autonomy",
          "type": "string"
        },
        "text": {
          "maxLength": 2000,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        },
        "context": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Context"
        },
        "knowledge_refs": {
          "items": {
            "maxLength": 80,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
            "type": "string"
          },
          "maxItems": 100,
          "title": "Knowledge Refs",
          "type": "array"
        },
        "confidence": {
          "anyOf": [
            {
              "maximum": 1,
              "minimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence"
        },
        "notes": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Notes"
        }
      },
      "required": [
        "id",
        "kind",
        "actor",
        "autonomy",
        "text",
        "context",
        "knowledge_refs",
        "confidence",
        "notes"
      ],
      "title": "Evidence",
      "type": "object",
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "const": "independent_response"
              }
            }
          },
          "then": {
            "properties": {
              "actor": {
                "const": "learner"
              },
              "autonomy": {
                "const": "independent"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "assisted_response"
              }
            }
          },
          "then": {
            "properties": {
              "actor": {
                "const": "learner"
              },
              "autonomy": {
                "const": "assisted"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "corrected_response"
              }
            }
          },
          "then": {
            "properties": {
              "actor": {
                "const": "learner"
              },
              "autonomy": {
                "const": "corrected"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "tutor_correction"
              }
            }
          },
          "then": {
            "properties": {
              "actor": {
                "const": "tutor"
              },
              "autonomy": {
                "const": "not_applicable"
              }
            }
          }
        }
      ]
    },
    "Knowledge": {
      "additionalProperties": false,
      "properties": {
        "id": {
          "maxLength": 80,
          "minLength": 1,
          "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
          "title": "Id",
          "type": "string"
        },
        "kind": {
          "enum": [
            "word",
            "expression",
            "grammar_structure"
          ],
          "title": "Kind",
          "type": "string"
        },
        "term": {
          "maxLength": 300,
          "minLength": 1,
          "title": "Term",
          "type": "string"
        },
        "meaning": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Meaning"
        },
        "context": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Context"
        },
        "learner_selected": {
          "title": "Learner Selected",
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "kind",
        "term",
        "meaning",
        "context",
        "learner_selected"
      ],
      "title": "Knowledge",
      "type": "object"
    },
    "Observation": {
      "additionalProperties": false,
      "properties": {
        "dimension": {
          "enum": [
            "functional_understanding",
            "construction",
            "listening",
            "oral_production",
            "spontaneous_use",
            "retention",
            "autonomy"
          ],
          "title": "Dimension",
          "type": "string"
        },
        "status": {
          "enum": [
            "observed",
            "uncertain",
            "not_observed"
          ],
          "title": "Status",
          "type": "string"
        },
        "evidence_refs": {
          "items": {
            "maxLength": 80,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
            "type": "string"
          },
          "maxItems": 100,
          "title": "Evidence Refs",
          "type": "array"
        },
        "confidence": {
          "anyOf": [
            {
              "maximum": 1,
              "minimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence"
        },
        "notes": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Notes"
        }
      },
      "required": [
        "dimension",
        "status",
        "evidence_refs",
        "confidence",
        "notes"
      ],
      "title": "Observation",
      "type": "object",
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "observed"
              }
            }
          },
          "then": {
            "properties": {
              "evidence_refs": {
                "minItems": 1
              }
            }
          }
        }
      ]
    },
    "Recommendation": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "practice",
            "next_goal",
            "transfer",
            "resource"
          ],
          "title": "Kind",
          "type": "string"
        },
        "mode": {
          "enum": [
            "feynman",
            "construction",
            "shadowing",
            "conversation",
            "cards"
          ],
          "title": "Mode",
          "type": "string"
        },
        "text": {
          "maxLength": 2000,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        },
        "knowledge_refs": {
          "items": {
            "maxLength": 80,
            "minLength": 1,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
            "type": "string"
          },
          "maxItems": 100,
          "title": "Knowledge Refs",
          "type": "array"
        },
        "resource_id": {
          "anyOf": [
            {
              "maxLength": 80,
              "minLength": 1,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Resource Id"
        },
        "priority": {
          "enum": [
            "suggested",
            "learner_selected"
          ],
          "title": "Priority",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "mode",
        "text",
        "knowledge_refs",
        "resource_id",
        "priority"
      ],
      "title": "Recommendation",
      "type": "object"
    },
    "Session": {
      "additionalProperties": false,
      "properties": {
        "session_id": {
          "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
          "title": "Session Id",
          "type": "string"
        },
        "occurred_at": {
          "anyOf": [
            {
              "format": "date-time",
              "maxLength": 40,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Occurred At"
        },
        "native_language": {
          "enum": [
            "es",
            "en",
            "fr",
            "de",
            "it",
            "pt",
            "ja",
            "ko",
            "zh",
            "tr"
          ],
          "title": "Native Language",
          "type": "string"
        },
        "target_language": {
          "enum": [
            "es",
            "en",
            "fr",
            "de",
            "it",
            "pt",
            "ja",
            "ko",
            "zh",
            "tr"
          ],
          "title": "Target Language",
          "type": "string"
        },
        "native_locale": {
          "anyOf": [
            {
              "maxLength": 35,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Native Locale"
        },
        "target_locale": {
          "anyOf": [
            {
              "maxLength": 35,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Target Locale"
        },
        "topic": {
          "maxLength": 300,
          "minLength": 1,
          "title": "Topic",
          "type": "string"
        },
        "context": {
          "anyOf": [
            {
              "maxLength": 2000,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Context"
        },
        "source": {
          "$ref": "#/$defs/Source"
        }
      },
      "required": [
        "session_id",
        "occurred_at",
        "native_language",
        "target_language",
        "native_locale",
        "target_locale",
        "topic",
        "context",
        "source"
      ],
      "title": "Session",
      "type": "object",
      "allOf": [
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "es"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "es"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "en"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "en"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "fr"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "fr"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "de"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "de"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "it"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "it"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "pt"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "pt"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "ja"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "ja"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "ko"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "ko"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "zh"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "zh"
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "native_language": {
                "const": "tr"
              }
            }
          },
          "then": {
            "properties": {
              "target_language": {
                "not": {
                  "const": "tr"
                }
              }
            }
          }
        }
      ]
    },
    "Source": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "external_ai",
            "human_tutor",
            "self_report"
          ],
          "title": "Kind",
          "type": "string"
        },
        "tool": {
          "anyOf": [
            {
              "maxLength": 300,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tool"
        },
        "evidence_basis": {
          "enum": [
            "transcript",
            "audio",
            "written_work",
            "unspecified"
          ],
          "title": "Evidence Basis",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "tool",
        "evidence_basis"
      ],
      "title": "Source",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "hablemos.hlx",
      "title": "Format",
      "type": "string"
    },
    "schema_version": {
      "const": "1.0",
      "title": "Schema Version",
      "type": "string"
    },
    "session": {
      "$ref": "#/$defs/Session"
    },
    "knowledge": {
      "items": {
        "$ref": "#/$defs/Knowledge"
      },
      "maxItems": 200,
      "minItems": 1,
      "title": "Knowledge",
      "type": "array"
    },
    "evidence": {
      "items": {
        "$ref": "#/$defs/Evidence"
      },
      "maxItems": 500,
      "minItems": 1,
      "title": "Evidence",
      "type": "array"
    },
    "observations": {
      "items": {
        "$ref": "#/$defs/Observation"
      },
      "maxItems": 50,
      "title": "Observations",
      "type": "array"
    },
    "recommendations": {
      "items": {
        "$ref": "#/$defs/Recommendation"
      },
      "maxItems": 100,
      "title": "Recommendations",
      "type": "array"
    },
    "notes": {
      "anyOf": [
        {
          "maxLength": 2000,
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Notes"
    }
  },
  "required": [
    "format",
    "schema_version",
    "session",
    "knowledge",
    "evidence",
    "observations",
    "recommendations",
    "notes"
  ],
  "title": "HABLEMOS Learning Exchange 1.0",
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://myhablemos.app/synapse-connect/hlx-1.0.schema.json",
  "description": "External evidence, not direct mastery. Cross-reference, attribution and secret checks also apply in the importer."
}