{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/auditae-app/json-schema/auditae-app-run-result-schema.json",
  "title": "RunResult",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/auditae-app-citations-api-openapi.yml#/components/schemas/RunResult",
  "type": "object",
  "required": [
    "audit_id",
    "results",
    "citation_rate",
    "completed",
    "total",
    "partial",
    "out_of_credits"
  ],
  "properties": {
    "audit_id": {
      "type": "string",
      "format": "uuid"
    },
    "results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AuditPromptResult"
      }
    },
    "citation_rate": {
      "type": "number",
      "description": "Share of answered cells that cite the brand's URL, 0–1."
    },
    "completed": {
      "type": "integer",
      "description": "Cells that finished."
    },
    "total": {
      "type": "integer",
      "description": "Cells requested (prompts × engines)."
    },
    "partial": {
      "type": "boolean",
      "description": "True when some cells didn't finish or failed."
    },
    "out_of_credits": {
      "type": "boolean",
      "description": "True when the run stopped because the balance ran out."
    },
    "charged_cents": {
      "type": [
        "integer",
        "null"
      ],
      "description": "What the run billed so far: its checks plus the fix-it playbook written in the call. null when the ledger couldn't be read."
    },
    "charged_breakdown_cents": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "checks": {
          "type": "integer"
        },
        "playbook": {
          "type": "integer"
        }
      }
    }
  },
  "$defs": {
    "AuditPromptResult": {
      "type": "object",
      "description": "One prompt × engine cell.",
      "required": [
        "engine",
        "prompt",
        "status",
        "brand_mentioned",
        "brand_url_cited",
        "position",
        "competitors",
        "sources",
        "sentiment",
        "was_cache_hit",
        "latency_ms",
        "error_message"
      ],
      "properties": {
        "engine": {
          "$ref": "#/$defs/Engine"
        },
        "prompt": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "success",
            "rate_limited",
            "timeout",
            "parse_error",
            "api_error"
          ]
        },
        "brand_mentioned": {
          "type": "boolean",
          "description": "The answer's text names the brand."
        },
        "brand_url_cited": {
          "type": "boolean",
          "description": "The brand's domain is among the answer's cited sources. Citation rate counts this."
        },
        "position": {
          "type": [
            "integer",
            "null"
          ]
        },
        "competitors": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AuditPromptSource"
          }
        },
        "sentiment": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "positive",
            "neutral",
            "negative",
            null
          ]
        },
        "was_cache_hit": {
          "type": "boolean"
        },
        "latency_ms": {
          "type": "integer"
        },
        "error_message": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "AuditPromptSource": {
      "type": "object",
      "required": [
        "url",
        "title"
      ],
      "properties": {
        "url": {
          "type": "string"
        },
        "title": {
          "type": [
            "string",
            "null"
          ]
        },
        "resolved_host": {
          "type": [
            "string",
            "null"
          ],
          "description": "Real host behind an opaque redirect URL, when recovered."
        }
      }
    },
    "Engine": {
      "type": "string",
      "enum": [
        "chatgpt",
        "perplexity",
        "gemini",
        "ai-overviews",
        "ai-mode"
      ],
      "description": "Answer engine. ai-mode is opt-in. Check prices: Perplexity 5¢, ChatGPT 7¢, Google AI Overviews 9¢, Google AI Mode 10¢ (opt-in), Gemini 12¢."
    }
  }
}