{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/git-top/json-schema/git-top-quality-report-response-schema.json",
  "title": "QualityReportResponse",
  "description": "Corpus quality and trust report. release_score is the release gate; data_trust_score and risk_level describe corpus trust.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/git-top-openapi.json#/components/schemas/QualityReportResponse",
  "type": "object",
  "required": [
    "score",
    "release_score",
    "data_trust_score",
    "risk_level",
    "risk_summary",
    "coverage",
    "metadata"
  ],
  "properties": {
    "score": {
      "type": "number"
    },
    "release_score": {
      "type": "number"
    },
    "data_trust_score": {
      "type": "number"
    },
    "score_summary": {
      "type": "object",
      "properties": {
        "release_score_meaning": {
          "type": "string"
        },
        "data_trust_score_meaning": {
          "type": "string"
        },
        "risk_level_meaning": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "risk_level": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high"
      ]
    },
    "risk_summary": {
      "type": "object",
      "properties": {
        "level": {
          "type": "string",
          "enum": [
            "low",
            "medium",
            "high"
          ]
        },
        "reasons": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "low_confidence_classification_rate": {
          "type": "number"
        },
        "collection_review_rate": {
          "type": "number"
        },
        "stale_project_rate": {
          "type": "number"
        },
        "stale_collection_rate": {
          "type": "number"
        }
      },
      "additionalProperties": true
    },
    "improvement_plan": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "project_count": {
      "type": "integer"
    },
    "issue_count": {
      "type": "integer"
    },
    "error_count": {
      "type": "integer"
    },
    "warning_count": {
      "type": "integer"
    },
    "category_distribution": {
      "type": "object",
      "additionalProperties": {
        "type": "integer"
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": true
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "metadata": {
      "$ref": "#/$defs/Metadata"
    }
  },
  "additionalProperties": true,
  "$defs": {
    "Metadata": {
      "type": "object",
      "description": "Common provenance envelope for agent-facing responses. Agents should require source=d1 for high-confidence production claims and disclose seed fallback.",
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "d1",
            "seed"
          ]
        },
        "reason": {
          "type": "string"
        },
        "project_count": {
          "type": "integer"
        },
        "generated_at": {
          "type": "string",
          "format": "date-time"
        },
        "snapshot_id": {
          "type": "string",
          "description": "Stable identity for the corpus snapshot used by this response."
        },
        "latest_synced_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "schema_version": {
          "type": "string",
          "enum": [
            "git-top.knowledge.v1"
          ]
        },
        "loaded_project_limit": {
          "type": "integer",
          "description": "Maximum D1 knowledge or search-candidate rows loaded into the bounded ranking set when present."
        },
        "truncated": {
          "type": "boolean",
          "description": "Whether the D1-backed ranking or candidate set reached its limit and may omit additional matching rows."
        },
        "candidate_retrieval": {
          "type": "string",
          "enum": [
            "d1_first"
          ],
          "description": "Search-only marker indicating that deterministic filters and broad query matching ran in D1 before TypeScript ranking."
        },
        "candidate_count": {
          "type": "integer",
          "description": "Number of D1 search candidates passed to the authoritative TypeScript filter and ranking stage."
        },
        "candidate_limit": {
          "type": "integer",
          "description": "Maximum number of D1 search candidates passed to the ranking stage."
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Fallback, count, freshness, or trust caveats that agents should account for before citing results."
        }
      }
    }
  }
}