{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wstein.github.io/cx-cli/schemas/shared-handover-v2.schema.json",
  "title": "cx Shared Handover JSON Artifact v2",
  "description": "Schema for JSON-style shared handover artifacts emitted by cx bundle. Version 2 records recent repository history under recentRepositoryHistory[].message so full multiline commit messages can be preserved without overloading a subject-only field.",
  "type": "object",
  "additionalProperties": false,
  "required": ["kind", "project", "purpose", "sections", "usage"],
  "properties": {
    "kind": { "const": "cx_shared_handover" },
    "project": { "type": "string", "minLength": 1 },
    "purpose": { "type": "string", "minLength": 1 },
    "sections": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["name", "style", "outputFile", "fileCount", "packedTokens", "outputTokens"],
        "properties": {
          "name": { "type": "string", "minLength": 1 },
          "style": { "enum": ["xml", "markdown", "json", "plain"] },
          "outputFile": { "type": "string", "minLength": 1 },
          "fileCount": { "type": "integer", "minimum": 0 },
          "packedTokens": { "type": "integer", "minimum": 0 },
          "outputTokens": { "type": "integer", "minimum": 0 }
        }
      }
    },
    "assets": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sourcePath", "storedPath"],
        "properties": {
          "sourcePath": { "type": "string", "minLength": 1 },
          "storedPath": { "type": "string", "minLength": 1 }
        }
      }
    },
    "inclusionProvenance": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["marker", "count"],
        "properties": {
          "marker": { "type": "string", "minLength": 1 },
          "count": { "type": "integer", "minimum": 0 }
        }
      }
    },
    "recentRepositoryHistory": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["shortHash", "message"],
        "properties": {
          "shortHash": { "type": "string", "minLength": 1 },
          "message": { "type": "string", "minLength": 1 }
        }
      }
    },
    "usage": { "type": "string", "minLength": 1 }
  }
}
