{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "project.json",
  "title": "Project Manifest",
  "description": "A project manifest describing a tracked project.",
  "type": "object",
  "required": ["id", "name", "status", "created"],
  "additionalProperties": false,
  "definitions": {
    "docEntry": {
      "type": "object",
      "required": ["label", "path"],
      "additionalProperties": false,
      "properties": {
        "label": {
          "type": "string",
          "description": "Display label for the document"
        },
        "path": {
          "type": "string",
          "pattern": "^[^/]",
          "description": "Repo-root-relative path to the document. Must NOT start with a leading slash — the file API resolves paths relative to repo root and rejects absolute paths."
        }
      }
    }
  },
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "Unique project identifier (slug)"
    },
    "number": {
      "type": "integer",
      "minimum": 1,
      "description": "Sequential project number for display"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Human-readable project name"
    },
    "category": {
      "type": "string",
      "description": "Project category"
    },
    "status": {
      "type": "string",
      "enum": ["draft", "planned", "in-progress", "blocked", "done", "archived"],
      "description": "Current project status"
    },
    "priority": {
      "type": "integer",
      "minimum": 0,
      "maximum": 3,
      "description": "Priority level: 0 (critical) to 3 (low)"
    },
    "lead": {
      "type": "string",
      "description": "Project lead"
    },
    "owner": {
      "type": "string",
      "description": "Long-term project owner"
    },
    "assignee": {
      "type": "string",
      "description": "Whose move it is right now"
    },
    "executor": {
      "type": "string",
      "description": "Who is executing the project"
    },
    "created": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Creation date in YYYY-MM-DD format"
    },
    "updated": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Last-update date in YYYY-MM-DD format"
    },
    "shipped": {
      "type": ["string", "null"],
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Ship date in YYYY-MM-DD format, or null"
    },
    "path": {
      "type": "string",
      "description": "Relative path to the project directory"
    },
    "summary": {
      "type": "string",
      "description": "Brief project summary"
    },
    "docs": {
      "description": "Related documentation. Two shapes are accepted: a flat array of {label, path} entries (legacy), or an object keyed by group name → array of entries (current). The pa CLI writes the grouped shape; the workspace UI renders both.",
      "oneOf": [
        {
          "type": "array",
          "items": { "$ref": "#/definitions/docEntry" }
        },
        {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": { "$ref": "#/definitions/docEntry" }
          }
        }
      ]
    }
  }
}
