{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://kostina.online/star/i/za-kadrom-keyteringa/agent.schema.json",
 "title": "Kostina interview — agent layer",
 "description": "Только структура. Ссылочную целостность (каждый source_ref и claim_id разрешается; каждый фрагмент дословно содержится в указанном элементе) проверяет сборка: JSON Schema этого не выражает.",
 "type": "object",
 "additionalProperties": false,
 "required": [
  "article_id",
  "canonical_url",
  "language",
  "revision",
  "title",
  "subtitle",
  "person",
  "notice",
  "interview",
  "addressing",
  "science_sections",
  "source_elements",
  "topics",
  "claims",
  "principles",
  "projects",
  "intentions",
  "related_links"
 ],
 "$defs": {
  "ref": {
   "type": "string",
   "pattern": "^(interview#A([1-9]|10)|[a-z]+[0-9]{4})$"
  },
  "refs": {
   "type": "array",
   "minItems": 1,
   "uniqueItems": true,
   "items": {
    "$ref": "#/$defs/ref"
   }
  },
  "claim_id": {
   "type": "string",
   "pattern": "^C-(F[0-9]{2}|S[1-6][a-z])$"
  }
 },
 "properties": {
  "article_id": {
   "type": "string",
   "pattern": "^[a-z0-9-]+$"
  },
  "canonical_url": {
   "const": "https://kostina.online/star/i/za-kadrom-keyteringa/"
  },
  "language": {
   "const": "ru"
  },
  "revision": {
   "type": "string",
   "pattern": "^r[0-9]+$"
  },
  "title": {
   "type": "string",
   "minLength": 1
  },
  "subtitle": {
   "type": "string",
   "minLength": 1
  },
  "person": {
   "type": "string",
   "minLength": 1
  },
  "notice": {
   "type": "string",
   "minLength": 1
  },
  "addressing": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "model"
   ],
   "properties": {
    "model": {
     "type": "string"
    },
    "interview_note": {
     "type": "string"
    }
   }
  },
  "source_elements": {
   "type": "array",
   "minItems": 11,
   "items": {
    "oneOf": [
     {
      "type": "object",
      "additionalProperties": false,
      "required": [
       "element_id",
       "kind",
       "number",
       "source_question",
       "answer_sha256"
      ],
      "properties": {
       "element_id": {
        "type": "string",
        "pattern": "^interview#A([1-9]|10)$"
       },
       "kind": {
        "const": "interview_answer"
       },
       "number": {
        "type": "integer",
        "minimum": 1,
        "maximum": 10
       },
       "source_question": {
        "type": "string"
       },
       "answer_sha256": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
       }
      }
     },
     {
      "type": "object",
      "additionalProperties": false,
      "required": [
       "element_id",
       "kind",
       "authors",
       "year",
       "title",
       "venue",
       "url",
       "doi",
       "kind_of_evidence",
       "does_not_show"
      ],
      "properties": {
       "element_id": {
        "type": "string",
        "pattern": "^[a-z]+[0-9]{4}$"
       },
       "kind": {
        "const": "research_source"
       },
       "authors": {
        "type": "array",
        "minItems": 1,
        "items": {
         "type": "string"
        }
       },
       "year": {
        "type": "integer"
       },
       "title": {
        "type": "string"
       },
       "venue": {
        "type": "string"
       },
       "url": {
        "type": "string"
       },
       "doi": {
        "type": [
         "string",
         "null"
        ]
       },
       "does_not_show": {
        "type": "string"
       },
       "kind_of_evidence": {
        "type": "string"
       }
      }
     }
    ]
   }
  },
  "topics": {
   "type": "array",
   "minItems": 8,
   "maxItems": 8,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "topic_id",
     "title",
     "question",
     "source_refs"
    ],
    "properties": {
     "topic_id": {
      "type": "string",
      "pattern": "^T0[1-8]$"
     },
     "title": {
      "type": "string"
     },
     "question": {
      "type": "string",
      "minLength": 1
     },
     "source_refs": {
      "$ref": "#/$defs/refs"
     }
    }
   }
  },
  "claims": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "claim_id",
     "text",
     "claim_type",
     "topic",
     "source_refs",
     "supporting_fragments",
     "editorial_transformation",
     "evidence_status"
    ],
    "properties": {
     "claim_id": {
      "$ref": "#/$defs/claim_id"
     },
     "text": {
      "type": "string",
      "minLength": 1
     },
     "claim_type": {
      "enum": [
       "self_reported_event",
       "stated_principle",
       "intention",
       "editorial_interpretation",
       "theoretical_proposition",
       "empirical_finding"
      ]
     },
     "topic": {
      "type": "string",
      "pattern": "^T0[1-8]$"
     },
     "science_section": {
      "type": "string",
      "pattern": "^S[1-6]$"
     },
     "source_refs": {
      "$ref": "#/$defs/refs"
     },
     "supporting_fragments": {
      "type": "array",
      "minItems": 1,
      "items": {
       "type": "object",
       "additionalProperties": false,
       "required": [
        "source_ref",
        "fragment"
       ],
       "properties": {
        "source_ref": {
         "$ref": "#/$defs/ref"
        },
        "fragment": {
         "type": "string",
         "minLength": 1
        },
        "locator": {
         "type": "string"
        }
       }
      }
     },
     "limits": {
      "type": "string"
     },
     "editorial_transformation": {
      "type": "string"
     },
     "evidence_status": {
      "enum": [
       "self_reported",
       "interpretation",
       "read_source"
      ]
     }
    },
    "if": {
     "properties": {
      "claim_type": {
       "enum": [
        "theoretical_proposition",
        "empirical_finding"
       ]
      }
     }
    },
    "then": {
     "required": [
      "science_section",
      "limits"
     ],
     "properties": {
      "supporting_fragments": {
       "items": {
        "required": [
         "source_ref",
         "fragment",
         "locator"
        ]
       }
      }
     }
    }
   }
  },
  "principles": {
   "type": "array",
   "items": {
    "$ref": "#/$defs/claim_id"
   }
  },
  "projects": {
   "type": "array",
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "name",
     "status",
     "source_refs",
     "claim_ids"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "status": {
      "enum": [
       "named_public_project",
       "not_disclosed"
      ]
     },
     "source_refs": {
      "$ref": "#/$defs/refs"
     },
     "claim_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
       "$ref": "#/$defs/claim_id"
      }
     },
     "url": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   }
  },
  "related_links": {
   "type": "array",
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "title",
     "url"
    ],
    "properties": {
     "title": {
      "type": "string"
     },
     "url": {
      "type": [
       "string",
       "null"
      ]
     },
     "status": {
      "type": "string"
     }
    }
   }
  },
  "interview": {
   "type": "object",
   "additionalProperties": false,
   "required": [
    "publication",
    "interviewer",
    "interview_date"
   ],
   "description": "Неизвестные значения — null.",
   "properties": {
    "publication": {
     "type": [
      "string",
      "null"
     ]
    },
    "interviewer": {
     "type": [
      "string",
      "null"
     ]
    },
    "interview_date": {
     "type": [
      "string",
      "null"
     ],
     "format": "date"
    },
    "edition_note": {
     "type": "string"
    }
   }
  },
  "science_sections": {
   "type": "array",
   "minItems": 1,
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "section_id",
     "title",
     "anchor"
    ],
    "properties": {
     "section_id": {
      "type": "string",
      "pattern": "^S[1-6]$"
     },
     "title": {
      "type": "string"
     },
     "anchor": {
      "type": "string",
      "pattern": "^#science-s[1-6]$"
     }
    }
   }
  },
  "intentions": {
   "type": "array",
   "items": {
    "type": "object",
    "additionalProperties": false,
    "required": [
     "claim_ids",
     "text",
     "status"
    ],
    "properties": {
     "claim_ids": {
      "type": "array",
      "minItems": 1,
      "items": {
       "$ref": "#/$defs/claim_id"
      }
     },
     "text": {
      "type": "string"
     },
     "status": {
      "const": "not_realized"
     }
    }
   }
  }
 }
}
