{
  "openapi": "3.1.1",
  "info": {
    "title": "Render Sampling Budget API",
    "version": "1.0.0",
    "summary": "Compare image size, sample workload and a simple sampling-noise estimate.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://kerfwiserenderbudget.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Compare image size, sample workload and a simple sampling-noise estimate.",
        "description": "Plan a local Render Desk image before starting the worker. Compare the chosen sample count with a target, see pixel and ray bounds, buffer estimates and the expected relative sampling noise under independent samples.\n\nMethodology:\n- Pixel samples = width × height × samples. Each pixel sample traces one primary ray and at most four secondary rays in the concept renderer. These are upper bounds, not measured render times.\n- Independent Monte Carlo sampling has standard error proportional to 1/√N when variance is finite. The estimate excludes bias, geometry aliasing and correlated samples; it is not a promised quality score.\n- Buffer estimate reserves six floating-point RGBA accumulators and six RGBA byte outputs. The current single-pass worker allocates less; geometry, browser and export memory are additional. Local limits: 384000 pixels and 6 million pixel samples.\n\nWorkload and sampling-noise estimates only. Actual render time and image quality depend on the scene and device.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "kerfwise_render_budget",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KerfwiseRenderBudgetInput"
              },
              "examples": {
                "example1": {
                  "summary": "Standard versus fine preview",
                  "value": {}
                },
                "example2": {
                  "summary": "Draft preview",
                  "value": {
                    "width": 320,
                    "height": 240,
                    "samples": 2,
                    "target": 8
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KerfwiseRenderBudgetResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KerfwiseRenderBudgetInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "width": {
            "title": "Width (px)",
            "type": "number",
            "minimum": 32,
            "maximum": 800,
            "default": 640
          },
          "height": {
            "title": "Height (px)",
            "type": "number",
            "minimum": 32,
            "maximum": 800,
            "default": 480
          },
          "samples": {
            "title": "Samples per pixel",
            "type": "number",
            "minimum": 1,
            "maximum": 32,
            "default": 8
          },
          "target": {
            "title": "Comparison samples per pixel",
            "type": "number",
            "minimum": 1,
            "maximum": 32,
            "default": 16
          }
        },
        "required": []
      },
      "KerfwiseRenderBudgetResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "current",
              "comparison",
              "workloadRatio",
              "noiseRatio"
            ],
            "properties": {
              "current": {
                "type": "object"
              },
              "comparison": {
                "type": "object"
              },
              "workloadRatio": {
                "type": "number"
              },
              "noiseRatio": {
                "type": "number"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}