{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cedarloom.github.io/cedarloom/schema/cedarloom.json",
  "title": "CedarLoom repository settings (cedarloom.json at the repository root)",
  "type": "object",
  "additionalProperties": false,
  "patternProperties": { "^//": {} },
  "$defs": {
    "pair": {
      "title": "{ model, effort }",
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "required": ["model", "effort"],
      "properties": {
        "model": {
          "enum": ["haiku", "sonnet", "opus", "fable"],
          "description": "Which model runs the step. Use a stronger one for planning, building and review, a cheaper one for reading and lookups."
        },
        "effort": {
          "enum": ["low", "medium", "high", "xhigh", "max"],
          "description": "How much thinking the model spends. Raise it for a step that misses problems, lower it to save time and cost."
        }
      }
    },
    "role": { "title": "a role name", "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
    "value": { "anyOf": [{ "$ref": "#/$defs/role" }, { "$ref": "#/$defs/pair" }] },
    "build": {
      "anyOf": [
        { "$ref": "#/$defs/role" },
        {
          "title": "{ model: opus, effort }",
          "type": "object",
          "additionalProperties": false,
          "patternProperties": { "^//": {} },
          "required": ["model", "effort"],
          "properties": {
            "model": { "enum": ["opus"], "description": "Always opus: implementation and fixes run only on opus." },
            "effort": {
              "enum": ["low", "medium", "high", "xhigh", "max"],
              "description": "How much thinking the model spends. Raise it for a step that misses problems, lower it to save time and cost."
            }
          }
        }
      ]
    },
    "row": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "coordinate": { "$ref": "#/$defs/value", "description": "The project bot's own runs: picking issues, catching up and routing pull request events." },
        "plan": { "$ref": "#/$defs/value", "description": "Planning an issue or task before any code is written." },
        "review": { "$ref": "#/$defs/value", "description": "Reviewing a pull request or a change." },
        "recheck": { "$ref": "#/$defs/value", "description": "Reviewing a fix against the findings that came before it." },
        "verify": { "$ref": "#/$defs/value", "description": "Checking review findings, a plan or a research answer before they are used." },
        "zoom-out": { "$ref": "#/$defs/value", "description": "Checking a plan or design for a simpler route." },
        "fresh-read": { "$ref": "#/$defs/value", "description": "Reads by a session that starts without the work's history." },
        "audit": { "$ref": "#/$defs/value", "description": "Audits of docs, agent instructions or code." },
        "research": { "$ref": "#/$defs/value", "description": "Research and design consults." },
        "implement": { "$ref": "#/$defs/build", "description": "Writing the change. Runs only on opus." },
        "fix": { "$ref": "#/$defs/build", "description": "Fixing review findings. Runs only on opus." },
        "test": { "$ref": "#/$defs/value", "description": "Running the full checks and trying to break the change." },
        "docs": { "$ref": "#/$defs/value", "description": "Docs passes, where several documents are checked against the code." },
        "triage": { "$ref": "#/$defs/value", "description": "Sorting new issues." },
        "digest": { "$ref": "#/$defs/value", "description": "Writing the digest of the bot's work." },
        "merge": { "$ref": "#/$defs/value", "description": "The steps of a merge." },
        "gather": { "$ref": "#/$defs/value", "description": "Read-only lookups of files, logs and pull request status." },
        "lookup": { "$ref": "#/$defs/value", "description": "Looking up one fact." },
        "cleanup": { "$ref": "#/$defs/value", "description": "The cleanup bot's passes." }
      }
    }
  },
  "properties": {
    "$schema": { "type": "string", "description": "The address of this schema, so an editor checks and completes the file. Keep the line setup writes." },
    "schemaVersion": { "enum": [3], "description": "The version of the file format, 3. Keep it as setup wrote it: any other value makes the file unreadable." },
    "startLabel": {
      "type": "string",
      "minLength": 1,
      "description": "The label that lets the bot start an issue. Pick it at setup; a CedarLoom label other than cl:ready-for-agent is refused. Without it nothing starts."
    },
    "trustedAuthors": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "description": "Logins whose issue, review and comment text workers may follow, besides you and the members and collaborators with write access. Add a review bot only if you trust its text; a bot counts only when listed."
    },
    "workersPerProject": {
      "deprecated": true,
      "type": "integer",
      "minimum": 1,
      "maximum": 32,
      "description": "Ignored. The computer shares its workers between projects; cap one project in host.json (projects.<project>.maxWorkers)."
    },
    "hostWorkerLimit": { "deprecated": true, "type": "integer", "minimum": 1, "maximum": 64, "description": "Ignored. The computer's worker limit is maxWorkers in host.json." },
    "stallMinutes": {
      "type": "integer",
      "minimum": 1,
      "maximum": 1440,
      "description": "Minutes without a commit, pull request or message before the bot counts a worker as stalled and releases it. Raise it for work with long silent steps, such as slow builds."
    },
    "issuesPerWorker": {
      "type": "integer",
      "minimum": 1,
      "maximum": 16,
      "description": "How many startable issues one supervised worker takes as a batch. Raise it for many small issues; an automatic worker always takes one."
    },
    "mode": {
      "enum": ["supervised", "automatic"],
      "description": "How workers run: supervised, or automatic with a settings file that bounds each worker. Switch to automatic only in an isolated environment."
    },
    "minPlugin": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "The oldest plugin version that may run this file; an older plugin refuses it. Set it to the version that knows the newest key you use."
    },
    "riskyPaths": {
      "type": "array",
      "items": { "type": "string", "pattern": "^(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s)(?:/(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s))*/?$" },
      "description": "Paths whose change makes a pull request at least elevated and sensitive. List folders, such as deploy scripts or migrations, that deserve more care than their size suggests."
    },
    "issues": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "labels": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string", "minLength": 1 },
          "description": "Labels an issue must carry besides startLabel. Use them to start only issues you have triaged."
        }
      },
      "description": "Rules for which issues the bot may start."
    },
    "models": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "roles": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": { "^//": {}, "^[a-z][a-z0-9-]*$": { "description": "One role: its name, then its model and effort.", "$ref": "#/$defs/pair" } },
          "description": "Named model and effort pairs that tasks can use by name. Add a role to reuse one pair for several tasks."
        },
        "tasks": { "$ref": "#/$defs/row", "description": "The role or pair each task uses. Change one task, such as review, to run it on a stronger model." },
        "depth": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": { "^//": {} },
          "properties": {
            "quick": { "$ref": "#/$defs/row", "description": "Task overrides for quick work, with the task names of models.tasks." },
            "deep": { "$ref": "#/$defs/row", "description": "Task overrides for deep work, with the task names of models.tasks." }
          },
          "description": "Overrides by depth. They lower or raise a task's pair for quick or deep work."
        },
        "risk": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": { "^//": {} },
          "properties": {
            "critical": { "$ref": "#/$defs/row", "description": "Task overrides for critical work, with the task names of models.tasks. They can only raise a pair, never lower it." }
          },
          "description": "Overrides by risk class."
        }
      },
      "description": "The model and effort of each step in this project, over CedarLoom's defaults and your user file. Change a step only when its cost or quality needs it."
    },
    "review": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "depth": {
          "enum": ["low", "medium", "high", "xhigh"],
          "description": "How deep the review of a routine change goes: low, medium, high or xhigh. Raise it for riskier code. xhigh runs only for the first review of a critical change, or when you ask."
        },
        "sensitiveDepth": {
          "enum": ["low", "medium", "high", "xhigh"],
          "description": "How deep the review of a sensitive change goes (CI, guards, data formats, money, agent instructions and your sensitivePaths). Raise it above depth where a mistake costs more."
        },
        "reviewer": {
          "type": "string",
          "pattern": "^[A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38}$",
          "description": "The GitHub login the project bot runs under. The bot merges only a commit that login approved. Required for any merge: without it nothing merges."
        },
        "soloOwner": { "deprecated": true, "type": "boolean", "description": "Ignored. The project bot approves its own pull requests; remove the key." },
        "sensitivePaths": {
          "type": "array",
          "items": { "type": "string", "pattern": "^(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s)(?:/(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s))*/?$" },
          "description": "Paths that make a change sensitive, besides the built-in kinds (CI, guards, data formats, money, agent instructions). Add folders where a mistake costs more."
        }
      },
      "description": "How changes are reviewed and who approves them."
    },
    "merge": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "allowed": { "type": "boolean", "description": "Lets the bot merge a reviewed pull request. Off by default: turn it on when you want changes to land without you." },
        "requiredChecks": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 },
          "description": "Checks that must be green before a merge, named as GitHub shows them. List only checks that run on pull requests, not only on the default branch."
        },
        "mode": {
          "enum": ["strict", "disjoint"],
          "description": "strict: the merged commit must contain the default branch's latest commit. disjoint: a pull request that changed other files than the default branch may merge without an update. Choose disjoint when many pull requests touch separate files."
        },
        "autoMergeMax": {
          "enum": ["routine", "elevated"],
          "description": "The highest risk class the bot merges, routine or elevated. Critical is always yours. Lower it to routine to keep elevated changes for yourself."
        },
        "additivePaths": {
          "type": "array",
          "items": { "type": "string", "pattern": "^(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s)(?:/(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s))*/?$" },
          "description": "Paths that a pull request and the default branch may both change in disjoint mode, such as a changelog. Add append-only files."
        },
        "ownerOnlyPaths": {
          "type": "array",
          "items": { "type": "string", "pattern": "^(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s)(?:/(?!\\s)(?!\\.{1,2}(?:/|$))[^/\\\\*\\p{Cc}\\p{Cf}\\p{Zl}\\p{Zp}\\u00A0\\u1680\\u2000-\\u200A\\u202F\\u205F\\u3000]+(?<!\\s))*/?$" },
          "description": "Paths you add to the built-in owner-only list: a pull request that touches one stays open for you. Add the trigger paths of a deploy workflow and anything the bot must never land."
        }
      },
      "description": "When and how the bot lands pull requests."
    },
    "closeIssue": {
      "type": "boolean",
      "description": "A worker's pull request closes its issue when it merges, whoever merges it, and the bot closes one left open. Turn it off to close issues yourself."
    },
    "deleteMergedBranch": { "type": "boolean", "description": "Lets the bot delete a branch once its pull request is merged. Turn it on to keep old branches from piling up." },
    "cleanup": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": { "^//": {} },
      "properties": {
        "daysKept": {
          "type": "integer",
          "minimum": 0,
          "maximum": 365,
          "default": 7,
          "description": "Days a finished work folder stays on disk after its last pull request closed. Raise it to keep folders longer for inspection."
        },
        "diskFloorGB": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000,
          "default": 20,
          "description": "Free disk space in GiB below which the cleanup report warns and no new worker starts on the computer. Raise it on a small disk."
        }
      },
      "description": "What the cleanup bot keeps and when it warns about disk space."
    }
  }
}
