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.
| Key | Required | Its 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>.
| Key | Required | Its 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.
| Key | Required | Its 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.
| Key | Its 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.
| Key | Required | Its job |
|---|---|---|
within |
yes | How many lines to look, 1-500. |
In inside
| Key | Required | Its 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.
| Key | Required | Its 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 '
- Everything except a placeholder and
...is literal, so.,(,[and|need no escaping. $NAME(uppercase) inserts thatdefineentry, and%{NAME}does the same in a regex. An undefined name is a load error....matches anything on the same line, and$$writes a$.- Like a regex, a template matches anywhere in the line.
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
| Construct | Holds, or keeps |
|---|---|
preceded_by | A matching line is among the within lines above. The line itself doesn't count. |
followed_by | A matching line is among the within lines below. |
inside | The 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. |
from | The window starts at the nearest matching line at most within lines up, or at the anchor. |
until | The window ends at the next matching line, inclusive, or after max_lines. An anchor inside an open window starts nothing new. |
while | The window extends while the next line matches, up to max_lines. |
condense | Only 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
| What | Limit |
|---|---|
| Outputs per matcher | 20 |
| Variants per output | 10 |
Nodes in one match | 32 |
| Nesting depth | 4 |
within, max_lines | 1–500 |
define entries | 20 |
| A regex, after expanding defines | 500 characters and 1,000 RE2 instructions |
A match | must not hold on an empty line |
tags | 1–5 |
description | One 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.