{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/preuve-ai/json-schema/preuve-ai-analysis-run-schema.json",
  "title": "AnalysisRun",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/preuve-ai-openapi.json#/components/schemas/AnalysisRun",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "reportId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Null until the report row is attached, which is why a run that failed before dispatch is retryable under the same clientRunId.\n"
    },
    "clientRunId": {
      "type": [
        "string",
        "null"
      ],
      "description": "The caller-chosen id from create. Null when the analysis is a dashboard-created report resolved by its report id: no run row exists, so there is no clientRunId to replay.\n"
    },
    "batchId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "The batch this run belongs to, or null for a standalone run."
    },
    "scanType": {
      "type": "string",
      "enum": [
        "starter",
        "deep"
      ],
      "description": "Your request type. Reliable from creation, even while PROCESSING."
    },
    "enrichmentMode": {
      "type": "string",
      "enum": [
        "core",
        "none"
      ]
    },
    "publish": {
      "type": "boolean"
    },
    "reportType": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "quick",
        "deep_dive",
        null
      ]
    },
    "analysisTier": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "basic",
        "advanced",
        null
      ],
      "description": "Derived from the report. Deep runs read \"basic\" until deep sections land."
    },
    "status": {
      "type": "string",
      "enum": [
        "PENDING",
        "PROCESSING",
        "COMPLETED",
        "FAILED"
      ]
    },
    "progressStep": {
      "type": [
        "string",
        "null"
      ],
      "description": "Free-text pipeline stage while PROCESSING."
    },
    "errorCode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set on a FAILED run. Two internal markers are deliberately rewritten before they leave: an ambiguous dispatch reports TRIGGER_DISPATCH_FAILED and an ambiguous claim refund reports REPORT_CREATE_FAILED.\n"
    },
    "errorMessage": {
      "type": [
        "string",
        "null"
      ]
    },
    "resetAt": {
      "type": "string",
      "format": "date-time",
      "description": "Present only on a batch item refused by the rolling daily cap; absent, not null, on every other run.\n"
    },
    "pollAfterSeconds": {
      "type": "integer",
      "description": "Present only while polling is still useful. Pace by this rather than by a fixed interval.\n"
    },
    "pollHint": {
      "type": "string",
      "description": "Present alongside pollAfterSeconds."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "readyForExport": {
      "type": "boolean",
      "description": "Whether GET /export will serve this analysis now. Always false for a report created on the preuve.ai dashboard, whatever state the report is in, because that export answers 403 REPORT_NOT_FROM_AGENT_RUN. Branch on exportable first.\n"
    },
    "exportable": {
      "type": "boolean",
      "description": "Present, and false, only on a report created on the preuve.ai dashboard. Absent means the ordinary contract applies and readyForExport is the gate. When it is false, no amount of polling or enriching changes it.\n"
    },
    "exportBlockedCode": {
      "type": "string",
      "enum": [
        "REPORT_NOT_FROM_AGENT_RUN"
      ],
      "description": "Present alongside exportable, naming the refusal."
    },
    "exportBlockedHint": {
      "type": "string",
      "description": "Present alongside exportable. Relayable prose."
    },
    "enrichment": {
      "$ref": "#/$defs/EnrichmentState"
    },
    "modules": {
      "type": [
        "object",
        "null"
      ],
      "description": "Per-module statuses. Deep reports only; null on free runs.",
      "properties": {
        "proofOfDemand": {
          "$ref": "#/$defs/ModuleStatus"
        },
        "founderFit": {
          "$ref": "#/$defs/ModuleStatus"
        },
        "playbook": {
          "$ref": "#/$defs/ModuleStatus"
        },
        "trends": {
          "$ref": "#/$defs/ModuleStatus"
        },
        "community": {
          "$ref": "#/$defs/ModuleStatus"
        }
      }
    },
    "reportUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Null until the report row exists."
    },
    "shareUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    }
  },
  "$defs": {
    "EnrichmentState": {
      "type": "object",
      "description": "Progress of the core export sections. The four name arrays partition `required`, so a poller decides what to do next by reading them rather than by parsing `status`: anything in processing means keep polling, anything in failed means call enrich again, and missing with nothing processing means enrichment was never started for it.\n",
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "core",
            "none"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "not_required",
            "pending",
            "processing",
            "partial",
            "completed",
            "failed"
          ],
          "description": "Rolled up from the arrays below. \"partial\" means some sections landed and others did not; \"not_required\" is mode \"none\", or a report with no required sections.\n"
        },
        "required": {
          "type": "array",
          "description": "Every section this report and mode need. The other four arrays partition it.",
          "items": {
            "type": "string"
          }
        },
        "completed": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "missing": {
          "type": "array",
          "description": "Required, not generated, and not currently being generated.",
          "items": {
            "type": "string"
          }
        },
        "processing": {
          "type": "array",
          "description": "Generation is in flight. Keep polling rather than calling enrich again.",
          "items": {
            "type": "string"
          }
        },
        "failed": {
          "type": "array",
          "description": "Generation was attempted and failed. Retryable by calling enrich again.",
          "items": {
            "type": "string"
          }
        },
        "sections": {
          "type": "object",
          "description": "Per-section detail, keyed by section name, for every entry in required. Each value carries at least a status matching the array the section is in, plus completedAt on a completed section and whatever the last attempt recorded on a failed one.\n",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "missing",
                  "processing",
                  "completed",
                  "failed",
                  "pending"
                ]
              },
              "completedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "ModuleStatus": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "not_generated",
            "generating",
            "failed",
            "completed"
          ]
        }
      }
    }
  }
}