{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lenserfight.dev/schemas/lenser/v1alpha1",
  "title": "LenserFight Lenser Spec",
  "description": "An AI agent with a defined mission, tool policy, and operating rules.",
  "type": "object",
  "allOf": [{ "$ref": "common.schema.json#/$defs/baseSpec" }],
  "properties": {
    "apiVersion": { "$ref": "common.schema.json#/$defs/apiVersion" },
    "kind": { "type": "string", "enum": ["lenser", "agent"] },
    "schema_version": { "type": "integer", "minimum": 1 },
    "id": { "$ref": "common.schema.json#/$defs/specId" },
    "slug": { "$ref": "common.schema.json#/$defs/slug" },
    "name": { "type": "string", "minLength": 1, "maxLength": 200 },
    "description": { "type": "string", "minLength": 1, "maxLength": 2000 },
    "version": { "$ref": "common.schema.json#/$defs/semver" },
    "visibility": { "$ref": "common.schema.json#/$defs/visibility" },
    "status": { "$ref": "common.schema.json#/$defs/status" },
    "owner": { "$ref": "common.schema.json#/$defs/owner" },
    "tags": { "$ref": "common.schema.json#/$defs/tags" },
    "role": {
      "type": "string",
      "description": "Functional role of this lenser (e.g. reviewer, researcher, operator)."
    },
    "capabilities": {
      "type": "array",
      "items": { "type": "string" },
      "description": "Declared capability identifiers."
    },
    "model_policy": { "$ref": "common.schema.json#/$defs/modelPolicy" },
    "tool_policy": { "$ref": "common.schema.json#/$defs/toolPolicy" },
    "memory_policy_ref": {
      "type": "string",
      "description": "Reference to a MemoryPolicy spec ID."
    },
    "workspace_permissions": {
      "type": "object",
      "properties": {
        "read_scopes": { "type": "array", "items": { "type": "string" } },
        "write_scopes": { "type": "array", "items": { "type": "string" } }
      },
      "additionalProperties": false
    },
    "allowed_actions": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["read", "suggest", "draft", "simulate", "execute", "modify", "publish", "external_action", "admin"]
      }
    },
    "safety_boundaries": {
      "type": "object",
      "additionalProperties": true
    },
    "references": {
      "type": "array",
      "items": { "$ref": "common.schema.json#/$defs/disclosureRef" }
    }
  },
  "required": ["kind", "name", "description"],
  "additionalProperties": true,
  "examples": [
    {
      "apiVersion": "lenserfight.dev/v1alpha1",
      "kind": "lenser",
      "schema_version": 1,
      "id": "lenser_developer_reviewer",
      "slug": "developer-reviewer",
      "name": "Developer Reviewer",
      "description": "Reviews code diffs, PRs, and architecture decisions.",
      "role": "reviewer",
      "capabilities": ["code_review", "architecture_review"],
      "model_policy": {
        "mode": "dynamic",
        "preferred_models": ["claude-sonnet-4-6"]
      }
    }
  ]
}
