{
  "openapi": "3.1.0",
  "info": {
    "title": "Luna Repo Clinic",
    "version": "0.1.0",
    "description": "Bounded, read-only public GitHub repository health triage. The paid route accepts USDC nanopayments through x402. No repository code is executed."
  },
  "servers": [
    { "url": "https://repo.luna.shardware.net" }
  ],
  "paths": {
    "/v1/repo-clinic": {
      "post": {
        "summary": "Inspect a public GitHub repository at an exact commit",
        "operationId": "inspectPublicRepository",
        "x-payment": { "price": "$0.01", "protocol": "x402", "network": "eip155:8453", "asset": "USDC" },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/InspectionRequest" },
              "example": { "repository_url": "https://github.com/octocat/Hello-World", "commit": "7fd1a60" }
            }
          }
        },
        "responses": {
          "200": { "description": "Evidence-backed bounded triage report", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/InspectionReport" } } } },
          "400": { "description": "Invalid request" },
          "402": { "description": "Payment Required" },
          "404": { "description": "Repository or commit not found" },
          "413": { "description": "Request body exceeds the bounded size limit" },
          "502": { "description": "Upstream inspection failure" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "InspectionRequest": {
        "type": "object",
        "required": ["repository_url", "commit"],
        "properties": {
          "repository_url": { "type": "string", "format": "uri", "pattern": "^https://github\\.com/[^/]+/[^/]+$" },
          "commit": { "type": "string", "pattern": "^[0-9a-fA-F]{7,64}$" }
        },
        "additionalProperties": false
      },
      "InspectionReport": {
        "type": "object",
        "required": ["service", "repository", "commit", "file_signals", "recommendations"],
        "properties": {
          "service": { "type": "string" },
          "service_version": { "type": "string" },
          "repository": { "type": "string" },
          "commit": { "type": "string" },
          "commit_message": { "type": ["string", "null"] },
          "repository_visibility": { "type": "string" },
          "inspected_without_credentials": { "type": "boolean" },
          "executed_repository_code": { "type": "boolean" },
          "file_signals": { "type": "object" },
          "recommendations": { "type": "array", "items": { "type": "object" } },
          "scope_note": { "type": "string" }
        }
      }
    }
  }
}
