{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://conderis.com/schemas/conderis-batch-v2.schema.json",
  "title": "Conderis Batch v2",
  "description": "New tasks, pages and memories for one project, passed unchanged as batch to the item_store MCP tool together with projectId. Kinds may be mixed; each kind is stored atomically on its own. Sending the same batch again returns the kinds already stored and retries only a kind that failed. A batch of memories only may leave out projectId to store personal memories.",
  "type": "object",
  "additionalProperties": false,
  "required": ["idempotencyKey", "items"],
  "properties": {
    "idempotencyKey": {
      "type": "string",
      "minLength": 8,
      "maxLength": 100,
      "description": "A new client-generated value for this exact batch. Reuse it only when retrying the unchanged batch."
    },
    "source": {
      "type": "string",
      "maxLength": 100,
      "description": "Tool or agent the items come from, for example trello-import or claude-code."
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "maxItems": 100,
      "items": {
        "oneOf": [
          { "$ref": "#/$defs/task" },
          { "$ref": "#/$defs/page" },
          { "$ref": "#/$defs/memory" }
        ]
      }
    }
  },
  "$defs": {
    "key": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Names this item inside the batch, unique in the batch, so a later item of the same kind can name it as parent. The response maps each key to the assigned number."
    },
    "parent": {
      "description": "The key of an earlier item of the same kind in this batch, or the number of an existing item.",
      "oneOf": [
        { "type": "integer", "minimum": 1 },
        { "type": "string", "minLength": 1 }
      ]
    },
    "task": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "fields"],
      "properties": {
        "key": { "$ref": "#/$defs/key" },
        "kind": { "const": "task" },
        "fields": {
          "type": "object",
          "additionalProperties": false,
          "required": ["title"],
          "properties": {
            "title": { "type": "string", "minLength": 1, "maxLength": 160 },
            "content": { "type": "string", "maxLength": 4000, "description": "Safe Markdown." },
            "status": { "const": "open", "description": "A new task starts open." },
            "priority": { "enum": ["low", "normal", "high"], "default": "normal" },
            "assignee": { "type": "string", "description": "A reference from project_get, sent back unchanged." },
            "parent": { "$ref": "#/$defs/parent" }
          }
        }
      }
    },
    "page": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "fields"],
      "properties": {
        "key": { "$ref": "#/$defs/key" },
        "kind": { "const": "page" },
        "fields": {
          "type": "object",
          "additionalProperties": false,
          "required": ["title"],
          "properties": {
            "title": { "type": "string", "minLength": 1, "maxLength": 160 },
            "content": { "type": "string", "maxLength": 100000, "description": "Safe Markdown." },
            "parent": { "$ref": "#/$defs/parent" }
          }
        }
      }
    },
    "memory": {
      "type": "object",
      "additionalProperties": false,
      "required": ["kind", "fields"],
      "properties": {
        "key": { "$ref": "#/$defs/key" },
        "kind": { "const": "memory" },
        "fields": {
          "type": "object",
          "additionalProperties": false,
          "required": ["title", "summary"],
          "properties": {
            "title": { "type": "string", "minLength": 1, "maxLength": 160 },
            "summary": { "type": "string", "minLength": 1, "maxLength": 1200 },
            "content": { "type": "string", "maxLength": 30000 },
            "tags": { "type": "string", "maxLength": 300 },
            "type": { "enum": ["brief", "decision", "gotcha", "note", "session_summary"], "default": "note" },
            "visibility": { "enum": ["private", "shared"], "default": "private", "description": "shared needs a project and becomes a proposal without moderation rights." },
            "expiresAt": { "type": "string", "format": "date-time" }
          }
        }
      }
    }
  }
}
