{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wrok.in/config.schema.json",
  "title": ".wrokin/config.yml",
  "description": "Repo-level wrokin agent overrides. SPARSE: only fields present here override the dashboard-stored settings; absent fields keep their stored values. Persona/custom instructions are deliberately not settable from this file (owner-controlled in the dashboard). Invalid entries are ignored with errors reported to the installer's logs; the rest of the file still applies.",
  "type": "object",
  "properties": {
    "version": {
      "const": 1,
      "description": "Config format version. Only 1 exists."
    },
    "agents": {
      "type": "object",
      "description": "Per-role overrides, keyed by agent role.",
      "properties": {
        "code-review": { "$ref": "#/$defs/agentOverride" },
        "security-audit": { "$ref": "#/$defs/agentOverride" },
        "issue-triage": { "$ref": "#/$defs/agentOverride" },
        "repo-audit": { "$ref": "#/$defs/agentOverride" },
        "project-management": { "$ref": "#/$defs/agentOverride" }
      },
      "additionalProperties": false
    },
    "architecture": {
      "type": "object",
      "description": "Platform-architecture audit in code review: every NEW Cloud Function / Cloudflare Worker / Firestore collection / Storage path proposed by a PR is judged against the repo's existing resources (extend-existing by default, to stop function/collection sprawl). Detected automatically from repo markers (firebase.json, firestore.rules, storage.rules, functions/ entry, wrangler.toml|json|jsonc); set `audit` only to override detection.",
      "properties": {
        "audit": {
          "description": "auto (default): on for the platforms detected in the repo, off otherwise. on: force every platform family even without markers. off: no platform audit and no reuse/package suggestions. Booleans are accepted as aliases (true = on, false = off) because YAML authors naturally write them.",
          "enum": ["auto", "on", "off", true, false]
        }
      },
      "additionalProperties": false
    },
    "layers": {
      "type": "object",
      "description": "Architecture layer-boundary rules. A file matching a rule's `match` glob that adds a relative import resolving into a layer named in its `cannotImport` is flagged as a Dependency-Inversion violation (advisory).",
      "properties": {
        "rules": {
          "type": "array",
          "maxItems": 50,
          "items": {
            "type": "object",
            "properties": {
              "name": { "type": "string", "description": "Layer name, referenced by other rules' cannotImport." },
              "match": { "type": "string", "maxLength": 200, "description": "Path glob (`**`, `*`, `?`) selecting the layer's files, e.g. `src/domain/**`." },
              "cannotImport": { "type": "array", "items": { "type": "string" }, "description": "Layer names this layer must not import from. May be empty for a target-only layer." }
            },
            "required": ["name", "match"],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "project": {
      "type": "object",
      "description": "GitHub Projects v2 board sync for the Project Management agent (#765 / #775). Absent = milestones + status comments only (Phase 1). Org boards need Organization → Projects: Read & write (#764). User-owned boards need a fine-grained Projects PAT in the dashboard (#775) — never in this file.",
      "properties": {
        "number": {
          "type": "integer",
          "minimum": 1,
          "description": "Project v2 number (from the project URL — org or user)."
        },
        "statusField": {
          "type": "string",
          "minLength": 1,
          "description": "Single-select field to sync. Default Status."
        },
          "addIfMissing": {
            "type": "boolean",
            "description": "Add the issue/PR to the project when it is not already an item. Default false (opt in — avoids board pollution from untrusted open/close spam)."
          },
        "status": {
          "type": "object",
          "description": "Map issue/PR state onto Status option names (matched case-insensitively).",
          "properties": {
            "open": { "type": "string", "minLength": 1, "description": "Option for open work. Default Todo." },
            "closed": { "type": "string", "minLength": 1, "description": "Option for closed work. Default Done." }
          },
          "additionalProperties": false
        }
      },
      "required": ["number"],
      "additionalProperties": false
    }
  },
  "additionalProperties": false,
  "$defs": {
    "agentOverride": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean",
          "description": "Turn this agent on/off for the repo."
        },
        "model": {
          "type": "object",
          "description": "Which model this agent calls, on the installer's own key (BYOK).",
          "properties": {
            "provider": {
              "anyOf": [
                { "enum": [
                  "anthropic",
                  "openai",
                  "deepseek",
                  "google",
                  "mistral",
                  "openrouter",
                  "moonshot",
                  "groq",
                  "xai",
                  "meta",
                  "cruise"
                ] },
                {
                  "type": "string",
                  "pattern": "^custom:[a-z0-9]+(?:-[a-z0-9]+)*$",
                  "description": "A custom OpenAI-compatible provider you defined in the dashboard, e.g. custom:office-gpu. Whether it exists is settled when the agent runs, not here."
                }
              ],
              "description": "A provider the installer has added a key for in the dashboard, or a custom:<slug> endpoint they defined."
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "description": "Any model id the key can call, e.g. claude-sonnet-5, deepseek-v4-flash."
            }
          },
          "required": ["provider", "name"],
          "additionalProperties": false
        },
        "on": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Trigger events. The shipped roles use pull_request (code-review, security-audit) and issues (issue-triage); repo-audit is on-demand (/w audit) and needs no events."
        },
        "paths": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Glob path list. Accepted and stored, but dispatch filtering by path is NOT enforced yet — do not rely on it to exclude files."
        }
      },
      "additionalProperties": false
    }
  }
}
