{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xavidop.github.io/kojo/schema/factory.schema.json",
  "$ref": "#/$defs/FactoryFile",
  "$defs": {
    "FactoryFile": {
      "properties": {
        "merge_policy": {
          "$ref": "#/$defs/MergePolicy",
          "description": "MergePolicy overrides the org's merge policy for this repository:\nits mode, merge method and risk rules. Two things a repository cannot\ndecide for itself are ignored here: who may trigger work\n(trigger_permission is the org's), and auto_merge without an admin's\nallow_auto_merge on the repository."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "description": "FactoryFile is .factory/factory.yaml: a repository's own settings."
    },
    "MergePolicy": {
      "properties": {
        "inherit": {
          "type": "boolean",
          "description": "Inherit, in a repository's scope, means \"no override\": the org's\npolicy applies. It is how an override is taken back."
        },
        "mode": {
          "type": "string",
          "description": "Mode is draft_only (default): always a draft pull request; ask: a\nhuman approves in chat before the pull request is opened ready for\nreview; auto_merge: low-risk changes merge once required checks are\ngreen, medium-risk ones ask, high-risk ones stay drafts."
        },
        "trigger_permission": {
          "type": "string",
          "description": "TriggerPermission is the forge permission a user needs for a request\nto cause write actions: read, triage, write (default), maintain or\nadmin. Requests from anyone else are answered read-only."
        },
        "merge_method": {
          "type": "string",
          "description": "MergeMethod is merge, squash (default) or rebase."
        },
        "approval_timeout": {
          "type": "string",
          "pattern": "^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$",
          "description": "ApprovalTimeout is how long a question the policy asks in chat stays\nopen: \"Open a pull request?\" (ask) and \"Merge this pull request?\"\n(auto_merge, medium risk). Without an answer by then, the change is\nopened as a draft pull request, or the pull request stays open\nwithout a merge. Default 2h, at least 1m. \"Open a pull request?\"\ncloses no later than 30 minutes before the session's sandbox expires\n(sandbox.ttl), because the change is read from the sandbox when it is\npublished."
        },
        "risk": {
          "$ref": "#/$defs/RiskPolicy"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "description": "MergePolicy decides what happens to a change the factory produced."
    },
    "RiskPolicy": {
      "properties": {
        "max_changed_lines": {
          "type": "integer",
          "description": "MaxChangedLines is the diff size at which size alone is high risk.\nDefault 400."
        },
        "sensitive_paths": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "description": "SensitivePaths are globs that make a change high risk when touched.\nDefault: CI config, deployment manifests, migrations, auth code."
        },
        "low_below": {
          "type": "number",
          "description": "LowBelow and HighAbove split the score into low, medium and high.\nDefaults 0.3 and 0.6."
        },
        "high_above": {
          "type": "number"
        },
        "classifier": {
          "type": "boolean",
          "description": "Classifier adds a fast-tier model's opinion to the rules."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "description": "RiskPolicy holds the deterministic rules of the risk score."
    }
  },
  "title": ".factory/factory.yaml: a repository's settings"
}
