{
  "openapi": "3.1.0",
  "info": {
    "title": "delta mandate Evidence Extractor API",
    "description": "Extracts structured evidence attributes for a proposed solution.",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "http://localhost:9000"
    }
  ],
  "paths": {
    "/extract": {
      "post": {
        "summary": "Extract evidence attributes from a proposed solution.",
        "description": "Fetches or resolves the proposed solution and extracts its evidence fields.",
        "operationId": "evidence_extract",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtractionRequest"
              },
              "examples": {
                "solution-with-metadata": {
                  "summary": "Request with solution and metadata.",
                  "value": {
                    "solution": "gid://shopify/ProductVariant/42582963060798",
                    "metadata": {
                      "taxonomy_category": "Media > Books > Printed Books",
                      "merchant": "example-store"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Extracted evidence attributes. Attributes without enough evidence are omitted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractedAttributes"
                },
                "example": {
                  "category": "Media > Books > Printed Books",
                  "genre": "Fantasy",
                  "title": "The Lord of the Rings"
                }
              }
            }
          },
          "400": {
            "description": "The request is malformed, has invalid fields, or references an unsupported or missing solution.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "The server could not complete extraction.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ExtractionRequest": {
        "type": "object",
        "description": "Proposed solution and caller-provided metadata.",
        "required": [
          "solution",
          "metadata"
        ],
        "properties": {
          "solution": {
            "type": "string",
            "description": "Identifier of the proposed solution to inspect.",
            "examples": [
              "gid://shopify/ProductVariant/42582963060798"
            ]
          },
          "metadata": {
            "description": "Arbitrary JSON metadata agreed between the caller and evidence layer."
          }
        },
        "additionalProperties": false
      },
      "ExtractedAttributes": {
        "type": "object",
        "description": "Map from each extracted evidence attribute name to its value. Values are validated by the orchestrator against the template evidence schema.",
        "propertyNames": {
          "type": "string",
          "minLength": 1
        },
        "additionalProperties": true
      },
      "ErrorResponse": {
        "type": "object",
        "description": "Error returned when the extractor cannot process the request.",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "Human-readable explanation of the failure."
          }
        },
        "additionalProperties": false
      }
    }
  }
}