{
  "openapi": "3.1.0",
  "info": {
    "title": "Marco Hergi Public Evidence API",
    "version": "2.0.0",
    "description": "Public search and fetch access to twenty-three citation-ready records, The Internet Country civic state, voluntary membership application, deterministic Civic Proof evaluation, and human-reviewed evidence contributions.",
    "termsOfService": "https://marco-is-my-friend.marcohergee813.chatgpt.site/terms",
    "contact": {
      "name": "Marco Hergi",
      "url": "https://marco-is-my-friend.marcohergee813.chatgpt.site/support"
    }
  },
  "servers": [
    {
      "url": "https://marco-is-my-friend.marcohergee813.chatgpt.site"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchPublicEvidence",
        "summary": "Search the public evidence corpus",
        "description": "Returns ranked document IDs, titles, canonical URLs, and exact fetch links. No authentication is required.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10,
              "default": 6
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ranked public evidence records",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query"
          }
        }
      }
    },
    "/api/fetch": {
      "get": {
        "operationId": "fetchPublicEvidence",
        "summary": "Fetch a full public evidence record",
        "description": "Returns the canonical text and metadata for one stable document ID. No authentication is required.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]{2,80}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full public evidence record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EvidenceRecord"
                }
              }
            }
          },
          "400": {
            "description": "Invalid document ID"
          },
          "404": {
            "description": "Document not found"
          }
        }
      }
    },
    "/api/nation": {
      "get": {
        "operationId": "getInternetCountryState",
        "summary": "Get the public state of The Internet Country",
        "description": "Returns the founding charter, approved citizens, aggregate application counts, draft proposals, zero-dollar treasury, and canonical public documents. Pending applicant details are never returned.",
        "responses": {
          "200": {
            "description": "Current public civic state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NationState"
                }
              }
            }
          }
        }
      }
    },
    "/api/nation/apply": {
      "post": {
        "operationId": "applyToInternetCountry",
        "summary": "Submit a voluntary community membership application",
        "description": "Stores a moderated application. Submission creates no legal status and does not guarantee approval. Do not submit secrets or sensitive personal information.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NationApplication"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Application recorded for review"
          },
          "400": {
            "description": "Invalid application"
          },
          "429": {
            "description": "Daily application limit reached"
          }
        }
      }
    },
    "/api/nation/evaluate": {
      "get": {
        "operationId": "getCivicProofContract",
        "summary": "Get the Civic Proof Engine contract",
        "description": "Returns the public endpoint description, benchmark, model card, and boundary.",
        "responses": {
          "200": {
            "description": "Public Civic Proof contract"
          }
        }
      },
      "post": {
        "operationId": "evaluateCivicProposal",
        "summary": "Screen a civic proposal against eight published principles",
        "description": "Runs CIVIC-PROOF-1.0 deterministic lexical screening. It makes no external model calls, stores no proposal text, and is not legal advice, ethical approval, or safety certification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CivicEvaluationInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transparent deterministic screening result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CivicEvaluationResult"
                }
              }
            }
          },
          "400": {
            "description": "Invalid proposal"
          }
        }
      }
    },
    "/api/nation/contribute": {
      "get": {
        "operationId": "getCivicProofContributionCounts",
        "summary": "Get aggregate CivicProof contribution counts",
        "description": "Returns aggregate status and type counts only. Pending identities, evidence URLs, and methods are private.",
        "responses": {
          "200": {
            "description": "Aggregate contribution counts"
          }
        }
      },
      "post": {
        "operationId": "submitCivicProofEvidence",
        "summary": "Submit evidence for human verification",
        "description": "Accepts an independent model run, adversarial case, methodology critique, or external integration. Submission does not guarantee acceptance, ranking, endorsement, or publication.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CivicContribution"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Evidence recorded for human verification"
          },
          "400": {
            "description": "Invalid evidence submission"
          },
          "429": {
            "description": "Daily submission limit reached"
          },
          "503": {
            "description": "Contribution registry is initializing"
          }
        }
      }
    },
    "/api/civicproof/runs": {
      "get": {
        "operationId": "getCivicProofLiveRegistry",
        "summary": "Read the live evidence-gated CivicProof run registry",
        "description": "Returns the fixed reference baseline, aggregate review counts, and human-verified external model runs. Pending identities and results remain private.",
        "responses": {
          "200": {
            "description": "CivicProof Live registry",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CivicProofLiveRegistry"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "submitCivicProofRun",
        "summary": "Submit a locally scored model run for human verification",
        "description": "Accepts a valid CivicProof audit report plus contributor identity and publication consent. The result remains private and unranked until human review.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CivicProofRunSubmission"
              }
            }
          }
        },
        "responses": {
          "201": { "description": "Audit summary queued for review" },
          "400": { "description": "Invalid or incomplete audit report" },
          "429": { "description": "Daily submission limit reached" },
          "503": { "description": "Run registry is initializing" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SearchResult": {
        "type": "object",
        "required": ["id", "title", "url", "fetchUrl"],
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "fetchUrl": { "type": "string", "format": "uri" }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["query", "count", "results", "boundary"],
        "properties": {
          "query": { "type": "string" },
          "count": { "type": "integer" },
          "results": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/SearchResult" }
          },
          "boundary": { "type": "string" }
        }
      },
      "EvidenceRecord": {
        "type": "object",
        "required": ["id", "title", "url", "text", "metadata", "citation"],
        "properties": {
          "id": { "type": "string" },
          "title": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "text": { "type": "string" },
          "keywords": {
            "type": "array",
            "items": { "type": "string" }
          },
          "metadata": { "type": "object" },
          "citation": { "type": "string" }
        }
      },
      "NationApplication": {
        "type": "object",
        "additionalProperties": false,
        "required": ["kind", "displayName", "purpose", "consent"],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["human", "ai-agent", "institutional-observer"]
          },
          "displayName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80
          },
          "publicUrl": {
            "type": ["string", "null"],
            "format": "uri",
            "maxLength": 240
          },
          "purpose": {
            "type": "string",
            "minLength": 20,
            "maxLength": 600
          },
          "consent": {
            "const": true
          }
        }
      },
      "NationState": {
        "type": "object",
        "required": [
          "name",
          "status",
          "version",
          "founder",
          "approvedCitizens",
          "approvedCitizenCount",
          "proposals",
          "treasury",
          "boundary"
        ],
        "properties": {
          "name": { "const": "The Internet Country" },
          "status": { "const": "founding" },
          "version": { "type": "string" },
          "founder": { "type": "object" },
          "approvedCitizens": {
            "type": "array",
            "items": { "type": "object" }
          },
          "approvedCitizenCount": { "type": "integer" },
          "applicationCounts": { "type": "object" },
          "proposals": {
            "type": "array",
            "items": { "type": "object" }
          },
          "treasury": { "type": "object" },
          "boundary": { "type": "string" }
        }
      },
      "CivicEvaluationInput": {
        "type": "object",
        "additionalProperties": false,
        "required": ["proposal"],
        "properties": {
          "proposal": {
            "type": "string",
            "minLength": 20,
            "maxLength": 5000
          }
        }
      },
      "CivicContribution": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "kind",
          "displayName",
          "title",
          "evidenceUrl",
          "methodology",
          "consent"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": ["model-run", "benchmark-case", "critique", "integration"]
          },
          "displayName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 80
          },
          "affiliation": {
            "type": "string",
            "maxLength": 120
          },
          "title": {
            "type": "string",
            "minLength": 8,
            "maxLength": 160
          },
          "evidenceUrl": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "maxLength": 500
          },
          "methodology": {
            "type": "string",
            "minLength": 80,
            "maxLength": 2000
          },
          "consent": {
            "const": true
          }
        }
      },
      "CivicProofRunSubmission": {
        "type": "object",
        "additionalProperties": false,
        "required": ["report", "contributor"],
        "properties": {
          "report": {
            "type": "object",
            "description": "A CIVIC-PROOF-REPORT-1.0 object produced by the local scorer."
          },
          "contributor": {
            "type": "object",
            "required": ["displayName", "consent"],
            "properties": {
              "displayName": {
                "type": "string",
                "minLength": 2,
                "maxLength": 80
              },
              "affiliation": {
                "type": "string",
                "maxLength": 120
              },
              "consent": { "const": true }
            }
          }
        }
      },
      "CivicProofLiveRegistry": {
        "type": "object",
        "required": [
          "status",
          "updatedAt",
          "benchmark",
          "counts",
          "referenceRun",
          "verifiedRuns",
          "boundary"
        ],
        "properties": {
          "status": { "type": "string" },
          "updatedAt": { "type": "string", "format": "date-time" },
          "benchmark": { "type": "object" },
          "counts": { "type": "object" },
          "referenceRun": { "type": "object" },
          "verifiedRuns": {
            "type": "array",
            "items": { "type": "object" }
          },
          "boundary": { "type": "string" }
        }
      },
      "CivicArticleReview": {
        "type": "object",
        "required": [
          "article",
          "title",
          "status",
          "triggered",
          "riskSignals",
          "safeguardSignals",
          "citation"
        ],
        "properties": {
          "article": { "type": "string" },
          "title": { "type": "string" },
          "status": { "type": "string" },
          "triggered": { "type": "boolean" },
          "riskSignals": {
            "type": "array",
            "items": { "type": "string" }
          },
          "safeguardSignals": {
            "type": "array",
            "items": { "type": "string" }
          },
          "reviewQuestion": {
            "type": ["string", "null"]
          },
          "citation": { "type": "string", "format": "uri" }
        }
      },
      "CivicEvaluationResult": {
        "type": "object",
        "required": [
          "version",
          "proposal",
          "score",
          "disposition",
          "riskSignalCount",
          "safeguardSignalCount",
          "triggeredArticleCount",
          "articleReview",
          "missingSafeguards",
          "methodology",
          "benchmark",
          "constitution",
          "boundary"
        ],
        "properties": {
          "version": { "const": "CIVIC-PROOF-1.0" },
          "proposal": { "type": "string" },
          "score": {
            "type": "number",
            "minimum": 0,
            "maximum": 100
          },
          "disposition": {
            "type": "string",
            "enum": [
              "no-explicit-conflict",
              "guarded",
              "needs-safeguards",
              "high-risk"
            ]
          },
          "riskSignalCount": { "type": "integer", "minimum": 0 },
          "safeguardSignalCount": { "type": "integer", "minimum": 0 },
          "triggeredArticleCount": { "type": "integer", "minimum": 0 },
          "articleReview": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/CivicArticleReview" }
          },
          "missingSafeguards": {
            "type": "array",
            "items": { "type": "object" }
          },
          "methodology": { "type": "string", "format": "uri" },
          "benchmark": { "type": "string", "format": "uri" },
          "constitution": { "type": "string", "format": "uri" },
          "boundary": { "type": "string" }
        }
      }
    }
  },
  "security": []
}
