{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://claude-context.dev/schemas/research.schema.json",
  "title": "Claude Context Research Document",
  "description": "Schema for RPI research phase documents (YAML frontmatter)",
  "type": "object",
  "required": ["name", "objective", "status"],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "Research topic/feature name"
    },
    "objective": {
      "type": "string",
      "maxLength": 500,
      "description": "What this research aims to discover"
    },
    "status": {
      "type": "string",
      "enum": ["in-progress", "completed", "blocked", "archived"],
      "description": "Current research status"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "Research start time"
    },
    "completed_at": {
      "type": "string",
      "format": "date-time",
      "description": "Research completion time"
    },
    "context_tokens_used": {
      "type": "integer",
      "minimum": 0,
      "description": "Tokens used during research"
    },
    "files_explored": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "file": { "type": "string" },
          "lines": { "type": "string", "description": "Line range (e.g., '10-50')" },
          "findings": { "type": "string" }
        },
        "required": ["file"]
      },
      "description": "Files explored with findings"
    },
    "call_chains": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "entry_point": { "type": "string" },
          "depth": { "type": "integer" },
          "chain": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      },
      "description": "Traced call chains"
    },
    "dependencies": {
      "type": "object",
      "properties": {
        "internal": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Internal module dependencies"
        },
        "external": {
          "type": "array",
          "items": { "type": "string" },
          "description": "External service dependencies"
        }
      },
      "description": "Identified dependencies"
    },
    "test_coverage": {
      "type": "object",
      "properties": {
        "existing_tests": {
          "type": "array",
          "items": { "type": "string" }
        },
        "gaps": {
          "type": "array",
          "items": { "type": "string" }
        }
      },
      "description": "Test coverage analysis"
    },
    "open_questions": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Unresolved questions"
    },
    "summary": {
      "type": "string",
      "maxLength": 1000,
      "description": "Executive summary (max 150 words recommended)"
    },
    "next_phase": {
      "type": "string",
      "enum": ["plan", "more-research", "blocked"],
      "description": "Recommended next phase"
    }
  },
  "additionalProperties": false
}
