{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elicit/json-schema/elicit-systematic-review-session-detail-schema.json",
  "title": "SystematicReviewSessionDetail",
  "x-generated": "2026-11-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elicit-openapi.json#/components/schemas/SystematicReviewSessionDetail",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "const": "systematicReview"
    },
    "sessionId": {
      "type": "string",
      "format": "uuid",
      "description": "The session ID (UUID) returned by the create endpoints and `GET /sessions`"
    },
    "status": {
      "type": "string",
      "enum": [
        "processing",
        "pausedForInsufficientQuota",
        "completed",
        "failed",
        "unknown"
      ],
      "description": "Current status. Transitions: processing ⇄ pausedForInsufficientQuota (paused when the account exceeds its usage limit; stays paused until explicitly resumed via the resume endpoint or the Elicit web interface), processing → completed/failed. Poll until completed or failed."
    },
    "executionStage": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "gathering_sources",
        "screening_abstract",
        "screening_fulltext",
        "extracting_data",
        "generating_report",
        "done",
        null
      ],
      "description": "Current pipeline stage. Advances through gathering_sources → screening_abstract → screening_fulltext → extracting_data → generating_report → done. Null when the stage isn't known — treat it as unknown, not as not-started."
    },
    "url": {
      "type": "string",
      "description": "URL to view the review in the Elicit web interface"
    },
    "isPublic": {
      "type": "boolean",
      "description": "Whether the review is publicly accessible via its URL without authentication"
    },
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Machine-readable error code"
        },
        "message": {
          "type": "string",
          "description": "Human-readable error message"
        }
      },
      "required": [
        "code",
        "message"
      ],
      "description": "Error details, only present when status is failed"
    },
    "data": {
      "$ref": "#/$defs/ReviewData",
      "description": "Stage-organized content and export URLs: per-stage `search`/`screen`/`fulltext`/`extract` CSV + XLSX downloads and `report` content plus pdf/docx/txt/bib/ris downloads. Cached downloads can lag behind current stage outputs even when `exportsStatus` is `ready`; absence does not prove a stage did not run. Repoll after at least 60 seconds for missing expected exports, including after completion, using bounded retries with backoff."
    },
    "dataFreshness": {
      "type": [
        "string",
        "null"
      ],
      "description": "ISO timestamp of the cached export manifest used for this response, or null when no timestamp is available for the returned data. An unchanged timestamp can indicate a stale cache; the timestamp alone does not guarantee that every completed stage is exported."
    },
    "exportsStatus": {
      "type": "string",
      "enum": [
        "ready",
        "generating",
        "unavailable"
      ],
      "description": "Availability of cached export download URLs in `data`. `ready`: a cached manifest was served; it can be stale, including during regeneration or failures, and does not guarantee a complete current export set. If expected URLs are missing, repoll after at least 60 seconds with bounded backoff, even after completion. `generating`: exports are being generated and no cached downloads can be served. `unavailable`: export generation or retrieval failed and no cached downloads can be served; structured report content may still be available."
    },
    "links": {
      "$ref": "#/$defs/SessionLinks"
    }
  },
  "required": [
    "type",
    "sessionId",
    "status",
    "executionStage",
    "url",
    "isPublic",
    "dataFreshness",
    "exportsStatus",
    "links"
  ],
  "$defs": {
    "ReportData": {
      "type": "object",
      "properties": {
        "result": {
          "$ref": "#/$defs/ReviewResult",
          "description": "Structured report content (title, summary, optional body + abstract)."
        },
        "pdf": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for the report PDF. Expires in 7 days."
        },
        "docx": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for the report DOCX. Expires in 7 days."
        },
        "txt": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for an APA-style plain-text reference list of the papers synthesized in the report. Expires in 7 days."
        },
        "bib": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for a BibTeX bibliography of the papers synthesized in the report. Expires in 7 days."
        },
        "ris": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for a RIS bibliography of the papers synthesized in the report. Expires in 7 days."
        }
      },
      "required": [
        "result"
      ]
    },
    "ReviewData": {
      "type": "object",
      "properties": {
        "search": {
          "$ref": "#/$defs/StageData",
          "description": "Gather-stage paper list exports."
        },
        "screen": {
          "$ref": "#/$defs/StageData",
          "description": "Abstract-screening results exports."
        },
        "fulltext": {
          "$ref": "#/$defs/StageData",
          "description": "Fulltext-screening results exports."
        },
        "extract": {
          "$ref": "#/$defs/StageData",
          "description": "Extraction-stage results exports."
        },
        "report": {
          "$ref": "#/$defs/ReportData",
          "description": "Report-stage content and exports."
        }
      }
    },
    "ReviewResult": {
      "type": "object",
      "properties": {
        "title": {
          "type": "string",
          "description": "Auto-generated title"
        },
        "summary": {
          "type": "string",
          "description": "AI-generated executive summary of the findings"
        },
        "reportBody": {
          "type": [
            "string",
            "null"
          ],
          "description": "Full report content in markdown format. Only included when ?include=reportBody is specified."
        },
        "abstract": {
          "type": [
            "string",
            "null"
          ],
          "description": "Report abstract in markdown format. Only included when ?include=reportBody is specified."
        }
      },
      "required": [
        "title",
        "summary"
      ]
    },
    "SessionLinks": {
      "type": "object",
      "properties": {
        "self": {
          "type": "string",
          "description": "API URL for this session's full status and results (the typed get endpoint for its type)"
        },
        "resume": {
          "type": "string",
          "description": "API URL to resume this session. Present only while the session is paused for insufficient quota. Only the owner can use it; a shared recipient receives 404 even when this link is present."
        }
      },
      "required": [
        "self"
      ]
    },
    "StageData": {
      "type": "object",
      "properties": {
        "csv": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for the CSV export. Expires in 7 days."
        },
        "xlsx": {
          "type": "string",
          "format": "uri",
          "description": "Presigned URL for the XLSX export. Expires in 7 days."
        }
      },
      "required": [
        "csv",
        "xlsx"
      ]
    }
  }
}