{
  "openapi": "3.1.0",
  "info": {
    "title": "GroupConsensus — SimCondor Analysis API",
    "description": "Stateless Monte Carlo + Condorcet decision analysis. POST a decision with alternatives and weighted criteria (the request body names that array `factors`) to get the recommended choice, ranking, pairwise win matrix, and disagreement metrics. No account and no auth required: these two endpoints persist nothing and are reachable without a session (everything else under /api/ requires signing in during the private beta).",
    "version": "1.0.0"
  },
  "servers": [
    { "url": "/" }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "summary": "Service health and endpoint list",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "example": {
                  "status": "ok",
                  "name": "SimCondor",
                  "endpoints": ["/api/analyze", "/api/sensitivity", "/api/analyses", "/mcp", "/openapi.json", "/.well-known/agent.json"]
                }
              }
            }
          }
        }
      }
    },
    "/api/analyze": {
      "get": {
        "summary": "Describe the analysis API and its input schema"
      },
      "post": {
        "summary": "Run a Monte Carlo + Condorcet decision analysis",
        "description": "Given alternatives and weighted criteria (with optional uncertainty ranges), returns the recommended choice, full ranking, pairwise win matrix, per-criterion averages, and a plain-language recommendation. The request field for the criteria is `factors`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "decisionName": { "type": "string", "description": "Name of the decision (optional)" },
                  "alternatives": {
                    "type": "array",
                    "description": "The options to choose between; strings are auto-numbered, or use { id, name } objects",
                    "items": { "oneOf": [{ "type": "string" }, { "type": "object", "properties": { "id": { "type": "number" }, "name": { "type": "string" } } }] }
                  },
                  "factors": {
                    "type": "array",
                    "description": "Evaluation criteria: importance (1-10) and a performance score per alternative, optionally as { min, max, distribution, peak } ranges",
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": { "type": ["string", "number"] },
                        "name": { "type": "string" },
                        "importance": {
                          "oneOf": [
                            { "type": "number" },
                            { "type": "object", "properties": { "min": { "type": "number" }, "max": { "type": "number" }, "distribution": { "enum": ["uniform", "triangular"] }, "peak": { "type": "number" } } }
                          ]
                        },
                        "performances": {
                          "type": "object",
                          "additionalProperties": {
                            "oneOf": [
                              { "type": "number" },
                              { "type": "object", "properties": { "min": { "type": "number" }, "max": { "type": "number" }, "distribution": { "enum": ["uniform", "triangular"] }, "peak": { "type": "number" } } }
                            ]
                          }
                        }
                      }
                    }
                  },
                  "numSimulations": { "type": "integer", "minimum": 1000, "maximum": 100000, "description": "Monte Carlo iterations (default 10000). The same 1000-100000 range the app stores on a decision." },
                  "seed": { "type": "integer", "description": "Optional seed for reproducible results" },
                  "framework": {
                    "type": "object",
                    "description": "Optional Decision Check quantifiers",
                    "properties": {
                      "confidence": { "type": "number", "minimum": 0, "maximum": 100, "description": "0-100; widens uncertainty ranges when low" },
                      "reversibility": { "type": "number", "minimum": 0, "maximum": 100, "description": "0-100; 100 = one-way door, applies a downside-risk penalty" }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Analysis result (recommended choice, ranking, win matrix, per-criterion averages, recommendation)" },
          "400": { "description": "Invalid input" }
        }
      }
    },
    "/api/sensitivity": {
      "post": {
        "summary": "Run a what-if sensitivity analysis",
        "description": "Same input as /api/analyze plus overrideFactorId and overridePerformances (alternative → fixed score) to see how forcing one criterion's scores changes the winner.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "overrideFactorId": { "type": "string", "description": "The criterion id to override (the request field is named overrideFactorId)" },
                  "overridePerformances": { "type": "object", "description": "Map of alternative id/name to a fixed performance score", "additionalProperties": { "type": "number" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Sensitivity analysis result" },
          "400": { "description": "Invalid input" }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "Model Context Protocol endpoint (Streamable HTTP)",
        "description": "Connect any MCP client. Exposes run_decision_analysis and run_sensitivity_analysis. See https://modelcontextprotocol.io for the protocol."
      },
      "delete": {
        "summary": "MCP session deletion"
      }
    }
  }
}