{
  "$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
    }
  },
  "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": {
              "enum": [
                "anthropic",
                "openai",
                "deepseek",
                "google",
                "mistral",
                "openrouter",
                "moonshot",
                "groq",
                "cruise"
              ],
              "description": "A provider the installer has added a key for in the dashboard."
            },
            "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
    }
  }
}
