{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/zemlyansky/archbird/raw/main/schema/archbird.schema.json",
  "title": "Archbird project configuration",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "project": {"type": "string", "minLength": 1},
    "description": {"type": "string"},
    "exclude": {"$ref": "#/$defs/strings"},
    "discovery": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "default_excludes": {"type": "boolean", "default": true}
      }
    },
    "layers": {
      "type": "array",
      "minItems": 1,
      "items": {"$ref": "#/$defs/layer"}
    },
    "packages": {
      "type": "array",
      "items": {"$ref": "#/$defs/package"}
    },
    "builds": {
      "type": "array",
      "items": {"$ref": "#/$defs/build"}
    },
    "indexes": {
      "type": "array",
      "items": {"$ref": "#/$defs/index"}
    },
    "artifacts": {
      "type": "array",
      "items": {"$ref": "#/$defs/artifact"}
    },
    "bridges": {
      "type": "array",
      "items": {"$ref": "#/$defs/bridge"}
    },
    "tests": {
      "type": "array",
      "items": {"$ref": "#/$defs/test"}
    },
    "components": {
      "type": "array",
      "items": {"$ref": "#/$defs/component"}
    },
    "named_entries": {
      "type": "array",
      "items": {"$ref": "#/$defs/named_entry"}
    },
    "parity": {
      "type": "array",
      "items": {"$ref": "#/$defs/parity"}
    },
    "limits": {"$ref": "#/$defs/limits"},
    "projections": {"$ref": "#/$defs/projection_collection"},
    "queries": {"$ref": "#/$defs/query_collection"},
    "constraints": {"$ref": "#/$defs/constraint_collection"},
    "gates": {"$ref": "#/$defs/gate_collection"}
  },
  "$defs": {
    "stable_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
    },
    "gate": {
      "type": "object",
      "additionalProperties": false,
      "required": ["argv", "timeout_seconds"],
      "properties": {
        "id": {"$ref": "#/$defs/stable_id"},
        "argv": {
          "type": "array",
          "minItems": 1,
          "maxItems": 64,
          "items": {"type": "string", "minLength": 1, "maxLength": 4096}
        },
        "cwd": {
          "type": "string",
          "minLength": 1,
          "maxLength": 4096,
          "pattern": "^(?:\\.|(?!/)(?![A-Za-z]:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\u0000]+)$"
        },
        "depends_on": {
          "type": "array",
          "maxItems": 4096,
          "uniqueItems": true,
          "items": {"$ref": "#/$defs/stable_id"}
        },
        "timeout_seconds": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3600
        },
        "max_output_bytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 16777216,
          "default": 1048576
        }
      }
    },
    "gate_collection": {
      "oneOf": [
        {
          "type": "object",
          "propertyNames": {"$ref": "#/$defs/stable_id"},
          "additionalProperties": {
            "allOf": [
              {"$ref": "#/$defs/gate"},
              {"not": {"required": ["id"]}}
            ]
          }
        },
        {
          "type": "array",
          "items": {
            "allOf": [
              {"$ref": "#/$defs/gate"},
              {"required": ["id"]}
            ]
          }
        }
      ]
    },
    "projection_base": {
      "type": "object",
      "required": ["select"],
      "properties": {
        "id": {"$ref": "#/$defs/stable_id"},
        "select": {"type": "string"}
      }
    },
    "projection_normalization": {
      "properties": {
        "include": {"$ref": "#/$defs/collection_patterns"},
        "exclude": {"$ref": "#/$defs/collection_patterns"},
        "strip_prefix": {"type": "string"},
        "strip_suffix": {"type": "string"}
      }
    },
    "projection": {
      "oneOf": [
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "artifact_routes"}, "artifacts": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "build_routes"}, "builds": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "component_edges"}, "kinds": {"$ref": "#/$defs/strings"}, "kind_patterns": {"$ref": "#/$defs/strings"}, "name_patterns": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"properties": {"select": {"const": "component_membership"}, "components": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "components"}, "names": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"required": ["container"], "properties": {"select": {"const": "constant_memberships"}, "container": {"type": "string", "minLength": 1}, "paths": {"$ref": "#/$defs/collection_patterns"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"required": ["container"], "properties": {"select": {"const": "constant_values"}, "container": {"type": "string", "minLength": 1}, "paths": {"$ref": "#/$defs/collection_patterns"}, "kinds": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "file_edges"}, "from_paths": {"$ref": "#/$defs/collection_patterns"}, "to_paths": {"$ref": "#/$defs/collection_patterns"}, "kinds": {"$ref": "#/$defs/strings"}, "kind_patterns": {"$ref": "#/$defs/strings"}, "name_patterns": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"required": ["metric"], "properties": {"select": {"const": "file_metrics"}, "metric": {"const": "bytes"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"required": ["level"], "properties": {
              "select": {"const": "graph"},
              "group_by": {"enum": ["component", "directory", "language", "layer"]},
              "level": {"enum": ["component", "file", "symbol"]},
              "relations": {"type": "array", "uniqueItems": true, "items": {"enum": ["builds", "bridges", "calls", "declarations", "imports", "packages", "references", "tests"]}},
              "overlays": {"type": "array", "uniqueItems": true, "items": {"enum": ["diagnostics", "evidence-quality"]}}
            }},
            {
              "if": {"properties": {"level": {"const": "component"}}, "required": ["level"]},
              "then": {"not": {"required": ["group_by"]}}
            },
            {
              "if": {"properties": {"level": {"const": "symbol"}}, "required": ["level"]},
              "then": {"properties": {"relations": {"items": {"enum": ["calls", "references"]}}}}
            }
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"properties": {"select": {"const": "inventory_paths"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"required": ["call", "selector"], "properties": {"select": {"const": "macro_members"}, "call": {"type": "string", "minLength": 1}, "selector": {"type": "string", "minLength": 1}, "paths": {"$ref": "#/$defs/collection_patterns"}, "selector_argument": {"type": "integer", "minimum": 0, "maximum": 31}, "values_from_argument": {"type": "integer", "minimum": 0, "maximum": 31}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"properties": {"select": {"const": "mapped_paths"}, "paths": {"$ref": "#/$defs/collection_patterns"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "package_entrypoints"}, "packages": {"$ref": "#/$defs/strings"}, "routes": {"$ref": "#/$defs/strings"}, "target_paths": {"$ref": "#/$defs/collection_patterns"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "package_exports"}, "packages": {"$ref": "#/$defs/strings"}, "name_patterns": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"required": ["name"], "properties": {"select": {"const": "provider_surface"}, "name": {"type": "string", "minLength": 1}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "search_domain"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"properties": {"select": {"const": "symbols"}, "paths": {"$ref": "#/$defs/collection_patterns"}, "kinds": {"$ref": "#/$defs/strings"}, "names": {"$ref": "#/$defs/strings"}, "name_patterns": {"$ref": "#/$defs/strings"}, "layer": {"type": "string", "minLength": 1}, "public_only": {"type": "boolean"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "symbol_entities"}, "paths": {"$ref": "#/$defs/collection_patterns"}, "kinds": {"$ref": "#/$defs/strings"}, "names": {"$ref": "#/$defs/strings"}, "name_patterns": {"$ref": "#/$defs/strings"}, "layer": {"type": "string", "minLength": 1}, "public_only": {"type": "boolean"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {
              "required": ["names"],
              "properties": {
                "select": {"const": "symbol_occurrences"},
                "names": {
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 1,
                  "uniqueItems": true,
                  "items": {"type": "string", "minLength": 1}
                },
                "paths": {"$ref": "#/$defs/collection_patterns"}
              }
            }
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "symbol_relations"}, "from_paths": {"$ref": "#/$defs/collection_patterns"}, "to_paths": {"$ref": "#/$defs/collection_patterns"}, "kinds": {"type": "array", "uniqueItems": true, "items": {"enum": ["calls", "references"]}}, "resolutions": {"type": "array", "uniqueItems": true, "items": {"enum": ["ambiguous", "builtin", "candidate", "unique", "unresolved"]}}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"properties": {"select": {"const": "test_routes"}, "group": {"type": "string", "minLength": 1}, "paths": {"$ref": "#/$defs/collection_patterns"}, "selectors": {"$ref": "#/$defs/strings"}, "target_paths": {"$ref": "#/$defs/collection_patterns"}, "configured_only": {"type": "boolean"}}}
          ],
          "unevaluatedProperties": false
        },
        {
          "type": "object",
          "allOf": [
            {"$ref": "#/$defs/projection_base"},
            {"$ref": "#/$defs/projection_normalization"},
            {"properties": {"select": {"const": "test_selectors"}, "group": {"type": "string", "minLength": 1}, "paths": {"$ref": "#/$defs/collection_patterns"}, "selectors": {"$ref": "#/$defs/strings"}}}
          ],
          "unevaluatedProperties": false
        }
      ]
    },
    "projection_collection": {
      "oneOf": [
        {"type": "object", "propertyNames": {"$ref": "#/$defs/stable_id"}, "additionalProperties": {"allOf": [{"$ref": "#/$defs/projection"}, {"not": {"required": ["id"]}}]}},
        {"type": "array", "items": {"allOf": [{"$ref": "#/$defs/projection"}, {"required": ["id"]}]}}
      ]
    },
    "projection_reference": {
      "oneOf": [
        {"$ref": "#/$defs/stable_id"},
        {"$ref": "#/$defs/projection"}
      ]
    },
    "query_context_counts": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "files": {"type": "integer", "minimum": 0},
        "symbol_calls": {"type": "integer", "minimum": 0},
        "symbol_references": {"type": "integer", "minimum": 0},
        "test_matches": {"type": "integer", "minimum": 0}
      }
    },
    "query_context": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "profile": {"enum": ["exact", "change", "architecture", "audit"]},
        "provenance": {"type": "array", "items": {"enum": ["derived", "asserted", "observed"]}},
        "confidence": {"type": "array", "items": {"enum": ["exact", "candidate", "conservative", "unresolved"]}},
        "max_seed_distance": {"type": "integer", "minimum": 0},
        "candidate": {"enum": ["collapse", "expand", "exclude"]},
        "conservative": {"enum": ["collapse", "expand", "exclude"]},
        "quotas": {"$ref": "#/$defs/query_context_counts"},
        "offsets": {"$ref": "#/$defs/query_context_counts"}
      }
    },
    "query": {
      "type": "object",
      "properties": {
        "id": {"$ref": "#/$defs/stable_id"},
        "description": {"type": "string"},
        "projection": {
          "oneOf": [
            {"$ref": "#/$defs/projection_reference"},
            {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/projection_reference"}}
          ]
        },
        "focus": {"$ref": "#/$defs/strings"},
        "paths": {"$ref": "#/$defs/collection_patterns"},
        "symbols": {"$ref": "#/$defs/strings"},
        "components": {"$ref": "#/$defs/strings"},
        "packages": {"$ref": "#/$defs/strings"},
        "artifacts": {"$ref": "#/$defs/strings"},
        "search": {"$ref": "#/$defs/strings"},
        "search_limit": {"type": "integer", "minimum": 1, "maximum": 100},
        "direction": {"enum": ["upstream", "downstream", "both"]},
        "depth": {"type": "integer", "minimum": 0},
        "test_depth": {"type": "integer", "minimum": 0},
        "context": {"$ref": "#/$defs/query_context"}
      },
      "anyOf": [
        {"required": ["projection"]},
        {"required": ["focus"], "properties": {"focus": {"minItems": 1}}},
        {"required": ["paths"], "properties": {"paths": {"minItems": 1}}},
        {"required": ["symbols"], "properties": {"symbols": {"minItems": 1}}},
        {"required": ["components"], "properties": {"components": {"minItems": 1}}},
        {"required": ["packages"], "properties": {"packages": {"minItems": 1}}},
        {"required": ["artifacts"], "properties": {"artifacts": {"minItems": 1}}},
        {"required": ["search"], "properties": {"search": {"minItems": 1}}}
      ],
      "additionalProperties": false
    },
    "query_collection": {
      "oneOf": [
        {"type": "object", "propertyNames": {"$ref": "#/$defs/stable_id"}, "additionalProperties": {"allOf": [{"$ref": "#/$defs/query"}, {"not": {"required": ["id"]}}]}},
        {"type": "array", "items": {"allOf": [{"$ref": "#/$defs/query"}, {"required": ["id"]}]}}
      ]
    },
    "constraint_operand": {
      "oneOf": [
        {"type": "object", "required": ["projection"], "properties": {"projection": {"$ref": "#/$defs/projection_reference"}, "map": {"$ref": "#/$defs/stable_id"}, "source_lock": {"type": "object", "minProperties": 1, "propertyNames": {"pattern": "^(?!/)(?!.*//)(?!.*(?:^|/)\\.\\.?(?:/|$))[^\\\\]*(?:[^/\\\\])$"}, "additionalProperties": {"type": "string", "pattern": "^[0-9a-f]{64}$"}}}, "additionalProperties": false},
        {"type": "object", "required": ["literal"], "properties": {"literal": {"oneOf": [{"type": "array"}, {"type": "object"}]}}, "additionalProperties": false},
        {"type": "object", "required": ["observation"], "properties": {"observation": {"$ref": "#/$defs/stable_id"}}, "additionalProperties": false}
      ]
    },
    "constraint_waiver": {
      "type": "object",
      "required": ["id", "owner", "rationale"],
      "properties": {
        "id": {"$ref": "#/$defs/stable_id"},
        "fingerprint": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
        "comparison": {"$ref": "#/$defs/stable_id"},
        "key": {"type": "string"},
        "owner": {"type": "string", "minLength": 1},
        "rationale": {"type": "string", "minLength": 1},
        "expires_on": {"type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"},
        "until_inputs": {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {"$ref": "#/$defs/stable_id"},
          "additionalProperties": {"type": "string", "pattern": "^[0-9a-f]{64}$"}
        }
      },
      "oneOf": [
        {"required": ["fingerprint"], "not": {"anyOf": [{"required": ["comparison"]}, {"required": ["key"]}]}},
        {"required": ["comparison", "key"], "not": {"required": ["fingerprint"]}}
      ],
      "anyOf": [
        {"required": ["expires_on"]},
        {"required": ["until_inputs"]}
      ],
      "additionalProperties": false
    },
    "constraint": {
      "type": "object",
      "required": ["owner", "rationale"],
      "properties": {
        "id": {"$ref": "#/$defs/stable_id"},
        "kind": {"enum": ["allowed_component_edges", "allowed_file_edges", "component_cycles", "component_membership", "forbidden_component_edges", "forbidden_file_edges", "forbidden_paths", "forbidden_symbols", "max_file_bytes", "provider_surface", "required_bridge", "required_component_edges", "required_file_edge", "required_file_edges", "required_package_entrypoint", "required_paths", "required_symbols", "required_test_route", "symbol_cardinality", "test_routes"]},
        "assert": {"enum": ["acyclic", "allowed_edges", "cardinality", "disjoint", "forbidden_edges", "mapped_set_equal", "mapped_values_equal", "min_test_routes", "numeric_bounds", "observations_equal", "required_edges", "required_subset", "required_values", "set_equal", "subset", "values_equal"]},
        "actual": {"$ref": "#/$defs/constraint_operand"},
        "expected": {"$ref": "#/$defs/constraint_operand"},
        "owner": {"type": "string", "minLength": 1},
        "rationale": {"type": "string", "minLength": 1},
        "requirement": {"oneOf": [{"type": "string", "minLength": 1}, {"$ref": "#/$defs/strings"}]},
        "severity": {"enum": ["error", "warning", "note"]},
        "tags": {"$ref": "#/$defs/strings"},
        "min": {"type": "integer", "minimum": 0},
        "max": {"type": "integer", "minimum": 0},
        "exact": {"type": "integer", "minimum": 0},
        "allow_empty": {"type": "boolean"},
        "include": {"$ref": "#/$defs/collection_patterns"},
        "exclude": {"$ref": "#/$defs/collection_patterns"},
        "paths": {"$ref": "#/$defs/collection_patterns"},
        "symbols": {"$ref": "#/$defs/strings"},
        "from_paths": {"$ref": "#/$defs/collection_patterns"},
        "to_paths": {"$ref": "#/$defs/collection_patterns"},
        "kinds": {"$ref": "#/$defs/strings"},
        "kind_patterns": {"$ref": "#/$defs/strings"},
        "name_patterns": {"$ref": "#/$defs/strings"},
        "target_paths": {"$ref": "#/$defs/collection_patterns"},
        "selectors": {"$ref": "#/$defs/strings"},
        "layer": {"type": "string", "minLength": 1},
        "group": {"type": "string", "minLength": 1},
        "public_only": {"type": "boolean"},
        "configured_only": {"type": "boolean"},
        "strip_prefix": {"type": "string"},
        "strip_suffix": {"type": "string"},
        "edges": {"type": "array", "items": {"$ref": "#/$defs/relation_row"}},
        "values": {},
        "required_routes": {"$ref": "#/$defs/strings"},
        "reference_route": {"type": "string", "minLength": 1},
        "mapping": {"type": "object"},
        "edge_kind": {"type": "string", "minLength": 1},
        "source": {"type": "string", "minLength": 1},
        "target": {"type": "string", "minLength": 1},
        "name": {"type": "string", "minLength": 1},
        "bridge": {"type": "string", "minLength": 1},
        "package": {"type": "string", "minLength": 1},
        "route": {"type": "string", "minLength": 1},
        "surface": {"type": "string", "minLength": 1},
        "declared": {"$ref": "#/$defs/strings"},
        "forbid_unregistered": {"type": "boolean"},
        "forbid_unresolved": {"type": "boolean"},
        "forbid_ambiguous": {"type": "boolean"},
        "require_all_providers": {"type": "boolean"},
        "waivers": {
          "type": "array",
          "minItems": 1,
          "items": {"$ref": "#/$defs/constraint_waiver"}
        }
      },
      "oneOf": [
        {"required": ["kind"], "not": {"required": ["assert"]}},
        {"required": ["assert"], "not": {"required": ["kind"]}}
      ],
      "allOf": [
        {
          "if": {"properties": {"kind": {"const": "component_membership"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "allow_empty", "exact", "exclude", "include", "max", "min", "strip_prefix", "strip_suffix"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "component_cycles"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "kinds"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "max_file_bytes"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "allow_empty", "exclude", "include", "max", "strip_prefix", "strip_suffix"]}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["required_paths", "forbidden_paths"]}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "exclude", "include", "paths", "strip_prefix", "strip_suffix"]}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["required_symbols", "forbidden_symbols"]}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "exclude", "include", "kinds", "layer", "paths", "public_only", "strip_prefix", "strip_suffix", "symbols"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "symbol_cardinality"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "exact", "exclude", "include", "kinds", "layer", "max", "min", "paths", "public_only", "strip_prefix", "strip_suffix"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "test_routes"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "configured_only", "group", "min", "required_routes", "selectors", "target_paths"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "required_file_edge"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "edge_kind", "name", "source", "target"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "required_bridge"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "bridge"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "required_package_entrypoint"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "package", "route", "target"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "required_test_route"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "configured_only", "group", "selectors", "target"]}}
        },
        {
          "if": {"properties": {"kind": {"const": "provider_surface"}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "declared", "exclude", "forbid_ambiguous", "forbid_unregistered", "forbid_unresolved", "include", "require_all_providers", "strip_prefix", "strip_suffix", "surface"]}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["allowed_component_edges", "forbidden_component_edges", "required_component_edges"]}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "edges", "kinds"]}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["allowed_file_edges", "forbidden_file_edges", "required_file_edges"]}}, "required": ["kind"]},
          "then": {"propertyNames": {"enum": ["id", "kind", "owner", "rationale", "requirement", "severity", "tags", "waivers", "edges", "from_paths", "kind_patterns", "kinds", "name_patterns", "to_paths"]}}
        },
        {
          "if": {"properties": {"assert": {"const": "acyclic"}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual"]}}
        },
        {
          "if": {"properties": {"assert": {"enum": ["allowed_edges", "disjoint", "forbidden_edges", "required_edges"]}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "expected"]}}
        },
        {
          "if": {"properties": {"assert": {"const": "cardinality"}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "exact", "max", "min"]}}
        },
        {
          "if": {"properties": {"assert": {"enum": ["mapped_set_equal", "mapped_values_equal", "required_subset", "required_values", "set_equal", "subset", "values_equal"]}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "expected", "mapping"]}}
        },
        {
          "if": {"properties": {"assert": {"const": "min_test_routes"}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "min", "required_routes"]}}
        },
        {
          "if": {"properties": {"assert": {"const": "numeric_bounds"}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "allow_empty", "exact", "max", "min"]}}
        },
        {
          "if": {"properties": {"assert": {"const": "observations_equal"}}, "required": ["assert"]},
          "then": {"propertyNames": {"enum": ["id", "assert", "owner", "rationale", "requirement", "severity", "tags", "waivers", "actual", "expected", "reference_route", "required_routes"]}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["required_paths", "forbidden_paths"]}}, "required": ["kind"]},
          "then": {"required": ["paths"], "properties": {"paths": {"minItems": 1}}}
        },
        {
          "if": {"properties": {"kind": {"enum": ["required_symbols", "forbidden_symbols"]}}, "required": ["kind"]},
          "then": {"required": ["symbols"], "properties": {"symbols": {"minItems": 1}}}
        },
        {
          "if": {"properties": {"kind": {"const": "max_file_bytes"}}, "required": ["kind"]},
          "then": {"required": ["max"]}
        },
        {
          "if": {"properties": {"kind": {"const": "symbol_cardinality"}}, "required": ["kind"]},
          "then": {"anyOf": [{"required": ["min"]}, {"required": ["max"]}, {"required": ["exact"]}]}
        },
        {
          "if": {"properties": {"kind": {"const": "required_file_edge"}}, "required": ["kind"]},
          "then": {"required": ["edge_kind", "source", "target"]}
        },
        {
          "if": {"properties": {"kind": {"const": "required_bridge"}}, "required": ["kind"]},
          "then": {"required": ["bridge"]}
        },
        {
          "if": {"properties": {"kind": {"const": "required_package_entrypoint"}}, "required": ["kind"]},
          "then": {"required": ["package", "route"]}
        },
        {
          "if": {"properties": {"kind": {"const": "required_test_route"}}, "required": ["kind"]},
          "then": {"required": ["group", "target"]}
        },
        {
          "if": {"properties": {"kind": {"const": "provider_surface"}}, "required": ["kind"]},
          "then": {"required": ["surface"]}
        },
        {
          "if": {"properties": {"kind": {"enum": ["allowed_component_edges", "forbidden_component_edges", "required_component_edges", "allowed_file_edges", "forbidden_file_edges", "required_file_edges"]}}, "required": ["kind"]},
          "then": {"required": ["edges"]}
        },
        {
          "if": {"required": ["assert"]},
          "then": {"required": ["actual"]}
        },
        {
          "if": {"properties": {"assert": {"enum": ["cardinality", "numeric_bounds"]}}, "required": ["assert"]},
          "then": {"anyOf": [{"required": ["min"]}, {"required": ["max"]}, {"required": ["exact"]}]}
        },
        {
          "if": {"properties": {"assert": {"not": {"enum": ["acyclic", "cardinality", "min_test_routes", "numeric_bounds"]}}}, "required": ["assert"]},
          "then": {"required": ["expected"]}
        },
        {
          "if": {"properties": {"assert": {"const": "observations_equal"}}, "required": ["assert"]},
          "then": {
            "required": ["expected"],
            "properties": {
              "actual": {"type": "object", "required": ["observation"]},
              "expected": {"type": "object", "required": ["observation"]}
            }
          }
        },
        {
          "if": {"required": ["exact"]},
          "then": {"not": {"anyOf": [{"required": ["min"]}, {"required": ["max"]}]}}
        }
      ],
      "additionalProperties": false
    },
    "constraint_collection": {
      "oneOf": [
        {"type": "object", "propertyNames": {"$ref": "#/$defs/stable_id"}, "additionalProperties": {"allOf": [{"$ref": "#/$defs/constraint"}, {"not": {"required": ["id"]}}]}},
        {"type": "array", "items": {"allOf": [{"$ref": "#/$defs/constraint"}, {"required": ["id"]}]}}
      ]
    },
    "relation_row": {
      "type": "object",
      "properties": {
        "source": {"type": "string", "minLength": 1},
        "target": {"type": "string", "minLength": 1},
        "from": {"type": "string", "minLength": 1},
        "to": {"type": "string", "minLength": 1},
        "kind": {"type": "string"},
        "name": {"type": "string"}
      },
      "anyOf": [{"required": ["source", "target"]}, {"required": ["from", "to"]}],
      "additionalProperties": false
    },
    "strings": {
      "type": "array",
      "items": {"type": "string", "minLength": 1}
    },
    "collection_patterns": {
      "type": "array",
      "items": {"type": "string", "minLength": 1},
      "description": "Repository-relative segment-aware collection patterns: *, ?, and [] stay within one path segment; ** as a complete segment matches zero or more segments."
    },
    "collection_selector": {
      "oneOf": [
        {"type": "string", "minLength": 1},
        {"$ref": "#/$defs/collection_patterns"}
      ],
      "description": "One or more repository-relative segment-aware collection patterns."
    },
    "layer_names": {
      "oneOf": [
        {"type": "string", "minLength": 1},
        {"$ref": "#/$defs/strings"}
      ]
    },
    "layer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "language", "globs"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "role": {"type": "string", "minLength": 1, "default": "source"},
        "language": {
          "enum": ["c", "cpp", "python", "javascript", "typescript", "r", "vue", "text"]
        },
        "globs": {"$ref": "#/$defs/collection_patterns"},
        "public_headers": {"$ref": "#/$defs/strings"},
        "import_roots": {"$ref": "#/$defs/strings"},
        "external_call_namespaces": {
          "type": "array",
          "items": {"$ref": "#/$defs/external_call_namespace"}
        },
        "required": {"type": "boolean", "default": true}
      }
    },
    "external_call_namespace": {
      "type": "object",
      "additionalProperties": false,
      "required": ["prefix", "package"],
      "properties": {
        "prefix": {"type": "string", "minLength": 1},
        "package": {"type": "string", "minLength": 1}
      }
    },
    "package": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "kind", "path", "layer"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "kind": {"enum": ["npm", "python", "r", "generic"]},
        "path": {"type": "string", "minLength": 1},
        "layer": {"type": "string", "minLength": 1},
        "entries": {"$ref": "#/$defs/strings"},
        "identity": {"type": "string"},
        "version": {"type": "string"},
        "aliases": {"$ref": "#/$defs/strings"}
      }
    },
    "build": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "kind", "path"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "kind": {"enum": ["autoconf", "compile_commands", "make", "npm"]},
        "path": {"type": "string", "minLength": 1},
        "variant": {"type": "string"}
      }
    },
    "index": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "format", "path"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "format": {"const": "scip"},
        "path": {"type": "string", "minLength": 1},
        "path_prefix": {"type": "string", "minLength": 1},
        "position_encoding_fallback": {
          "enum": ["utf8", "utf16", "utf32"]
        },
        "variant": {"type": "string"},
        "required": {"type": "boolean", "default": true}
      }
    },
    "artifact": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "output"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "output": {"type": "string", "minLength": 1},
        "inputs": {"$ref": "#/$defs/collection_patterns"},
        "loaded_by": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["paths", "pattern"],
            "properties": {
              "paths": {"$ref": "#/$defs/collection_patterns"},
              "pattern": {"type": "string", "minLength": 1},
              "required": {"type": "boolean", "default": true}
            }
          }
        },
        "builds": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["source", "target"],
            "properties": {
              "source": {"type": "string", "minLength": 1},
              "target": {"type": "string", "minLength": 1}
            }
          }
        },
        "required": {"type": "boolean", "default": true}
      }
    },
    "bridge": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "kind", "from", "to"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "kind": {"enum": ["abi", "binding", "message"]},
        "from": {"$ref": "#/$defs/layer_names"},
        "from_paths": {"$ref": "#/$defs/collection_patterns"},
        "exclude_from_paths": {"$ref": "#/$defs/collection_patterns"},
        "to": {"$ref": "#/$defs/layer_names"},
        "prefixes": {"$ref": "#/$defs/strings"},
        "bidirectional": {"type": "boolean", "default": false},
        "message_keys": {"$ref": "#/$defs/strings"},
        "ignore": {"$ref": "#/$defs/strings"},
        "providers": {
          "type": "array",
          "items": {"$ref": "#/$defs/provider"}
        }
      }
    },
    "provider": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind"],
          "properties": {
            "kind": {"const": "exports"},
            "path": {"type": "string", "minLength": 1}
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "path", "variable", "pattern"],
          "properties": {
            "kind": {"const": "make_variable"},
            "path": {"type": "string", "minLength": 1},
            "variable": {"type": "string", "minLength": 1},
            "pattern": {"type": "string", "minLength": 1}
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "path", "pattern"],
          "properties": {
            "kind": {"const": "file_pattern"},
            "path": {"type": "string", "minLength": 1},
            "pattern": {"type": "string", "minLength": 1}
          }
        }
      ]
    },
    "test": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "language", "globs", "route_to"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "language": {
          "enum": ["c", "cpp", "python", "javascript", "typescript", "r", "vue", "text"]
        },
        "globs": {"$ref": "#/$defs/collection_patterns"},
        "route_to": {"$ref": "#/$defs/strings"},
        "case_extractors": {
          "type": "array",
          "items": {"$ref": "#/$defs/test_case_extractor"}
        },
        "case_routes": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["selector", "to"],
            "properties": {
              "selector": {"type": "string", "minLength": 1},
              "paths": {"$ref": "#/$defs/collection_patterns"},
              "target_symbols": {"$ref": "#/$defs/strings"},
              "to": {"$ref": "#/$defs/collection_selector"}
            }
          }
        },
        "generated_files": {
          "type": "array",
          "items": {"$ref": "#/$defs/test_generated_file"}
        },
        "required": {"type": "boolean", "default": true}
      }
    },
    "test_case_extractor": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "call", "selector_arguments"],
          "properties": {
            "kind": {"const": "c_macro"},
            "call": {"type": "string", "minLength": 1},
            "selector_arguments": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {"type": "integer", "minimum": 0, "maximum": 31}
            },
            "separator": {"type": "string", "default": "."}
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind", "name"],
          "properties": {
            "kind": {"const": "named_dispatch"},
            "name": {"type": "string", "minLength": 1},
            "selector_argument": {
              "type": "integer",
              "minimum": 0,
              "maximum": 31,
              "default": 0
            }
          }
        }
      ]
    },
    "test_generated_file": {
      "type": "object",
      "additionalProperties": false,
      "required": ["globs", "sources"],
      "properties": {
        "globs": {"$ref": "#/$defs/collection_patterns"},
        "sources": {"$ref": "#/$defs/strings"}
      }
    },
    "component": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "paths"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "paths": {"$ref": "#/$defs/collection_patterns"},
        "description": {"type": "string"},
        "required": {"type": "boolean", "default": true}
      }
    },
    "named_entry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "kind", "functions", "globs"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "kind": {"const": "call_string_arg"},
        "functions": {"$ref": "#/$defs/strings"},
        "argument": {"type": "integer", "minimum": 0, "default": 0},
        "globs": {"$ref": "#/$defs/collection_patterns"}
      }
    },
    "parity_member": {
      "type": "object",
      "additionalProperties": false,
      "required": ["label", "source"],
      "properties": {
        "label": {"type": "string", "minLength": 1},
        "source": {"enum": ["symbols", "package", "bridge"]},
        "layer": {"type": "string"},
        "package": {"type": "string"},
        "bridge": {"type": "string"},
        "include": {"$ref": "#/$defs/strings"},
        "exclude": {"$ref": "#/$defs/strings"},
        "kinds": {"$ref": "#/$defs/strings"}
      }
    },
    "parity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "members"],
      "properties": {
        "name": {"type": "string", "minLength": 1},
        "members": {
          "type": "array",
          "minItems": 2,
          "items": {"$ref": "#/$defs/parity_member"}
        },
        "case": {"enum": ["identity", "lower", "snake"], "default": "identity"},
        "strip_prefixes": {"$ref": "#/$defs/strings"},
        "strip_suffixes": {"$ref": "#/$defs/strings"},
        "aliases": {
          "type": "object",
          "additionalProperties": {"type": "string"}
        },
        "ignore": {"$ref": "#/$defs/strings"},
        "enforce": {"type": "boolean", "default": false}
      }
    },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "max_file_bytes": {"type": "integer", "minimum": 1},
        "max_index_bytes": {"type": "integer", "minimum": 1},
        "compact_symbols": {"type": "integer", "minimum": 1},
        "compact_edge_names": {"type": "integer", "minimum": 1}
      }
    }
  }
}
