{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "TraceJsonOutput",
  "description": "JSON shape emitted by `pathlint trace --json`. Tagged enum with the `kind` discriminator that 0.0.14 introduced (`\"found\"` or `\"not_found\"`). Schema is generated by `cargo run --bin gen_trace_schema` and shipped at `schemas/trace.schema.json`.",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "command",
        "kind"
      ],
      "properties": {
        "command": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "not_found"
          ]
        }
      }
    },
    {
      "type": "object",
      "required": [
        "command",
        "kind",
        "matched_sources",
        "resolved",
        "uninstall"
      ],
      "properties": {
        "command": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "found"
          ]
        },
        "matched_sources": {
          "description": "Sources matched against the resolved path. The most specific (longest path) source comes first; the catch-all `mise` follows after `mise_shims` / `mise_installs`.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "provenance": {
          "description": "Extra provenance hint inferred from path heuristics — e.g. \"this lives under `mise/installs/cargo-foo/...` so it's a cargo install reached *through* mise\". `None` when nothing more specific than `matched_sources` can be said.",
          "anyOf": [
            {
              "$ref": "#/definitions/Provenance"
            },
            {
              "type": "null"
            }
          ]
        },
        "resolved": {
          "type": "string"
        },
        "uninstall": {
          "description": "Best-guess uninstall hint or a reason none could be produced.",
          "allOf": [
            {
              "$ref": "#/definitions/UninstallHint"
            }
          ]
        }
      }
    }
  ],
  "definitions": {
    "Provenance": {
      "description": "Best-guess provenance derived from `[[relation]]` declarations rather than catalog `[source.<name>]` entries. Today only fires for binaries served through wrapper installers such as mise's plugin system. Computed from `Relation::ServedByVia` (matching the host source path + a `prefix-*` glob on the next path segment) using the `installer_token` as the human-facing installer name.",
      "oneOf": [
        {
          "description": "A binary served via a wrapper installer's plugin layer. `installer` is the upstream tool name (`cargo`, `npm`, ...) taken from the matched relation's `installer_token` (or `guest_provider` if absent); `plugin_segment` is the raw path segment so the user can verify with the installer's own tooling.",
          "type": "object",
          "required": [
            "installer",
            "kind",
            "plugin_segment"
          ],
          "properties": {
            "installer": {
              "type": "string"
            },
            "kind": {
              "type": "string",
              "enum": [
                "wrapper_installer"
              ]
            },
            "plugin_segment": {
              "type": "string"
            }
          }
        }
      ]
    },
    "UninstallHint": {
      "oneOf": [
        {
          "description": "A concrete shell command the user can run.",
          "type": "object",
          "required": [
            "command",
            "kind"
          ],
          "properties": {
            "command": {
              "type": "string"
            },
            "kind": {
              "type": "string",
              "enum": [
                "command"
              ]
            }
          }
        },
        {
          "description": "We matched a source but it has no `uninstall_command` template.",
          "type": "object",
          "required": [
            "kind",
            "source"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "no_template"
              ]
            },
            "source": {
              "type": "string"
            }
          }
        },
        {
          "description": "No source matched the resolved path at all.",
          "type": "object",
          "required": [
            "kind"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "no_source"
              ]
            }
          }
        }
      ]
    }
  }
}
