{
  "$defs": {
    "AppliesTo": {
      "additionalProperties": false,
      "description": "Narrows where the rule is active. An absent key means no restriction.",
      "minProperties": 1,
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "genres": {
          "items": {
            "$ref": "#/$defs/Genre"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        },
        "modes": {
          "items": {
            "$ref": "#/$defs/ApplyMode"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        }
      },
      "type": "object"
    },
    "ApplyMode": {
      "description": "Lint input surface, chosen by --mode. Its text context tag is code-comment (lint-report Finding.contexts), a separate label that keeps its singular spelling.",
      "enum": [
        "prose",
        "code-comments"
      ]
    },
    "BlockKind": {
      "description": "A block or span kind the rule must not look inside.",
      "enum": [
        "heading",
        "list-item",
        "code",
        "code-span",
        "table",
        "quote",
        "front-matter"
      ]
    },
    "CapitalizationMatch": {
      "additionalProperties": false,
      "description": "Report text that is not written in the named capitalization style. New in 3.0: 2.x expresses this as a pattern.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "allowed_words": {
          "description": "Words exempt from the style, such as product names.",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "type": "array",
          "uniqueItems": true
        },
        "kind": {
          "const": "capitalization"
        },
        "style": {
          "description": "The style.",
          "enum": [
            "sentence",
            "title",
            "lower",
            "upper"
          ]
        }
      },
      "required": [
        "kind",
        "style"
      ],
      "type": "object"
    },
    "Case": {
      "additionalProperties": false,
      "anyOf": [
        {
          "required": [
            "want"
          ]
        },
        {
          "required": [
            "contains"
          ]
        },
        {
          "required": [
            "absent"
          ]
        }
      ],
      "description": "A test case in the style of vale test. The input is linted with only this rule enabled. want counts findings, contains and absent compare against the matched text and message of those findings.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "absent": {
          "description": "No finding has a matched text or message that contains any of these strings.",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "minItems": 1,
          "type": "array"
        },
        "contains": {
          "description": "Each string appears in the matched text or message of some finding.",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "minItems": 1,
          "type": "array"
        },
        "input": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "want": {
          "description": "Expected finding count, or an inclusive range.",
          "oneOf": [
            {
              "description": "Exactly this many findings.",
              "minimum": 0,
              "type": "integer"
            },
            {
              "additionalProperties": false,
              "description": "Between `min` and `max` findings, inclusive.",
              "minProperties": 1,
              "properties": {
                "max": {
                  "minimum": 0,
                  "type": "integer"
                },
                "min": {
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "required": [
        "input"
      ],
      "type": "object"
    },
    "Citation": {
      "additionalProperties": false,
      "description": "Where the rule's idea comes from, so a reader can argue with it. Not the runtime `RuleProvenance`, which names the pack that supplied a rule.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "note": {
          "description": "A note for the reader.",
          "type": "string"
        },
        "orwell_ref": {
          "description": "Orwell reference.",
          "type": "string"
        },
        "source": {
          "description": "The source.",
          "minLength": 1,
          "type": "string"
        },
        "ste_ref": {
          "description": "Issue-qualified STE rule number such as 9:1.2 or 9:GR-2. A citation only.",
          "pattern": "^(?:[0-9]+:[0-9]+\\.[0-9]+|[0-9]+:GR-[0-9]+)(?![\\s\\S])",
          "type": "string"
        },
        "url": {
          "description": "A link.",
          "type": "string"
        }
      },
      "required": [
        "source"
      ],
      "type": "object"
    },
    "Contexts": {
      "additionalProperties": false,
      "description": "Context tags that gate the rule. With only, the rule runs on text that carries at least one listed tag. With skip, it is silent on text that carries any listed tag.",
      "minProperties": 1,
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "only": {
          "items": {
            "$ref": "common.schema.json#/$defs/ContextTag"
          },
          "type": "array",
          "uniqueItems": true
        },
        "skip": {
          "items": {
            "$ref": "common.schema.json#/$defs/ContextTag"
          },
          "type": "array",
          "uniqueItems": true
        }
      },
      "type": "object"
    },
    "Example": {
      "additionalProperties": false,
      "description": "A before and after pair shown in rule documentation. For a mechanical rule the test runner also asserts that bad produces a finding and good produces none.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "bad": {
          "description": "Text the rule flags.",
          "type": "string"
        },
        "good": {
          "description": "The fixed text, which the rule leaves alone.",
          "type": "string"
        },
        "note": {
          "description": "A note for the reader.",
          "type": "string"
        }
      },
      "required": [
        "bad"
      ],
      "type": "object"
    },
    "Exception": {
      "additionalProperties": false,
      "description": "A named, closed reason a finding may be suppressed. A suppression annotation must cite one by name. With detector, the engine drops the finding itself when the named detector, or the context tag of that name, holds at the match.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "description": {
          "description": "Prose description.",
          "type": "string"
        },
        "detector": {
          "description": "A detector (or context tag) that drops the finding itself.",
          "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
          "type": "string"
        },
        "name": {
          "description": "The name a suppression annotation cites.",
          "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
          "type": "string"
        }
      },
      "required": [
        "name"
      ],
      "type": "object"
    },
    "Genre": {
      "description": "Genre id.",
      "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
      "type": "string"
    },
    "JudgementMatch": {
      "additionalProperties": false,
      "description": "A check no linter can run. Carried so writing and review guidance read one source. Never produces a finding.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "kind": {
          "const": "judgement"
        },
        "question": {
          "description": "The question the reviewer must answer. It must be decidable, not a matter of taste.",
          "minLength": 1,
          "type": "string"
        }
      },
      "required": [
        "kind",
        "question"
      ],
      "type": "object"
    },
    "LocalRuleId": {
      "description": "Rule id inside its category. The qualified RuleId is <plugin>:<category>.<id>, built from the plugin manifest, the category id and this id.",
      "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
      "type": "string"
    },
    "Match": {
      "description": "The typed detection payload. match.kind selects the one allowed shape.",
      "oneOf": [
        {
          "$ref": "#/$defs/TokensMatch"
        },
        {
          "$ref": "#/$defs/PatternMatch"
        },
        {
          "$ref": "#/$defs/SubstitutionMatch"
        },
        {
          "$ref": "#/$defs/MetricMatch"
        },
        {
          "$ref": "#/$defs/StructureMatch"
        },
        {
          "$ref": "#/$defs/CapitalizationMatch"
        },
        {
          "$ref": "#/$defs/VocabularyMatch"
        },
        {
          "$ref": "#/$defs/JudgementMatch"
        }
      ],
      "x-slopvac-extensible": true
    },
    "MetricMatch": {
      "additionalProperties": false,
      "description": "A counted measurement compared with a threshold. The finding fires when `measured <comparison> threshold` holds.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "comparison": {
          "default": "gt",
          "description": "How the measured value compares with the threshold.",
          "enum": [
            "gt",
            "gte",
            "lt",
            "lte"
          ]
        },
        "kind": {
          "const": "metric"
        },
        "metric": {
          "description": "Metric name. The names the 2.x engine measures are listed in docs/contract/rules.md.",
          "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])",
          "type": "string"
        },
        "threshold": {
          "description": "The threshold.",
          "type": "number"
        }
      },
      "required": [
        "kind",
        "metric",
        "threshold"
      ],
      "type": "object"
    },
    "PatternMatch": {
      "additionalProperties": false,
      "description": "A PCRE2 regular expression.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "ignore_case": {
          "default": true,
          "description": "Match regardless of case.",
          "type": "boolean"
        },
        "kind": {
          "const": "pattern"
        },
        "match_all_caps": {
          "default": false,
          "description": "Report a match written entirely in capitals.",
          "type": "boolean"
        },
        "pattern": {
          "$ref": "#/$defs/Pcre2Pattern",
          "description": "The pattern."
        },
        "placeholders": {
          "additionalProperties": {
            "description": "The source of a placeholder's value. The only one is the locale allow list.",
            "enum": [
              "allowed-words"
            ]
          },
          "description": "Maps a literal placeholder string in the pattern to a configuration source. The only source is allowed-words: the loader replaces the placeholder with an alternation of the escaped ASCII alphabetic words from the locale allow list, sorted case-insensitively. With no words it becomes (?!), which never matches.",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Z][A-Z0-9_]*(?![\\s\\S])"
          },
          "type": "object"
        }
      },
      "required": [
        "kind",
        "pattern"
      ],
      "type": "object"
    },
    "Pcre2Pattern": {
      "description": "A PCRE2 pattern (10.43 or later). The pattern may not contain a \\uXXXX or \\UXXXXXXXX escape: write the literal character, or \\x{X...} in rule data written for v3. A lookbehind must have a finite maximum length of at most 255 characters, so + , * and {n,} are not allowed inside one. The schema rejects the \\u and \\U escapes; the loader compiles the rest.",
      "minLength": 1,
      "not": {
        "pattern": "^(?:[^\\\\]|\\\\[^uU])*\\\\[uU]"
      },
      "type": "string"
    },
    "Rule": {
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "match": {
                "properties": {
                  "kind": {
                    "const": "judgement"
                  }
                },
                "required": [
                  "kind"
                ]
              }
            },
            "required": [
              "match"
            ]
          },
          "then": {
            "properties": {
              "cases": {
                "maxItems": 0
              },
              "exceptions": {
                "maxItems": 0
              },
              "severity": {
                "const": "suggestion"
              }
            }
          }
        }
      ],
      "description": "One check, as a category file embeds it.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "ai_signal": {
          "default": "none",
          "description": "How strongly a finding indicates machine-written text.",
          "enum": [
            "strong",
            "weak",
            "none"
          ]
        },
        "ai_signal_source": {
          "default": "unmeasured",
          "description": "Where the `ai_signal` value comes from.",
          "enum": [
            "measured",
            "catalog",
            "unmeasured"
          ]
        },
        "allowlist": {
          "description": "Literal strings that never fire, even when the match holds.",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "type": "array",
          "uniqueItems": true
        },
        "applies_to": {
          "$ref": "#/$defs/AppliesTo"
        },
        "cases": {
          "items": {
            "$ref": "#/$defs/Case"
          },
          "type": "array"
        },
        "citation": {
          "$ref": "#/$defs/Citation"
        },
        "contexts": {
          "$ref": "#/$defs/Contexts"
        },
        "examples": {
          "items": {
            "$ref": "#/$defs/Example"
          },
          "type": "array"
        },
        "exceptions": {
          "items": {
            "$ref": "#/$defs/Exception"
          },
          "type": "array",
          "uniqueItems": true
        },
        "exclude_blocks": {
          "items": {
            "$ref": "#/$defs/BlockKind"
          },
          "type": "array",
          "uniqueItems": true
        },
        "fix": {
          "description": "The rewrite operation, as guidance.",
          "type": "string"
        },
        "id": {
          "$ref": "#/$defs/LocalRuleId"
        },
        "match": {
          "$ref": "#/$defs/Match"
        },
        "message": {
          "description": "Shown on a finding. Names the fix, not the violation. {match} and {replacement} interpolate.",
          "minLength": 1,
          "type": "string"
        },
        "name": {
          "description": "Short imperative label.",
          "minLength": 1,
          "type": "string"
        },
        "schema_version": {
          "$ref": "common.schema.json#/$defs/SchemaVersion"
        },
        "scope": {
          "$ref": "#/$defs/Scope"
        },
        "severity": {
          "$ref": "common.schema.json#/$defs/Severity",
          "default": "warning",
          "description": "The shipped level. A category cap or a profile shift can lower it, never a rule. Disabling a rule is configuration, so there is no off level."
        },
        "text_type": {
          "$ref": "#/$defs/TextType"
        }
      },
      "required": [
        "id",
        "name",
        "message",
        "match",
        "citation"
      ],
      "type": "object"
    },
    "Scope": {
      "default": "prose",
      "description": "Which text units a lexical rule sees. prose is every prose block without code, URLs and front matter. body-sentence is sentence minus heading and table blocks. raw is the unparsed source and is for formatting rules only.",
      "enum": [
        "prose",
        "heading",
        "sentence",
        "body-sentence",
        "paragraph",
        "document",
        "raw"
      ]
    },
    "StructureMatch": {
      "additionalProperties": false,
      "description": "A block-level shape check implemented by the engine and selected by name.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "check": {
          "description": "The check name.",
          "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
          "type": "string"
        },
        "kind": {
          "const": "structure"
        }
      },
      "required": [
        "kind",
        "check"
      ],
      "type": "object"
    },
    "SubstitutionMatch": {
      "additionalProperties": false,
      "description": "A map from a PCRE2 pattern to its replacement. The message names the replacement.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "ignore_case": {
          "default": true,
          "description": "Match regardless of case.",
          "type": "boolean"
        },
        "kind": {
          "const": "substitution"
        },
        "match_all_caps": {
          "default": false,
          "description": "Report a match written entirely in capitals.",
          "type": "boolean"
        },
        "substitutions": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "Pattern to replacement.",
          "minProperties": 1,
          "propertyNames": {
            "$ref": "#/$defs/Pcre2Pattern"
          },
          "type": "object"
        }
      },
      "required": [
        "kind",
        "substitutions"
      ],
      "type": "object"
    },
    "TextType": {
      "default": "any",
      "description": "Restrict the rule to sentences of one STE text type. any means the rule does not care.",
      "enum": [
        "any",
        "procedural",
        "descriptive",
        "safety"
      ]
    },
    "TokensMatch": {
      "additionalProperties": false,
      "description": "Literal phrases, matched at word boundaries.",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "ignore_case": {
          "default": true,
          "description": "Match regardless of case.",
          "type": "boolean"
        },
        "kind": {
          "const": "tokens"
        },
        "match_all_caps": {
          "default": false,
          "description": "Report a match written entirely in capitals. Off by default because an all-caps token is usually a keyword, an identifier or an initialism. Applies to tokens, pattern and substitution.",
          "type": "boolean"
        },
        "tokens": {
          "description": "The phrases.",
          "items": {
            "minLength": 1,
            "type": "string"
          },
          "minItems": 1,
          "type": "array",
          "uniqueItems": true
        }
      },
      "required": [
        "kind",
        "tokens"
      ],
      "type": "object"
    },
    "VocabularyMatch": {
      "additionalProperties": false,
      "description": "A part-of-speech keyed controlled-vocabulary lookup selected by name (STE rule 1.2).",
      "patternProperties": {
        "^x-": true
      },
      "properties": {
        "check": {
          "description": "The check name.",
          "pattern": "^[a-z][a-z0-9-]*(?![\\s\\S])",
          "type": "string"
        },
        "kind": {
          "const": "vocabulary"
        }
      },
      "required": [
        "kind",
        "check"
      ],
      "type": "object"
    }
  },
  "$id": "https://slopvac.github.io/slopvac/schemas/v3/rule.schema.json",
  "$ref": "#/$defs/Rule",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "description": "One check. The root validates a standalone rule file and requires schema_version. A category file embeds the same shape through $defs/Rule, where schema_version is absent. Semantics are specified in docs/contract/rules.md.",
  "required": [
    "schema_version"
  ],
  "title": "slopvac v3 rule"
}
