{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "ai.stravica.knowledge.research/manifest.schema.json",
  "title": "Research session manifest",
  "description": "Root manifest.json for a research session, at sessions/<sessionId>/manifest.json. Hand-rolled validator: src/store/manifest.mjs. camelCase throughout.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "sessionId",
    "mode",
    "question",
    "gatePolicy",
    "status",
    "outputMode",
    "budget",
    "assumptions",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "sessionId": {
      "type": "string",
      "description": "ULID-like 26-char Crockford base32 id: 10-char ms timestamp + 16-char entropy. Lexicographically sortable by creation time.",
      "pattern": "^[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "mode": { "type": "string", "enum": ["light", "normal", "deep"] },
    "question": { "type": "string", "minLength": 1, "description": "Raw operator question." },
    "intent": { "type": "string", "description": "Clarified intent, if the caller passed one." },
    "gatePolicy": {
      "type": "string",
      "enum": ["operatorPresent", "background", "worker"],
      "description": "Human-gate execution posture (build-spec §6)."
    },
    "status": { "type": "string", "enum": ["draft", "in-progress", "done", "aborted"] },
    "outputMode": {
      "type": "string",
      "enum": ["shortAnswer", "article", "structured"],
      "description": "Synthesis render target. Defaults to shortAnswer."
    },
    "budget": {
      "type": "object",
      "description": "Records what the run was scoped to. Not enforced by the CLI.",
      "additionalProperties": false,
      "required": ["maxSubQuestions", "maxDeepeningRounds", "wallClockMinutes"],
      "properties": {
        "maxSubQuestions": { "type": "integer", "minimum": 0 },
        "maxDeepeningRounds": { "type": "integer", "minimum": 0 },
        "wallClockMinutes": { "type": "integer", "minimum": 0 }
      }
    },
    "assumptions": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Scope-narrowing assumptions recorded when a background run cannot clarify (build-spec §4)."
    },
    "createdAt": { "type": "string", "description": "ISO 8601 UTC." },
    "updatedAt": { "type": "string", "description": "ISO 8601 UTC." }
  }
}
