{
 "openapi": "3.1.0",
 "info": {
  "title": "AstroQ Engine API",
  "version": "1.0.0-draft",
  "summary": "Query public astronomy data instead of downloading it.",
  "description": "AstroQ engine (onpod app `astroq-engine`). This file is the canonical contract for the web\ngateway (`astroq-web`), the CLI and the Parallax lab. Rules (PLAN.md §3):\n\n* Every successful answer carries `provenance` (dataset, release, source local|federated,\n  object_key or upstream_url, retrieved_at, license).\n* \"Not there\" and \"could not look\" are different answers:\n  `absent` = we searched and it is not there (HTTP 404 + JSON `ErrorAbsent`);\n  `unavailable` = the layer is not loaded or the upstream archive failed (HTTP 503 + reason).\n  A failed lookup is never an empty 200.\n* Coordinates are ICRS degrees; times are MJD (+ ISO 8601); every measured field names its units.\n* Long computations answer 202 + job id (`/jobs/{id}`); responses are capped at 48 MB; heavy routes\n  have a concurrency slot (503 `busy` + Retry-After when full).\n* Numeric parameters are validated at the door (400 `bad_parameter`); a 500 carries a fixed text.\n\nAuthentication: send `Authorization: Bearer aq_…` (create a key at https://astroq.ai3discovery.com/account). Without a key a small per-network quota applies.\n\n`x-status` on each operation: `live` = answered now on https://astroq-engine.onpod.ai,\n`planned` = in the contract, not answered yet (the engine returns 501 `not_implemented`).\n`x-source` says where answers come from today: `local` index, `federated` (upstream archive, cached),\nor `computed`. engine/STATUS.md has the per-layer row counts and releases.\n"
 },
 "servers": [
  {
   "url": "https://astroq.ai3discovery.com/api/v1",
   "description": "AstroQ public gateway"
  }
 ],
 "security": [
  {
   "apiKey": []
  },
  {}
 ],
 "tags": [
  {
   "name": "status"
  },
  {
   "name": "identify"
  },
  {
   "name": "catalogs"
  },
  {
   "name": "timeseries"
  },
  {
   "name": "lists"
  },
  {
   "name": "compute"
  },
  {
   "name": "research"
  },
  {
   "name": "sky"
  },
  {
   "name": "viz"
  },
  {
   "name": "literature"
  },
  {
   "name": "internal"
  }
 ],
 "paths": {
  "/health": {
   "get": {
    "tags": [
     "status"
    ],
    "summary": "Liveness, layer readiness and the boot gate result (no key needed)",
    "x-status": "planned",
    "responses": {
     "200": {
      "description": "engine is serving (gate may still be degraded — read `gate.state`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Health"
        }
       }
      }
     },
     "503": {
      "description": "engine is booting or the gate failed hard",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Health"
        }
       }
      }
     }
    }
   }
  },
  "/catalog": {
   "get": {
    "tags": [
     "status"
    ],
    "summary": "Datasets the engine answers from (rows, release, license, coverage, local|federated)",
    "x-status": "planned",
    "responses": {
     "200": {
      "description": "catalog",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "layers",
          "generated_at"
         ],
         "properties": {
          "generated_at": {
           "type": "string",
           "format": "date-time"
          },
          "layers": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/LayerInfo"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/freshness": {
   "get": {
    "tags": [
     "status"
    ],
    "summary": "Data vintage per layer (upstream date, basis, age, stale?)",
    "x-status": "planned",
    "responses": {
     "200": {
      "description": "freshness",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "layers": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "layer": {
              "type": "string"
             },
             "release": {
              "type": "string"
             },
             "as_of": {
              "type": [
               "string",
               "null"
              ],
              "description": "date of the upstream data (not of our build)"
             },
             "as_of_basis": {
              "type": "string",
              "enum": [
               "upstream_release_date",
               "file_timestamp",
               "query_time",
               "unknown"
              ]
             },
             "age_days": {
              "type": [
               "number",
               "null"
              ]
             },
             "stale": {
              "type": [
               "boolean",
               "null"
              ]
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/resolve": {
   "get": {
    "tags": [
     "identify"
    ],
    "summary": "Name → ICRS position and identifiers (SIMBAD/Sesame, Gaia, TIC, …)",
    "x-status": "planned",
    "x-source": [
     "federated",
     "local"
    ],
    "parameters": [
     {
      "name": "name",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 200
      },
      "example": "Vega"
     }
    ],
    "responses": {
     "200": {
      "description": "resolved",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Resolved"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/cone": {
   "get": {
    "tags": [
     "catalogs"
    ],
    "summary": "Cone search on one catalog (local HEALPix index, else federated TAP)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "name": "ra",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "minimum": 0,
       "maximum": 360
      },
      "description": "deg ICRS"
     },
     {
      "name": "dec",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "minimum": -90,
       "maximum": 90
      },
      "description": "deg ICRS"
     },
     {
      "name": "radius",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number",
       "exclusiveMinimum": 0,
       "maximum": 5
      },
      "description": "deg (max 5; larger areas → POST /query)"
     },
     {
      "name": "catalog",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "default": "gaia_dr3"
      },
      "description": "layer id from /catalog (gaia_dr3, hipparcos, tycho2, twomass, allwise, tic, simbad, vsx, …)"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 10000,
       "default": 500
      }
     },
     {
      "name": "columns",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "comma-separated column names (default: a compact set)"
     }
    ],
    "responses": {
     "200": {
      "description": "rows sorted by angular distance",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/RowsAnswer"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/object": {
   "get": {
    "tags": [
     "identify"
    ],
    "summary": "One object's unified record — cross-identifications, photometry, parallax, proper motion, variability, light curves available, literature count",
    "description": "The flagship route. Resolves `id` (any name or identifier SIMBAD/Gaia/TIC knows, or \"ra,dec\"),\nthen asks every catalog it holds or can federate. Each section reports its own status\n(`ok` | `absent` | `unavailable`), so a partial failure is visible, never silent.\n",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 200
      },
      "example": "TRAPPIST-1"
     },
     {
      "name": "radius_arcsec",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number",
       "minimum": 0.1,
       "maximum": 60,
       "default": 3
      },
      "description": "match radius for positional cross-identification"
     }
    ],
    "responses": {
     "200": {
      "description": "unified record (sections may individually be absent/unavailable)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ObjectRecord"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/xmatch": {
   "post": {
    "tags": [
     "catalogs"
    ],
    "summary": "Cross-match a list of positions against one catalog",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "positions"
        ],
        "properties": {
         "positions": {
          "type": "array",
          "maxItems": 5000,
          "items": {
           "type": "object",
           "required": [
            "ra",
            "dec"
           ],
           "properties": {
            "id": {
             "type": "string"
            },
            "ra": {
             "type": "number"
            },
            "dec": {
             "type": "number"
            }
           }
          }
         },
         "catalog": {
          "type": "string",
          "default": "gaia_dr3"
         },
         "radius_arcsec": {
          "type": "number",
          "default": 2,
          "maximum": 60
         },
         "best_only": {
          "type": "boolean",
          "default": true
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "one entry per input position (match or null with reason)",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "required": [
          "matches",
          "provenance"
         ],
         "properties": {
          "catalog": {
           "type": "string"
          },
          "radius_arcsec": {
           "type": "number"
          },
          "n_input": {
           "type": "integer"
          },
          "n_matched": {
           "type": "integer"
          },
          "matches": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "input": {
              "type": "object"
             },
             "match": {
              "type": [
               "object",
               "null"
              ]
             },
             "sep_arcsec": {
              "type": [
               "number",
               "null"
              ]
             },
             "n_candidates": {
              "type": "integer"
             }
            }
           }
          },
          "provenance": {
           "$ref": "#/components/schemas/Provenance"
          }
         }
        }
       }
      }
     },
     "202": {
      "$ref": "#/components/responses/Accepted"
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/query": {
   "post": {
    "tags": [
     "catalogs"
    ],
    "summary": "Read-only SQL over local layers (ADQL subset → DuckDB); row and time caps",
    "description": "`SELECT` only; one statement; tables are layer ids from /catalog (e.g. `exoplanets`, `hipparcos`,\n`gaia_dr3`). ADQL helpers accepted: `TOP n`, `CONTAINS(POINT(ra,dec), CIRCLE(ra0,dec0,r))`,\n`DISTANCE(POINT(...), POINT(...))`. Answers \"how many objects satisfy X\" with `count(*)`.\n",
    "x-status": "planned",
    "x-source": [
     "local"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "sql"
        ],
        "properties": {
         "sql": {
          "type": "string",
          "maxLength": 8000
         },
         "max_rows": {
          "type": "integer",
          "default": 1000,
          "maximum": 100000
         },
         "timeout_s": {
          "type": "number",
          "default": 20,
          "maximum": 120
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "result table",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/QueryAnswer"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/lightcurve": {
   "get": {
    "tags": [
     "timeseries"
    ],
    "summary": "Light curve (ZTF, TESS, Kepler/K2, Gaia epoch, ASAS-SN…; local first, else federated)",
    "x-status": "planned",
    "x-source": [
     "federated",
     "local"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      },
      "description": "name or identifier (TIC 123, Gaia DR3 …, ZTF oid); or give ra/dec"
     },
     {
      "name": "ra",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "dec",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "survey",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "ztf",
        "tess",
        "kepler",
        "k2",
        "gaia",
        "asassn"
       ],
       "default": "ztf"
      }
     },
     {
      "name": "radius_arcsec",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number",
       "default": 2,
       "maximum": 10
      }
     },
     {
      "name": "band",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "time series",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/LightCurve"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/periodogram": {
   "post": {
    "tags": [
     "compute"
    ],
    "summary": "Lomb-Scargle or BLS periodogram with false-alarm probability (server-side, astropy)",
    "x-status": "planned",
    "x-source": [
     "computed"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "method": {
          "type": "string",
          "enum": [
           "lomb_scargle",
           "bls"
          ],
          "default": "lomb_scargle"
         },
         "t": {
          "type": "array",
          "items": {
           "type": "number"
          },
          "description": "MJD (days)",
          "maxItems": 200000
         },
         "y": {
          "type": "array",
          "items": {
           "type": "number"
          }
         },
         "dy": {
          "type": "array",
          "items": {
           "type": "number"
          }
         },
         "id": {
          "type": "string",
          "description": "alternative to t/y: fetch /lightcurve first"
         },
         "survey": {
          "type": "string"
         },
         "band": {
          "type": "string"
         },
         "min_period": {
          "type": "number",
          "description": "days"
         },
         "max_period": {
          "type": "number",
          "description": "days"
         },
         "samples_per_peak": {
          "type": "integer",
          "default": 10
         },
         "durations": {
          "type": "array",
          "items": {
           "type": "number"
          },
          "description": "BLS durations (days)"
         },
         "n_peaks": {
          "type": "integer",
          "default": 5,
          "maximum": 50
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "peaks with FAP",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Periodogram"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/spectrum": {
   "get": {
    "tags": [
     "timeseries"
    ],
    "summary": "Spectrum (SDSS, DESI, LAMOST, Gaia XP)",
    "x-status": "planned",
    "x-source": [
     "federated"
    ],
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "ra",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "dec",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "survey",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "sdss",
        "desi",
        "lamost",
        "gaia_xp"
       ],
       "default": "sdss"
      }
     },
     {
      "name": "radius_arcsec",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number",
       "default": 2
      }
     }
    ],
    "responses": {
     "200": {
      "description": "spectrum or spectrum index",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Spectrum"
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/cutout": {
   "get": {
    "tags": [
     "catalogs"
    ],
    "summary": "Image cutout (CDS hips2fits, federated)",
    "x-status": "planned",
    "x-source": [
     "federated"
    ],
    "parameters": [
     {
      "name": "ra",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "dec",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "survey",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "default": "CDS/P/DSS2/color"
      },
      "description": "HiPS id"
     },
     {
      "name": "size",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number",
       "default": 0.25,
       "maximum": 5
      },
      "description": "field of view, deg"
     },
     {
      "name": "pixels",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "default": 512,
       "maximum": 2048
      }
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "schema": {
       "type": "string",
       "enum": [
        "jpg",
        "png",
        "fits"
       ],
       "default": "jpg"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "image bytes; provenance in headers `X-Astroq-Provenance` (JSON)",
      "content": {
       "image/jpeg": {},
       "image/png": {},
       "application/fits": {}
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/exoplanets": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Confirmed exoplanets (NASA Exoplanet Archive PSCompPars) — filter & page",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "name": "host",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "discoverymethod",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/transients": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Transients (TNS public objects; ALeRCE/Fink classifications)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "name": "type",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "since_mjd",
      "in": "query",
      "schema": {
       "type": "number"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/frb": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Fast radio bursts (CHIME/FRB catalog, TNS FRB)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "name": "repeater",
      "in": "query",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/pulsars": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Pulsars (ATNF Pulsar Catalogue)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/gw": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Gravitational-wave events (GWOSC event catalog, GWTC)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/grb": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Gamma-ray bursts (Fermi GBM burst catalog, Swift)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/smallbodies": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Small bodies (JPL SBDB; MPCORB when local)",
    "x-status": "planned",
    "x-source": [
     "federated",
     "local"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/variables": {
   "get": {
    "tags": [
     "lists"
    ],
    "summary": "Variable stars (AAVSO VSX; Gaia DR3 vari_classifier_result)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "$ref": "#/components/parameters/Q"
     },
     {
      "name": "type",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "$ref": "#/components/parameters/Offset"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/literature/search": {
   "get": {
    "tags": [
     "literature"
    ],
    "summary": "astro-ph literature search (arXiv metadata; keyword now, embeddings when built)",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "maxLength": 500
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     },
     {
      "name": "mode",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "auto",
        "keyword",
        "semantic"
       ],
       "default": "auto"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "ranked papers; `mode_used` says keyword or semantic",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/LiteratureAnswer"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/controls/sample": {
   "post": {
    "tags": [
     "research"
    ],
    "summary": "Matched random control sample (same magnitude/colour/galactic-latitude distribution) — reproducible with seed",
    "description": "For Parallax null distributions. Give the target set (positions or ids) or explicit bins; the engine\ndraws, from the chosen catalog, objects matching the targets' joint distribution in the chosen\ncovariates (histogram matching on bins), excluding the targets themselves. Same `seed` + same\ncatalog release ⇒ same sample (the release is in provenance).\n",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "seed"
        ],
        "properties": {
         "catalog": {
          "type": "string",
          "default": "gaia_dr3"
         },
         "targets": {
          "type": "array",
          "maxItems": 5000,
          "items": {
           "type": "object",
           "properties": {
            "ra": {
             "type": "number"
            },
            "dec": {
             "type": "number"
            },
            "g_mag": {
             "type": "number"
            },
            "bp_rp": {
             "type": "number"
            }
           }
          }
         },
         "match_on": {
          "type": "array",
          "items": {
           "type": "string",
           "enum": [
            "g_mag",
            "bp_rp",
            "abs_b",
            "parallax"
           ]
          },
          "default": [
           "g_mag",
           "bp_rp",
           "abs_b"
          ]
         },
         "n_per_target": {
          "type": "integer",
          "default": 10,
          "maximum": 100
         },
         "seed": {
          "type": "integer"
         },
         "exclude_radius_arcsec": {
          "type": "number",
          "default": 5
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "control sample",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/ControlSample"
        }
       }
      }
     },
     "202": {
      "$ref": "#/components/responses/Accepted"
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/known": {
   "get": {
    "tags": [
     "research"
    ],
    "summary": "\"Is this already known?\" — SIMBAD, VSX, TNS, NED, Gaia variability, exoplanet lists at once; per-upstream status",
    "description": "Each upstream reports `answered` (with hits, possibly zero) or `failed` (with reason). Overall\n`status` is `complete` when every upstream answered, `partial` when some failed. A failed\nupstream is never reported as \"no match\".\n",
    "x-status": "planned",
    "x-source": [
     "federated",
     "local"
    ],
    "parameters": [
     {
      "name": "ra",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "dec",
      "in": "query",
      "required": true,
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "radius",
      "in": "query",
      "required": false,
      "schema": {
       "type": "number",
       "default": 0.00278,
       "maximum": 0.1
      },
      "description": "deg (default 10 arcsec)"
     }
    ],
    "responses": {
     "200": {
      "description": "per-upstream answers",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/KnownAnswer"
        }
       }
      }
     },
     "400": {
      "$ref": "#/components/responses/BadParameter"
     }
    }
   }
  },
  "/sky/events": {
   "get": {
    "tags": [
     "sky"
    ],
    "summary": "Sentinel events (alerts, circulars, transients) — newest first",
    "x-status": "planned",
    "x-source": [
     "local"
    ],
    "parameters": [
     {
      "name": "since_mjd",
      "in": "query",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "kind",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/sky/anomalies": {
   "get": {
    "tags": [
     "sky"
    ],
    "summary": "Sentinel anomaly candidates (scored), newest first",
    "x-status": "planned",
    "x-source": [
     "local"
    ],
    "parameters": [
     {
      "name": "min_score",
      "in": "query",
      "schema": {
       "type": "number"
      }
     },
     {
      "$ref": "#/components/parameters/Limit"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/sky/stream": {
   "get": {
    "tags": [
     "sky"
    ],
    "summary": "Server-sent events stream of new Sentinel events (text/event-stream)",
    "x-status": "planned",
    "responses": {
     "200": {
      "description": "SSE: `event: sky` + `data: <SkyEvent JSON>`; heartbeat comment every 15 s",
      "content": {
       "text/event-stream": {}
      }
     }
    }
   }
  },
  "/viz/stars": {
   "get": {
    "tags": [
     "viz"
    ],
    "summary": "Near/bright stars as a binary tile for the 3D view (Float32 little-endian)",
    "description": "Body = header JSON length (uint32 LE) + header JSON + N records of 6 float32:\nx, y, z (pc, ICRS-aligned heliocentric), bp_rp (mag), g_abs (mag), g_mag (mag).\nThe header carries `n`, `fields`, `units`, `selection`, `provenance`.\n",
    "x-status": "planned",
    "x-source": [
     "local",
     "federated"
    ],
    "parameters": [
     {
      "name": "max_dist_pc",
      "in": "query",
      "schema": {
       "type": "number",
       "default": 200,
       "maximum": 5000
      }
     },
     {
      "name": "max_g",
      "in": "query",
      "schema": {
       "type": "number",
       "default": 12
      }
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "default": 500000,
       "maximum": 3000000
      }
     }
    ],
    "responses": {
     "200": {
      "description": "binary tile",
      "content": {
       "application/octet-stream": {}
      }
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/viz/density": {
   "get": {
    "tags": [
     "viz"
    ],
    "summary": "HEALPix star-count map (nested ordering) as Float32 binary or JSON",
    "x-status": "planned",
    "parameters": [
     {
      "name": "order",
      "in": "query",
      "schema": {
       "type": "integer",
       "default": 6,
       "minimum": 0,
       "maximum": 8
      }
     },
     {
      "name": "format",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "bin",
        "json"
       ],
       "default": "bin"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "density map",
      "content": {
       "application/octet-stream": {},
       "application/json": {}
      }
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/viz/events": {
   "get": {
    "tags": [
     "viz"
    ],
    "summary": "Recent sky events with positions for the 3D view (JSON)",
    "x-status": "planned",
    "parameters": [
     {
      "$ref": "#/components/parameters/Limit"
     }
    ],
    "responses": {
     "200": {
      "$ref": "#/components/responses/ListOK"
     },
     "503": {
      "$ref": "#/components/responses/Unavailable"
     }
    }
   }
  },
  "/jobs/{id}": {
   "get": {
    "tags": [
     "compute"
    ],
    "summary": "Result of a long computation started with 202",
    "x-status": "planned",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "job state; `result` when done",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "id": {
           "type": "string"
          },
          "state": {
           "type": "string",
           "enum": [
            "queued",
            "running",
            "done",
            "failed"
           ]
          },
          "result": {
           "type": [
            "object",
            "null"
           ]
          },
          "error": {
           "type": [
            "object",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/Absent"
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "apiKey": {
    "type": "http",
    "scheme": "bearer",
    "description": "AstroQ API key (aq_…). Optional: without a key, a small per-network quota applies."
   }
  },
  "parameters": {
   "Limit": {
    "name": "limit",
    "in": "query",
    "schema": {
     "type": "integer",
     "minimum": 1,
     "maximum": 1000,
     "default": 50
    }
   },
   "Offset": {
    "name": "offset",
    "in": "query",
    "schema": {
     "type": "integer",
     "minimum": 0,
     "default": 0
    }
   },
   "Q": {
    "name": "q",
    "in": "query",
    "schema": {
     "type": "string",
     "maxLength": 200
    },
    "description": "name / identifier / free text filter"
   }
  },
  "responses": {
   "BadParameter": {
    "description": "invalid input (named field)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/ErrorBadParameter"
      }
     }
    }
   },
   "Absent": {
    "description": "searched, not there",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/ErrorAbsent"
      }
     }
    }
   },
   "Unavailable": {
    "description": "layer not loaded or upstream failed — NOT \"none\"",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/ErrorUnavailable"
      }
     }
    }
   },
   "Forbidden": {
    "description": "missing gateway or internal key",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Accepted": {
    "description": "long computation queued",
    "content": {
     "application/json": {
      "schema": {
       "type": "object",
       "properties": {
        "job": {
         "type": "string"
        },
        "poll": {
         "type": "string",
         "example": "/jobs/abc123"
        }
       }
      }
     }
    }
   },
   "ListOK": {
    "description": "a page of records",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/ListAnswer"
      }
     }
    }
   }
  },
  "schemas": {
   "Provenance": {
    "type": "object",
    "required": [
     "dataset",
     "release",
     "source",
     "retrieved_at",
     "license"
    ],
    "properties": {
     "dataset": {
      "type": "string",
      "example": "Gaia DR3 gaia_source"
     },
     "release": {
      "type": "string",
      "example": "DR3"
     },
     "source": {
      "type": "string",
      "enum": [
       "local",
       "federated",
       "computed"
      ]
     },
     "object_key": {
      "type": [
       "string",
       "null"
      ],
      "description": "bucket key of the local index (local answers)"
     },
     "upstream_url": {
      "type": [
       "string",
       "null"
      ],
      "description": "archive endpoint (federated answers; no user data in it)"
     },
     "query": {
      "type": [
       "string",
       "null"
      ],
      "description": "ADQL/TAP or request sent upstream (federated)"
     },
     "retrieved_at": {
      "type": "string",
      "format": "date-time"
     },
     "cached": {
      "type": "boolean",
      "description": "federated answer served from cache"
     },
     "license": {
      "type": "string"
     },
     "citation": {
      "type": [
       "string",
       "null"
      ]
     }
    }
   },
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "string"
     },
     "why": {
      "type": "string"
     }
    }
   },
   "ErrorBadParameter": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Error"
     },
     {
      "type": "object",
      "properties": {
       "error": {
        "const": "bad_parameter"
       },
       "parameter": {
        "type": "string"
       },
       "got": {
        "type": "string"
       }
      }
     }
    ]
   },
   "ErrorAbsent": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Error"
     },
     {
      "type": "object",
      "required": [
       "status",
       "searched"
      ],
      "properties": {
       "error": {
        "const": "absent"
       },
       "status": {
        "const": "absent"
       },
       "searched": {
        "type": "array",
        "description": "what was searched (dataset + release + coverage), so the miss is interpretable",
        "items": {
         "type": "object"
        }
       },
       "means": {
        "type": "string",
        "example": "no record in these releases; not proof the object does not exist"
       }
      }
     }
    ]
   },
   "ErrorUnavailable": {
    "allOf": [
     {
      "$ref": "#/components/schemas/Error"
     },
     {
      "type": "object",
      "required": [
       "status",
       "reason"
      ],
      "properties": {
       "error": {
        "const": "unavailable"
       },
       "status": {
        "const": "unavailable"
       },
       "layer": {
        "type": "string"
       },
       "upstream": {
        "type": "string"
       },
       "reason": {
        "type": "string",
        "example": "upstream timeout after 30 s"
       },
       "retry_after_seconds": {
        "type": "number"
       }
      }
     }
    ]
   },
   "LayerInfo": {
    "type": "object",
    "properties": {
     "layer": {
      "type": "string"
     },
     "title": {
      "type": "string"
     },
     "source": {
      "type": "string",
      "enum": [
       "local",
       "federated",
       "both"
      ]
     },
     "rows": {
      "type": [
       "integer",
       "null"
      ]
     },
     "release": {
      "type": "string"
     },
     "license": {
      "type": "string"
     },
     "coverage": {
      "type": "string"
     },
     "routes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "ready": {
      "type": "boolean"
     }
    }
   },
   "Health": {
    "type": "object",
    "properties": {
     "ok": {
      "type": "boolean"
     },
     "version": {
      "type": "string"
     },
     "started_at": {
      "type": "string",
      "format": "date-time"
     },
     "gate": {
      "type": "object",
      "properties": {
       "state": {
        "type": "string",
        "enum": [
         "pending",
         "passed",
         "degraded",
         "failed"
        ]
       },
       "passed": {
        "type": "integer"
       },
       "failed": {
        "type": "array",
        "items": {
         "type": "object"
        }
       },
       "checked_at": {
        "type": "string",
        "format": "date-time"
       }
      }
     },
     "layers": {
      "type": "object",
      "additionalProperties": {
       "type": "object",
       "properties": {
        "ready": {
         "type": "boolean"
        },
        "source": {
         "type": "string"
        },
        "rows": {
         "type": [
          "integer",
          "null"
         ]
        },
        "release": {
         "type": "string"
        }
       }
      }
     },
     "guard": {
      "type": "object"
     }
    }
   },
   "Resolved": {
    "type": "object",
    "required": [
     "name",
     "ra",
     "dec",
     "provenance"
    ],
    "properties": {
     "name": {
      "type": "string"
     },
     "main_id": {
      "type": "string"
     },
     "ra": {
      "type": "number",
      "description": "deg ICRS"
     },
     "dec": {
      "type": "number",
      "description": "deg ICRS"
     },
     "otype": {
      "type": [
       "string",
       "null"
      ]
     },
     "identifiers": {
      "type": "object",
      "description": "catalog → identifier (gaia_dr3, tic, hip, hd, 2mass, …)",
      "additionalProperties": {
       "type": "string"
      }
     },
     "aliases": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "Section": {
    "type": "object",
    "required": [
     "status"
    ],
    "properties": {
     "status": {
      "type": "string",
      "enum": [
       "ok",
       "absent",
       "unavailable"
      ]
     },
     "data": {
      "type": [
       "object",
       "array",
       "null"
      ]
     },
     "reason": {
      "type": [
       "string",
       "null"
      ]
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "ObjectRecord": {
    "type": "object",
    "required": [
     "query",
     "resolved",
     "sections"
    ],
    "properties": {
     "query": {
      "type": "string"
     },
     "resolved": {
      "$ref": "#/components/schemas/Resolved"
     },
     "sections": {
      "type": "object",
      "description": "one Section per source; never silently dropped",
      "properties": {
       "identifiers": {
        "$ref": "#/components/schemas/Section"
       },
       "gaia": {
        "$ref": "#/components/schemas/Section"
       },
       "photometry": {
        "$ref": "#/components/schemas/Section"
       },
       "astrometry": {
        "$ref": "#/components/schemas/Section"
       },
       "variability": {
        "$ref": "#/components/schemas/Section"
       },
       "exoplanets": {
        "$ref": "#/components/schemas/Section"
       },
       "lightcurves": {
        "$ref": "#/components/schemas/Section"
       },
       "literature": {
        "$ref": "#/components/schemas/Section"
       },
       "special": {
        "$ref": "#/components/schemas/Section"
       }
      }
     },
     "summary": {
      "type": "object"
     }
    }
   },
   "RowsAnswer": {
    "type": "object",
    "required": [
     "rows",
     "n",
     "provenance"
    ],
    "properties": {
     "query": {
      "type": "object"
     },
     "n": {
      "type": "integer"
     },
     "truncated": {
      "type": "boolean"
     },
     "columns": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "units": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     },
     "rows": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "QueryAnswer": {
    "allOf": [
     {
      "$ref": "#/components/schemas/RowsAnswer"
     },
     {
      "type": "object",
      "properties": {
       "sql_executed": {
        "type": "string"
       },
       "elapsed_s": {
        "type": "number"
       },
       "tables": {
        "type": "array",
        "items": {
         "type": "string"
        }
       }
      }
     }
    ]
   },
   "ListAnswer": {
    "type": "object",
    "required": [
     "rows",
     "total",
     "provenance"
    ],
    "properties": {
     "layer": {
      "type": "string"
     },
     "total": {
      "type": "integer"
     },
     "n_returned": {
      "type": "integer"
     },
     "offset": {
      "type": "integer"
     },
     "next_offset": {
      "type": [
       "integer",
       "null"
      ]
     },
     "units": {
      "type": "object"
     },
     "rows": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "LightCurve": {
    "type": "object",
    "required": [
     "survey",
     "n",
     "points",
     "provenance"
    ],
    "properties": {
     "survey": {
      "type": "string"
     },
     "target": {
      "type": "object"
     },
     "n": {
      "type": "integer"
     },
     "bands": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "units": {
      "type": "object",
      "example": {
       "mjd": "d",
       "mag": "mag",
       "mag_err": "mag",
       "flux": "e-/s"
      }
     },
     "points": {
      "type": "object",
      "description": "column arrays (mjd, mag|flux, err, band, flags)"
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "Periodogram": {
    "type": "object",
    "properties": {
     "method": {
      "type": "string"
     },
     "n_points": {
      "type": "integer"
     },
     "baseline_days": {
      "type": "number"
     },
     "peaks": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "period_days": {
         "type": "number"
        },
        "power": {
         "type": "number"
        },
        "fap": {
         "type": [
          "number",
          "null"
         ],
         "description": "false-alarm probability (baluev for LS; bootstrap-free analytic)"
        },
        "depth": {
         "type": [
          "number",
          "null"
         ]
        },
        "duration_days": {
         "type": [
          "number",
          "null"
         ]
        },
        "t0_mjd": {
         "type": [
          "number",
          "null"
         ]
        },
        "snr": {
         "type": [
          "number",
          "null"
         ]
        }
       }
      }
     },
     "caveats": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "Spectrum": {
    "type": "object",
    "properties": {
     "survey": {
      "type": "string"
     },
     "target": {
      "type": "object"
     },
     "spectra": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "LiteratureAnswer": {
    "type": "object",
    "properties": {
     "q": {
      "type": "string"
     },
     "mode_used": {
      "type": "string",
      "enum": [
       "keyword",
       "semantic",
       "federated"
      ]
     },
     "n": {
      "type": "integer"
     },
     "papers": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "arxiv_id": {
         "type": "string"
        },
        "title": {
         "type": "string"
        },
        "authors": {
         "type": "string"
        },
        "published": {
         "type": "string"
        },
        "categories": {
         "type": "string"
        },
        "abstract": {
         "type": "string"
        },
        "score": {
         "type": "number"
        }
       }
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "ControlSample": {
    "type": "object",
    "properties": {
     "seed": {
      "type": "integer"
     },
     "catalog": {
      "type": "string"
     },
     "match_on": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "n_targets": {
      "type": "integer"
     },
     "n_controls": {
      "type": "integer"
     },
     "shortfall": {
      "type": "object",
      "description": "bins where fewer matches existed than asked"
     },
     "balance": {
      "type": "object",
      "description": "per-covariate target vs control quantiles"
     },
     "controls": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "provenance": {
      "$ref": "#/components/schemas/Provenance"
     }
    }
   },
   "KnownAnswer": {
    "type": "object",
    "required": [
     "status",
     "upstreams"
    ],
    "properties": {
     "status": {
      "type": "string",
      "enum": [
       "complete",
       "partial",
       "failed"
      ]
     },
     "position": {
      "type": "object"
     },
     "radius_deg": {
      "type": "number"
     },
     "known": {
      "type": [
       "boolean",
       "null"
      ],
      "description": "true if any answering upstream has a match; null if nothing answered and no local hit"
     },
     "upstreams": {
      "type": "object",
      "additionalProperties": {
       "type": "object",
       "properties": {
        "status": {
         "type": "string",
         "enum": [
          "answered",
          "failed"
         ]
        },
        "n": {
         "type": [
          "integer",
          "null"
         ]
        },
        "hits": {
         "type": "array",
         "items": {
          "type": "object"
         }
        },
        "reason": {
         "type": [
          "string",
          "null"
         ]
        },
        "provenance": {
         "$ref": "#/components/schemas/Provenance"
        }
       }
      }
     }
    }
   },
   "SkyEvent": {
    "type": "object",
    "description": "Sentinel's event schema (sentinel/STATUS.md §1.2) is the contract; the engine stores rows exactly as\nSentinel sends them and serves them back unchanged. The v0 names below (`event_id`, `source`,\n`time_mjd`, `error_radius_deg`) are still accepted on ingest and mapped to `id`, `stream`, `t_mjd`, `err_deg`.\n",
    "required": [
     "id",
     "kind"
    ],
    "properties": {
     "seq": {
      "type": "integer",
      "description": "Sentinel's own monotonic cursor"
     },
     "id": {
      "type": "string",
      "description": "<stream>:<upstream id>, globally unique; same id = overwrite"
     },
     "stream": {
      "type": "string",
      "example": "gcn_circulars"
     },
     "kind": {
      "type": "string",
      "example": "grb"
     },
     "title": {
      "type": "string"
     },
     "t_mjd": {
      "type": [
       "number",
       "null"
      ]
     },
     "t_iso": {
      "type": [
       "string",
       "null"
      ]
     },
     "t_basis": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "event",
       "published",
       "observed",
       null
      ]
     },
     "ra": {
      "type": [
       "number",
       "null"
      ]
     },
     "dec": {
      "type": [
       "number",
       "null"
      ]
     },
     "err_deg": {
      "type": [
       "number",
       "null"
      ]
     },
     "err_kind": {
      "type": [
       "string",
       "null"
      ]
     },
     "skymap_url": {
      "type": [
       "string",
       "null"
      ]
     },
     "mag": {
      "type": [
       "number",
       "null"
      ]
     },
     "mag_band": {
      "type": [
       "string",
       "null"
      ]
     },
     "flux": {
      "type": [
       "number",
       "null"
      ]
     },
     "flux_units": {
      "type": [
       "string",
       "null"
      ]
     },
     "object_id": {
      "type": [
       "string",
       "null"
      ]
     },
     "value": {
      "type": [
       "object",
       "null"
      ]
     },
     "url": {
      "type": [
       "string",
       "null"
      ]
     },
     "raw_key": {
      "type": [
       "string",
       "null"
      ]
     },
     "ingested_at": {
      "type": [
       "string",
       "null"
      ]
     },
     "replay": {
      "type": "boolean"
     },
     "event_id": {
      "type": "string",
      "description": "v0 name of id (accepted on ingest)"
     },
     "source": {
      "type": "string",
      "description": "v0 name of stream (accepted on ingest)"
     },
     "time_mjd": {
      "type": "number",
      "description": "v0 name of t_mjd (accepted on ingest)"
     },
     "time_iso": {
      "type": "string"
     },
     "error_radius_deg": {
      "type": [
       "number",
       "null"
      ],
      "description": "v0 name of err_deg"
     },
     "anomaly_score": {
      "type": [
       "number",
       "null"
      ]
     },
     "payload": {
      "type": "object"
     }
    }
   },
   "SkyAnomaly": {
    "type": "object",
    "description": "Sentinel anomaly candidate (sentinel/STATUS.md §1.3), stored and served unchanged. Candidates, never 'discoveries'.",
    "required": [
     "id"
    ],
    "properties": {
     "seq": {
      "type": "integer"
     },
     "id": {
      "type": "string"
     },
     "score": {
      "type": [
       "number",
       "null"
      ]
     },
     "level": {
      "type": [
       "string",
       "null"
      ],
      "enum": [
       "info",
       "notable",
       "alert",
       null
      ]
     },
     "rules": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "title_ko": {
      "type": [
       "string",
       "null"
      ]
     },
     "evidence": {
      "type": "array",
      "items": {
       "type": "object"
      }
     },
     "p_chance": {
      "type": [
       "number",
       "null"
      ]
     },
     "known": {
      "type": [
       "object",
       "null"
      ]
     },
     "events": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "ra": {
      "type": [
       "number",
       "null"
      ]
     },
     "dec": {
      "type": [
       "number",
       "null"
      ]
     },
     "t_mjd": {
      "type": [
       "number",
       "null"
      ]
     },
     "replay": {
      "type": "boolean"
     }
    }
   }
  }
 }
}