{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/hud-ai/json-schema/hud-ai-qa-agent-resource-result-detail-schema.json",
  "title": "QaAgentResourceResultDetail",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/hud-ai-qa-agents-api-openapi.yml#/components/schemas/QaAgentResourceResultDetail",
  "properties": {
    "result": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Result"
    },
    "canonical_result": {
      "anyOf": [
        {
          "$ref": "#/$defs/QaAgentResultV1"
        },
        {
          "type": "null"
        }
      ]
    },
    "canonical_verdict": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "passed",
            "failed",
            "unknown"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Canonical Verdict"
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "qa_agent_id": {
      "type": "string",
      "format": "uuid",
      "title": "Qa Agent Id"
    },
    "subject_type": {
      "$ref": "#/$defs/QaAgentSubjectType"
    },
    "subject_id": {
      "type": "string",
      "format": "uuid",
      "title": "Subject Id"
    },
    "agent_name": {
      "type": "string",
      "title": "Agent Name"
    },
    "status": {
      "$ref": "#/$defs/QaAgentResultStatus"
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Error"
    },
    "analysis_trace_id": {
      "type": "string",
      "format": "uuid",
      "title": "Analysis Trace Id"
    },
    "agent_config_hash": {
      "type": "string",
      "title": "Agent Config Hash"
    },
    "stale": {
      "type": "boolean",
      "title": "Stale"
    },
    "snapshot_hash": {
      "type": "string",
      "title": "Snapshot Hash"
    },
    "attempt": {
      "type": "integer",
      "title": "Attempt"
    },
    "batch_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Batch Id"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At"
    }
  },
  "type": "object",
  "required": [
    "id",
    "qa_agent_id",
    "subject_type",
    "subject_id",
    "agent_name",
    "status",
    "analysis_trace_id",
    "agent_config_hash",
    "stale",
    "snapshot_hash",
    "attempt",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "QaAgentFinding": {
      "properties": {
        "finding_type": {
          "type": "string",
          "title": "Finding Type"
        },
        "severity": {
          "type": "string",
          "enum": [
            "info",
            "warning",
            "error"
          ],
          "title": "Severity"
        },
        "summary": {
          "type": "string",
          "title": "Summary"
        },
        "confidence": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Confidence"
        },
        "evidence_refs": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Evidence Refs"
        },
        "recommended_action": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Recommended Action"
        },
        "metadata": {
          "additionalProperties": true,
          "type": "object",
          "title": "Metadata"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "finding_type",
        "severity",
        "summary"
      ],
      "title": "QaAgentFinding",
      "description": "One actionable issue identified by a QA agent."
    },
    "QaAgentResultStatus": {
      "type": "string",
      "enum": [
        "queued",
        "completed",
        "error",
        "cancelled"
      ],
      "title": "QaAgentResultStatus"
    },
    "QaAgentResultV1": {
      "properties": {
        "schema_version": {
          "type": "string",
          "const": "qa_agent_result.v1",
          "title": "Schema Version"
        },
        "verdict": {
          "type": "string",
          "enum": [
            "passed",
            "failed",
            "unknown"
          ],
          "title": "Verdict"
        },
        "findings": {
          "items": {
            "$ref": "#/$defs/QaAgentFinding"
          },
          "type": "array",
          "title": "Findings"
        },
        "summary": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Summary"
        },
        "metadata": {
          "additionalProperties": true,
          "type": "object",
          "title": "Metadata"
        },
        "execution_error": {
          "anyOf": [
            {
              "$ref": "#/$defs/QaExecutionError"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "schema_version",
        "verdict",
        "findings"
      ],
      "title": "QaAgentResultV1",
      "description": "Versioned result every QA agent must emit."
    },
    "QaAgentSubjectType": {
      "type": "string",
      "enum": [
        "trace",
        "environment",
        "taskset",
        "task"
      ],
      "title": "QaAgentSubjectType",
      "description": "Canonical resources a QA agent can analyze."
    },
    "QaExecutionError": {
      "properties": {
        "stage": {
          "type": "string",
          "maxLength": 64,
          "minLength": 1,
          "pattern": "^[a-z][a-z0-9_]*$",
          "title": "Stage"
        },
        "reason": {
          "type": "string",
          "maxLength": 1000,
          "minLength": 1,
          "title": "Reason"
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "stage",
        "reason"
      ],
      "title": "QaExecutionError",
      "description": "A step of a check that did not finish.\n\n``reason`` is shown to everyone who can read the result, so producers write it\nfrom code: no model output, raw analysis context, or credentials."
    }
  }
}