{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aburi.dev/schema/aburi.config.v1.json",
  "title": "Aburi Project Config",
  "description": "aburi.json / aburi.jsonc project configuration. All fields optional; empty config is valid (autodetect handles everything).",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "enum": [
        "https://aburi.dev/schema/aburi.config.v1.json",
        "https://aburi.kage1020.com/schema/aburi.config.v1.json"
      ],
      "description": "The first value is this schema's $id, the one to write. The second is the host the schema was served from before aburi.dev; documents that name it remain valid."
    },
    "ignore": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true,
      "description": "Glob patterns added to drop-list category A (file-level skip). POSIX, workspace-root relative."
    },
    "respectGitignore": {
      "type": "boolean",
      "default": true,
      "description": "Whether to merge .gitignore patterns into drop-list category A."
    },
    "testFiles": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true,
      "default": [
        "**/*.test.*",
        "**/*.spec.*",
        "**/*.test-d.*",
        "**/*.spec-d.*",
        "**/__tests__/**",
        "**/__mocks__/**",
        "**/__fixtures__/**",
        "**/test/**",
        "**/tests/**",
        "**/e2e/**"
      ],
      "description": "Glob patterns, in the syntax of ignore, naming the files that hold test code. A pattern that does not end in * names a directory as well; one that starts with ! takes the files it names out of what the others mark. Their Symbols are scanned and kept in the dependency graph like any other, carry inTestFile in the IR, are listed apart in the diff report, and are left out of a gate scoped to non-test Symbols. Given, the list replaces the default one; [] marks no file."
    },
    "languages": {
      "type": "array",
      "items": { "$ref": "#/$defs/PluginRef" },
      "uniqueItems": true,
      "description": "Enabled language plugins (manifest names, npm package ids, or relative/absolute paths)."
    },
    "frameworks": {
      "type": "array",
      "items": { "$ref": "#/$defs/PluginRef" },
      "uniqueItems": true,
      "description": "Enabled framework plugins. Order has no semantic effect."
    },
    "effects": {
      "type": "array",
      "items": { "$ref": "#/$defs/PluginRef" },
      "uniqueItems": true,
      "description": "Enabled effect plugins. Order determines first-match-wins priority."
    },
    "pluginOptions": {
      "type": "object",
      "additionalProperties": true,
      "propertyNames": { "$ref": "#/$defs/PluginManifestName" },
      "description": "Per-plugin opaque options keyed by manifest name."
    },
    "components": {
      "type": "array",
      "items": { "$ref": "#/$defs/ComponentOverride" }
    },
    "suppress": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true,
      "description": "Identifier prefixes added to drop-list category C call drop."
    },
    "keep": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 },
      "uniqueItems": true,
      "description": "Identifier prefixes or decorator names that escape drop. Wins over suppress and plugin/core drop rules."
    },
    "frameworkHints": {
      "type": "array",
      "items": { "$ref": "#/$defs/FrameworkHint" }
    },
    "output": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "dir": {
          "type": "string",
          "minLength": 1,
          "default": ".aburi",
          "description": "Where scan and diff write their artifacts, and where explain reads the IR back from. Resolved against the working directory, as --output-dir is; --output-dir wins when both are given. May be absolute, which is why this is not a RelativePath."
        }
      }
    },
    "strict": {
      "type": "boolean",
      "default": true,
      "description": "If true, undeclared vocab emitted by plugins aborts extraction. If false, warnings are written to aburi-vocab-discovered.json in the output directory."
    },
    "maxFileSizeBytes": {
      "type": "integer",
      "minimum": 1024,
      "default": 2097152,
      "description": "Files exceeding this size are skipped during scan to protect WASM heap. Default 2 MB."
    },
    "minParsedFileRatio": {
      "type": "number",
      "exclusiveMinimum": 0,
      "maximum": 1,
      "description": "Smallest share of discovered files a scan may parse and still exit 0. Absent by default: a scan that parsed at least one file passes whatever it lost. Set it and `aburi scan` exits 3 when parsedFiles / totalFiles falls below it, counting every skip reason. A workspace that discovers nothing, or parses nothing, exits 3 with or without this key."
    },
    "parseTimeoutMs": {
      "type": "integer",
      "minimum": 100,
      "default": 5000,
      "description": "Per-file parse timeout (parse + extract + walk combined). Files exceeding this are aborted and recorded as skipped. Default 5000 ms."
    },
    "classifyTimeoutMs": {
      "type": "integer",
      "minimum": 10,
      "maximum": 5000,
      "default": 50,
      "description": "Per-call budget for effect plugin classify(). A call that overruns it keeps its classification and is recorded in stats.effectClassifyTimeouts[]. Default 50 ms; raise to 200-500 for SQL/regex-heavy effect plugins."
    },
    "lsp": {
      "type": "object",
      "additionalProperties": false,
      "description": "Optional LSP enrichment. Opt-in per-language; default off. Refines SourceRange columns, this./super./interface call resolution, Signature.inferredThrows, and CallEdge.confidence.",
      "properties": {
        "enabled": {
          "type": "boolean",
          "default": false,
          "description": "Master switch. When false the enrichment pass is a total no-op regardless of servers."
        },
        "servers": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/LspServerConfig" },
          "propertyNames": { "$ref": "#/$defs/LspLanguageKey" },
          "description": "Per-language server config. One entry per loaded language plugin, keyed by that plugin's language id (ts for @aburi/lang-typescript, which covers .js / .jsx / .tsx too)."
        }
      }
    }
  },

  "$defs": {
    "PluginRef": {
      "type": "string",
      "minLength": 1,
      "description": "Manifest name (e.g., 'effects-prisma'), npm package id ('@scope/pkg'), or relative/absolute filesystem path ('./aburi-plugins/x.mjs', '/opt/aburi-plugins/x.mjs', 'C:/aburi-plugins/x.mjs'). A bare name resolves to '@aburi/<name>', where plugins are named with their kind as a prefix ('lang-typescript'), so a bare name of lowercase letters and digits alone ('ts') is refused when plugins load."
    },

    "PluginManifestName": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]*$"
    },

    "ComponentOverride": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "roots"],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
        },
        "name": { "type": "string", "minLength": 1 },
        "roots": {
          "type": "array",
          "items": { "$ref": "#/$defs/RelativePath" },
          "minItems": 1
        },
        "publicApi": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        },
        "languages": {
          "type": "array",
          "items": { "type": "string", "pattern": "^[a-z][a-z0-9]*$" }
        },
        "frameworks": {
          "type": "array",
          "items": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
          "description": "Framework ids ('nestjs'), as plugins provide them, not plugin names ('framework-nestjs')."
        },
        "description": { "type": ["string", "null"] }
      }
    },

    "FrameworkHint": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9-]*$",
          "description": "Identifier used as the auto-registered ad-hoc plugin name and as Component.frameworks[] value."
        },
        "decorators": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/HintRule" },
          "description": "Keyed by decorator name (e.g., 'AcmeController')."
        },
        "classNamePatterns": {
          "type": "object",
          "additionalProperties": { "$ref": "#/$defs/HintRule" },
          "description": "Keyed by class name glob pattern (e.g., '*Handler')."
        }
      }
    },

    "HintRule": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "boundary": {
          "type": "boolean",
          "description": "Override Decorator.boundary for matching decorators. Ignored for classNamePatterns."
        },
        "extKind": {
          "type": "string",
          "pattern": "^framework(:[a-z][a-z0-9.-]*){2,}$",
          "description": "Set Symbol.extKind for matching symbols. Must start with 'framework:' and have at least three segments ('framework:<vendor>:<kind>'); the loader injects 'hint' as the second segment so the resulting ownership prefix is unique per hint name. Writing 'framework:hint:*' directly is rejected at load time."
        },
        "derivedBy": {
          "type": "string",
          "minLength": 1,
          "description": "Append to Symbol.derivedBy[]."
        },
        "drop": {
          "type": "boolean",
          "description": "If true, drop matching symbol as Category B with dropReason set from name."
        }
      }
    },

    "RelativePath": {
      "type": "string",
      "minLength": 1,
      "not": { "pattern": "\\\\" }
    },

    "LspLanguageKey": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9]*$",
      "description": "The id of a loaded language plugin, exactly as Symbol ids carry it (ir-schema LanguageId): ts for @aburi/lang-typescript, which also covers .js, .jsx and .tsx. A key that names no loaded plugin is never looked up, and the scan warns about it."
    },

    "LspServerConfig": {
      "type": "object",
      "additionalProperties": false,
      "required": ["command"],
      "properties": {
        "command": {
          "type": "string",
          "minLength": 1,
          "description": "Server binary. PATH-resolvable or absolute path. Missing binaries trigger per-language fallback."
        },
        "args": {
          "type": "array",
          "items": { "type": "string" },
          "default": [],
          "description": "Arguments passed to the server binary (e.g., ['--stdio'])."
        },
        "initializeTimeoutMs": {
          "type": "integer",
          "minimum": 100,
          "default": 10000,
          "description": "Handshake timeout. Default 10 s absorbs cold-disk starts."
        },
        "requestTimeoutMs": {
          "type": "integer",
          "minimum": 50,
          "default": 500,
          "description": "Per-request timeout. Exceeding requests fall back per-request. Default 500 ms."
        },
        "fileBudgetMs": {
          "type": "integer",
          "minimum": 100,
          "default": 2000,
          "description": "Per-file budget across all requests for that file. Exceeding triggers per-file fallback. Default 2000 ms."
        },
        "concurrency": {
          "type": "integer",
          "minimum": 1,
          "default": 8,
          "description": "Max in-flight requests per file."
        },
        "initializationOptions": {
          "type": "object",
          "additionalProperties": true,
          "default": {},
          "description": "Opaque object forwarded verbatim to the server's initialize.initializationOptions. Server-specific; outside Aburi's compatibility scope."
        }
      }
    }
  }
}
