{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rubriclab.local/schema/submission.schema.json",
  "title": "RubriclabSubmission",
  "description": "Track D gated submission bundle. Never include full copyrighted book text.",
  "type": "object",
  "required": [
    "submission_version",
    "contributor",
    "work",
    "evidence_tier",
    "l1",
    "l1_mean",
    "coverage",
    "excerpts"
  ],
  "additionalProperties": false,
  "properties": {
    "submission_version": {
      "type": "string",
      "const": "d12-v0"
    },
    "contributor": {
      "type": "object",
      "required": ["display_name", "public_credit"],
      "additionalProperties": false,
      "properties": {
        "display_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 80,
          "description": "Public signature shown as Scored by …"
        },
        "handle": {
          "type": "string",
          "maxLength": 64,
          "description": "Optional @handle"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Optional homepage / profile"
        },
        "public_credit": {
          "type": "boolean",
          "description": "If true, name appears on public board after merge"
        },
        "contact_email": {
          "type": "string",
          "description": "Optional; for Coord only, not published"
        }
      }
    },
    "work": {
      "type": "object",
      "required": ["title", "author", "band", "source_text", "serialization_status"],
      "additionalProperties": false,
      "properties": {
        "title": { "type": "string" },
        "author": { "type": "string" },
        "band": { "type": "string" },
        "source_text": { "type": "string" },
        "serialization_status": {
          "type": "string",
          "enum": ["completed"]
        },
        "language": { "type": "string" },
        "print_genre": { "type": "string" }
      }
    },
    "evidence_tier": {
      "type": "string",
      "enum": ["T0_public_domain", "T1_webnovel_excerpts"],
      "description": "T0 = PD URL reopenable; T1 = webnovel short excerpts only"
    },
    "coverage": { "type": "string" },
    "coverage_notes": { "type": "string" },
    "score_version": { "type": "string" },
    "scored_at": { "type": "string", "format": "date" },
    "rubric": { "type": "string" },
    "l1": {
      "type": "object",
      "required": ["plot", "cast", "pace", "prose", "world", "hook", "innov", "ending"],
      "additionalProperties": false,
      "properties": {
        "plot": { "$ref": "#/$defs/dim" },
        "cast": { "$ref": "#/$defs/dim" },
        "pace": { "$ref": "#/$defs/dim" },
        "prose": { "$ref": "#/$defs/dim" },
        "world": { "$ref": "#/$defs/dim" },
        "hook": { "$ref": "#/$defs/dim" },
        "innov": { "$ref": "#/$defs/dim" },
        "ending": { "$ref": "#/$defs/dim" }
      }
    },
    "l1_mean": { "type": "number", "minimum": 0, "maximum": 100 },
    "excerpts": {
      "type": "object",
      "description": "Short quotes per anchor — NOT full chapters. Soft max ~800 chars each.",
      "required": ["open", "p25", "p75", "ending"],
      "additionalProperties": false,
      "properties": {
        "open": { "$ref": "#/$defs/excerpt" },
        "p25": { "$ref": "#/$defs/excerpt" },
        "p75": { "$ref": "#/$defs/excerpt" },
        "ending": { "$ref": "#/$defs/excerpt" }
      }
    },
    "local_fingerprint": {
      "type": "string",
      "description": "Optional hash of local file; never upload plaintext book"
    },
    "notes_for_coord": { "type": "string" }
  },
  "$defs": {
    "dim": {
      "type": "object",
      "required": ["score", "evidence"],
      "additionalProperties": false,
      "properties": {
        "score": { "type": "integer", "minimum": 0, "maximum": 100 },
        "evidence": { "type": "string", "minLength": 8 }
      }
    },
    "excerpt": {
      "type": "object",
      "required": ["locator", "quote"],
      "additionalProperties": false,
      "properties": {
        "locator": {
          "type": "string",
          "description": "Chapter title / URL / % offset"
        },
        "quote": {
          "type": "string",
          "maxLength": 1200,
          "description": "Short excerpt only"
        }
      }
    }
  }
}
