{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://spec-first.dev/contracts/quality-gates/quality-feedback-topics.schema.json",
  "title": "Quality Feedback Topics",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "source",
    "latest_gate",
    "candidate_topics"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "v1"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "source": {
      "type": "string",
      "const": "passive-quality-feedback"
    },
    "latest_gate": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "gate_id",
            "passed",
            "generated_at",
            "artifact_path"
          ],
          "properties": {
            "gate_id": {
              "type": [
                "string",
                "null"
              ]
            },
            "passed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "generated_at": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "artifact_path": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      ]
    },
    "candidate_topics": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "topic_id",
          "kind",
          "topic_key",
          "summary",
          "scope_hint",
          "artifact_paths",
          "evidence_refs",
          "tags"
        ],
        "properties": {
          "topic_id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "failed-check",
              "failed-evidence"
            ]
          },
          "topic_key": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "scope_hint": {
            "type": "string"
          },
          "artifact_paths": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_refs": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
