{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/osolmaz/yarp/blob/main/rules/schema/rule.schema.json",
"title": "YARP command pruning rule",
"oneOf": [
{ "$ref": "#/$defs/reduceRule" },
{ "$ref": "#/$defs/transformRule" },
{ "$ref": "#/$defs/passthroughRule" }
],
"$defs": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[a-z0-9](?:[a-z0-9]|[._/-](?=[a-z0-9]))*[a-z0-9]$|^[a-z0-9]$"
},
"token": {
"type": "string",
"maxLength": 1024,
"pattern": "^[^\\u0000]*$"
},
"matcher": {
"type": "object",
"additionalProperties": false,
"required": ["program"],
"properties": {
"program": {
"type": "array",
"minItems": 1,
"maxItems": 32,
"uniqueItems": true,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[^\\s/\\\\|&;<>\\(\\)`$#\\u0000]+$"
}
},
"argv_prefix": {
"type": "array",
"maxItems": 64,
"uniqueItems": true,
"items": { "$ref": "#/$defs/token" }
},
"argv_contains_all": {
"type": "array",
"maxItems": 64,
"uniqueItems": true,
"items": { "$ref": "#/$defs/token" }
}
}
},
"pattern": {
"type": "object",
"additionalProperties": false,
"required": ["kind", "value"],
"properties": {
"kind": { "enum": ["exact", "prefix", "suffix", "contains"] },
"value": {
"type": "string",
"minLength": 1,
"maxLength": 4096,
"pattern": "^[^\\u0000]+$"
},
"case": { "enum": ["sensitive", "ascii_insensitive"] },
"trim": { "enum": ["none", "start", "both"] }
}
},
"lineFilter": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": { "const": "line_filter" },
"strip_ansi": { "type": "boolean" },
"drop": {
"type": "array",
"maxItems": 256,
"uniqueItems": true,
"items": { "$ref": "#/$defs/pattern" }
},
"keep": {
"type": "array",
"maxItems": 256,
"uniqueItems": true,
"items": { "$ref": "#/$defs/pattern" }
}
}
},
"typedReducer": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": {
"enum": [
"search_summary",
"diff_summary",
"test_summary",
"build_summary",
"log_summary",
"status_summary",
"list_summary"
]
}
}
},
"reducer": {
"oneOf": [
{ "$ref": "#/$defs/lineFilter" },
{ "$ref": "#/$defs/typedReducer" }
]
},
"policy": {
"type": "object",
"additionalProperties": false,
"required": [
"max_line_bytes",
"max_output_bytes",
"min_savings_bytes",
"min_savings_basis_points"
],
"properties": {
"max_line_bytes": { "type": "integer", "minimum": 1, "maximum": 1048576 },
"max_output_bytes": { "type": "integer", "minimum": 704, "maximum": 4194304 },
"min_savings_bytes": { "type": "integer", "minimum": 0, "maximum": 1048576 },
"min_savings_basis_points": { "type": "integer", "minimum": 0, "maximum": 10000 }
}
},
"reduceRule": {
"type": "object",
"additionalProperties": false,
"required": ["id", "match", "action", "reducer", "success", "failure"],
"properties": {
"id": { "$ref": "#/$defs/id" },
"match": { "$ref": "#/$defs/matcher" },
"action": { "const": "reduce" },
"reducer": { "$ref": "#/$defs/reducer" },
"success": { "$ref": "#/$defs/policy" },
"failure": { "$ref": "#/$defs/policy" }
}
},
"transform": {
"type": "object",
"additionalProperties": false,
"required": ["kind"],
"properties": {
"kind": { "const": "line_preserving" }
}
},
"transformRule": {
"type": "object",
"additionalProperties": false,
"required": ["id", "match", "action", "transform"],
"properties": {
"id": { "$ref": "#/$defs/id" },
"match": { "$ref": "#/$defs/matcher" },
"action": { "const": "transform" },
"transform": { "$ref": "#/$defs/transform" }
}
},
"passthroughRule": {
"type": "object",
"additionalProperties": false,
"required": ["id", "match", "action"],
"properties": {
"id": { "$ref": "#/$defs/id" },
"match": { "$ref": "#/$defs/matcher" },
"action": { "const": "passthrough" }
}
}
}
}