{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://stemmar.org/spec/0.2/akp-knowledge-object.schema.json",
  "title": "AKP knowledge object",
  "description": "Normative schema for one line of a knowledge JSON Lines file. SPEC-0001 §5. Each line of the file is one instance of this schema; the file as a whole is not JSON.",
  "type": "object",
  "required": ["id", "asset", "anchor", "text"],
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "Content-derived. BLAKE3-256 over asset digest, canonical anchor and normalised text, joined by 0x1F. SPEC-0001 §5.2.",
      "type": "string",
      "pattern": "^ko:[0-9a-f]{64}$"
    },
    "asset": {
      "description": "The id of the asset this was derived from. MUST appear in the manifest.",
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{1,64}$"
    },
    "anchor": {
      "description": "Where in that asset. MUST resolve, and MUST use an anchor kind defined for the asset's media type. SPEC-0001 §6.2.",
      "type": "string",
      "pattern": "^akp:asset/[A-Za-z0-9_-]{1,64}#[a-z]{1,32}=[A-Za-z0-9\\-._~,:%]{1,256}(&[a-z]{1,32}=[A-Za-z0-9\\-._~,:%]{1,256})*$",
      "maxLength": 2048
    },
    "text": {
      "description": "The extracted passage, normalised per SPEC-0001 §5.3. Never empty.",
      "type": "string",
      "minLength": 1
    },
    "role": {
      "description": "What kind of passage this is. The listed values are the vocabulary; an unlisted value MUST be preserved and MUST NOT cause rejection, so this is documented rather than enumerated.",
      "type": "string",
      "maxLength": 64,
      "examples": ["prose", "procedure", "table", "heading", "warning", "definition"]
    },
    "metadata": {
      "description": "Arbitrary namespaced metadata. Keys are reverse-DNS; a key with no dot is reserved for the specification.",
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$"
      }
    }
  }
}
