{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://vindicaseneca.com/assets/starter-kit/schemas/starter-evidence.schema.json",
  "title": "Seneca Starter Kit evidence (0.1)",
  "description": "What Product A sends after the local transform, in the Starter Kit's teaching format. Not Seneca's production contract.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "source",
    "transform",
    "learner",
    "observations",
    "judgments",
    "withheld_at_source"
  ],
  "properties": {
    "format": {
      "const": "seneca-starter-evidence@0.1"
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "product",
        "product_kind",
        "product_version",
        "input_format"
      ],
      "properties": {
        "product": {
          "$ref": "#/$defs/token"
        },
        "product_kind": {
          "type": "string",
          "maxLength": 60
        },
        "product_version": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 40
        },
        "input_format": {
          "enum": [
            "JSON export",
            "JSON export (writing)",
            "CSV",
            "JSON rows",
            "xAPI statements",
            "Caliper 1.2 envelope"
          ]
        }
      }
    },
    "transform": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "by",
        "version",
        "ran",
        "at"
      ],
      "properties": {
        "by": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "ran": {
          "const": "locally, before anything was sent"
        },
        "at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "learner": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "ref",
        "ref_note"
      ],
      "properties": {
        "ref": {
          "$ref": "#/$defs/learnerRef"
        },
        "ref_note": {
          "type": "string"
        }
      }
    },
    "observations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/observation"
      }
    },
    "judgments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/judgment"
      }
    },
    "withheld_at_source": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "$defs": {
    "token": {
      "type": "string",
      "pattern": "^[\\w.:/-]{1,128}$"
    },
    "learnerRef": {
      "type": "string",
      "pattern": "^lrn_[0-9a-f]{12}$"
    },
    "skill": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "local_code",
        "label"
      ],
      "properties": {
        "local_code": {
          "$ref": "#/$defs/token"
        },
        "label": {
          "type": "string",
          "maxLength": 120
        },
        "aligned_to": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "name",
            "declared_by"
          ],
          "properties": {
            "name": {
              "type": "string",
              "maxLength": 120
            },
            "declared_by": {
              "const": "source"
            }
          }
        }
      }
    },
    "conditions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "setting",
        "timed",
        "tools"
      ],
      "properties": {
        "setting": {
          "enum": [
            "diagnostic",
            "practice",
            "test",
            "homework",
            "tutoring",
            "unknown"
          ]
        },
        "timed": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "observation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "kind",
        "occurred_at",
        "session_ref",
        "evidence_type",
        "conditions"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^obs_[0-9a-f]{12}$"
        },
        "kind": {
          "enum": [
            "item_response",
            "session_completed",
            "writing_submission"
          ]
        },
        "occurred_at": {
          "type": "string",
          "format": "date-time"
        },
        "session_ref": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^ses_[0-9a-f]{12}$"
        },
        "item_ref": {
          "type": "string",
          "pattern": "^itm_[0-9a-f]{12}$"
        },
        "item_type": {
          "$ref": "#/$defs/token"
        },
        "skill": {
          "$ref": "#/$defs/skill"
        },
        "outcome": {
          "enum": [
            "correct",
            "incorrect",
            "partially_correct",
            "skipped",
            "not_reported"
          ]
        },
        "evidence_type": {
          "enum": [
            "graded_by_source",
            "self_reported",
            "completion_only",
            "submitted_work"
          ]
        },
        "self_report": {
          "enum": [
            "knew_it",
            "unsure",
            "didnt_know"
          ]
        },
        "assistance": {
          "enum": [
            "none",
            "hint",
            "ai",
            "human",
            "unknown"
          ]
        },
        "score": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "raw",
            "max"
          ],
          "properties": {
            "raw": {
              "type": "number"
            },
            "max": {
              "type": "number",
              "minimum": 0
            }
          }
        },
        "seconds": {
          "type": "integer",
          "minimum": 0,
          "maximum": 86400
        },
        "attempt": {
          "type": "integer",
          "minimum": 1
        },
        "conditions": {
          "$ref": "#/$defs/conditions"
        },
        "task": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "label",
            "genre"
          ],
          "properties": {
            "label": {
              "type": "string",
              "maxLength": 120
            },
            "genre": {
              "type": "string",
              "maxLength": 40
            }
          }
        },
        "draft": {
          "type": "integer",
          "minimum": 1
        },
        "revises": {
          "type": "string",
          "pattern": "^obs_[0-9a-f]{12}$",
          "description": "The earlier draft this submission revises."
        },
        "words": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "judgment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "attributed_to",
        "skill",
        "method",
        "made_at",
        "seneca_rederived"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^jdg_[0-9a-f]{12}$"
        },
        "attributed_to": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "kind",
            "product"
          ],
          "properties": {
            "kind": {
              "enum": [
                "source",
                "rater"
              ]
            },
            "product": {
              "$ref": "#/$defs/token"
            },
            "role": {
              "enum": [
                "teacher",
                "ai_grader",
                "peer",
                "self"
              ]
            }
          }
        },
        "skill": {
          "$ref": "#/$defs/skill"
        },
        "claim": {
          "$ref": "#/$defs/token"
        },
        "method": {
          "type": "string",
          "maxLength": 60
        },
        "made_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "seneca_rederived": {
          "const": false
        },
        "about": {
          "type": "string",
          "pattern": "^obs_[0-9a-f]{12}$"
        },
        "score": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "raw",
            "max"
          ],
          "properties": {
            "raw": {
              "type": "number",
              "minimum": 0
            },
            "max": {
              "type": "number",
              "minimum": 0
            }
          }
        }
      },
      "description": "A conclusion someone other than Seneca drew: the source product itself, or a named rater (teacher, AI grader, peer, the learner). Carries either a claim or a score."
    }
  }
}
