Matcher format v1

Every key a schema: 1 matcher file may hold. What matchers, outputs and roles are for is on Matchers.

The tables below are generated from the models ci-doctor validates with, and ci-doctor matchers schema prints the same format as JSON Schema. Each release attaches it as matcher-v1.schema.json, so an editor can complete and check a file:

# yaml-language-server: $schema=https://github.com/ci-doctor/ci-doctor/releases/latest/download/matcher-v1.schema.json
schema: 1
id: mytool

On a matcher

A matcher with one output puts role, match (or variants) and window at the top level; with several, they go on each entry of outputs.

KeyRequiredIts job
schema yes The format version this file is written in.
id yes Matcher id: bare in a registry file (`ruff`), `alias/id` once loaded. Equals its folder name.
description yes With one output, the prompt text. With `outputs`, a one-line summary for people.
tags yes 1-5 tags, for search and filters.
define no Named pattern pieces: `$NAME` in a template, `%{NAME}` in a regex.
outputs no The outputs, when there are several.
role no One output only. Default `tool`.
match no One output only: finds the anchor lines.
variants no One output only: one spelling each.
window no One output only: lines kept around the anchor.

On an output

Each entry of outputs. Its id is <matcher>.<key>.

KeyRequiredIts job
description yes What the evidence means; prompt text. 20-250 printable ASCII.
role no Ranks the window under budget pressure and tells the model how to read it.
match no Finds the anchor lines. Set this or `variants`.
variants no One spelling each. Set this or `match`.
window no Which lines around the anchor become evidence.

On a variant

Each entry of variants. Its key is the name verify and examine report.

KeyRequiredIts job
match yes Finds this spelling.
window no Only when this spelling needs a different window.

In a match

Each node is a mapping with exactly one of these keys.

KeyIts job
regex RE2, matched anywhere in the line. `%{NAME}` inserts a `define`.
template The line as it looks in the log: `$NAME` inserts a `define`, `...` is anything, `$$` is a `$`, and everything else is literal text. Matched anywhere in the line.
all The line matches every item.
any The line matches at least one item.
not The line doesn't match this.
inside The line sits inside such a block.
preceded_by A matching line is among the `within` lines above.
followed_by A matching line is among the `within` lines below.

In preceded_by, followed_by and window.from

A match node written inline, plus within.

KeyRequiredIts job
within yes How many lines to look, 1-500.

In inside

KeyRequiredIts job
start yes Opens a block.
end yes Closes it, on the first match after `start`.
max_lines yes Closes it after this many lines if `end` never comes.

In a window

before excludes from; after excludes until and while.

KeyRequiredIts job
before no Lines kept above the anchor, 0-100.
after no Lines kept below the anchor, 0-100.
from no Start at the nearest matching line above, looking `within` lines up.
until no End at the next matching line, inclusive.
while no Keep extending while the next line matches.
max_lines no Lines from the anchor down, at most; required with `until` and `while`. 1-500.
condense no The lines that matter most. Only when the evidence is over budget, the window's other lines are cut first, each cut marked; under budget it goes in whole.

Templates

A template is the line as it looks in the log. ci-doctor turns it into a regex when it loads the matcher. The same pattern, written both ways:

define:
  FILE: '[\w./-]+\.py'
  LINE: '\d+'
  RULE: '[A-Z]+[0-9]+'

regex:    '%{FILE}:%{LINE}:%{LINE}: %{RULE} '
template: '$FILE:$LINE:$LINE: $RULE '

The placeholders belong to the matcher, not to ci-doctor: what $FILE means is the file's own define, so a change to it is a change to that matcher, proven by its fixtures.

Relations and windows

The match inside a relation, inside inside, and inside a window's from, until, while and condense may only use regex, template, all, any and not. That keeps every evaluation linear.

# PHPStan's footer, kept away from Maven's [ERROR] lines by PHPStan's own table above it
match:
  all:
    - template: ' [ERROR] Found ... error'
    - preceded_by: { regex: '^ -+ +-+', within: 300 }

# A JVM exception and its Caused by: chain, which has no closing line
match: { regex: '^Exception in thread ' }
window:
  while: { regex: '^\s+at |^\s+\.\.\. \d+ more|^Caused by: ' }
  max_lines: 150
ConstructHolds, or keeps
preceded_byA matching line is among the within lines above. The line itself doesn't count.
followed_byA matching line is among the within lines below.
insideThe line is in a block that opens on start and closes on the first end after it, or after max_lines. Both ends count, and blocks don't nest.
fromThe window starts at the nearest matching line at most within lines up, or at the anchor.
untilThe window ends at the next matching line, inclusive, or after max_lines. An anchor inside an open window starts nothing new.
whileThe window extends while the next line matches, up to max_lines.
condenseOnly when the evidence is over budget: the window keeps its anchor and the matching lines, and each run of other lines becomes one elision marker. Under budget the window goes in whole, so a line condense doesn't match can still reach the model. A line another window keeps whole is never cut.

Limits

WhatLimit
Outputs per matcher20
Variants per output10
Nodes in one match32
Nesting depth4
within, max_lines1–500
define entries20
A regex, after expanding defines500 characters and 1,000 RE2 instructions
A matchmust not hold on an empty line
tags1–5
descriptionOne line of 20–250 printable ASCII characters

RE2 has no lookaround (use not), no backreferences, uses \z not \Z, and its \d \s \w \b are ASCII-only. An error names its place in the file, for example ruff › outputs.check › variants.full › match.all[1].followed_by: FILE is not defined.

Versions

A released schema version never changes how it compiles: a change is a new version, and every ci-doctor compiles every version it knows. A file with no schema is refused.