# Public read API The unauthenticated surface the conjectures.io website is built on: what is on offer, what an attempt costs, what has been verified, and whether submissions are open. Served by the same process as the miner-facing intake ([API.md](API.md)), on the same port, with a different middleware stack and a different set of response models. Everything here is a `GET`, needs no credential, and is safe to cache. | Method | Path | Contract | Purpose | | --- | --- | --- | --- | | `GET` | `/v1/catalog/conjectures` | `ConjectureListResponse` | List with filters and facet counts; one entry per conjecture | | `GET` | `/v1/catalog/conjectures/{slug}` | `ConjectureDetail` | Statement, references, bounty, pins, and one `Challenge.lean` plus machine contract per attack direction | | `GET` | `/v1/catalog/conjectures/{slug}/activity` | `ConjectureActivity` | Anonymised activity stream, paged by `offset` | | `GET` | `/v1/catalog/index` | `ConjectureIndexResponse` | Flat table of contents; one entry per *problem*, with its variants, retired ones flagged. Whole unless `limit`/`offset` ask for a page | | `GET` | `/v1/catalog/meta` | `PoolMeta` | Counts, credit price, treasury, bounty model, pins | | `GET` | `/v1/results/certified` | `CursorPage` | Approved and paid out. Filterable by `slug` and `q` | | `GET` | `/v1/results/in-review` | `CursorPage` | Lean-verified, awaiting manual review. Filterable by `slug` and `q` | | `GET` | `/v1/results/submissions` | `CursorPage` | Every submission in every state — including rejected and still-queued — newest first, for a dashboard | | `GET` | `/v1/results/stats` | `ResultStats` | Headline counts and the total paid out, overall or for one `slug` | | `GET` | `/v1/results/{id}` | `PublicResult` | One published result | | `GET` | `/v1/results/{id}/report` | `PublicVerificationReport` | The published subset of the verifier report | | `GET` | `/v1/results/{id}/solution` | `PublicSolution` | The proof itself — only once review has approved it | | `GET` | `/v1/invitations/{code}` | `InvitationOffer` | What an invitation link offers, without redeeming it | | `GET` | `/v1/system/status` | `SystemStatus` | Submissions open/paused, queue depths, pin rotation window | | `GET` | `/v1/contributions` | `OffsetPage` | Partial work contributed to the pool, newest first, with filters | | `GET` | `/v1/contributions/{id}` | `ContributionItem` | One contribution, by full id or unambiguous prefix | | `GET` | `/v1/contributions/targets` | `OffsetPage` | One row per target, including the ones nobody has contributed to | | `GET` | `/v1/contributions/targets/{target}` | `ContributionTargetDetail` | Everything on one target, by any of its four names. Whole unless `limit`/`offset` ask for a page | | `GET` | `/v1/contributions/authors` | `OffsetPage` | One row per author key, across every target | | `GET` | `/v1/contributions/pending` | `OffsetPage` | Open contribution pull requests: offered, not yet accepted | | `GET` | `/v1/contributions/meta` | `ContributionsMeta` | What corpus is served, at which commit, and how fresh | Response models are in [`../submission_api/schemas_public.py`](../submission_api/schemas_public.py), kept separate from the miner-facing `schemas.py` so that the rules below are enforced by which module a field lives in rather than by remembering to leave it out. The contribution models are in [`../submission_api/schemas_contributions.py`](../submission_api/schemas_contributions.py), separate again because they project a mirrored external repository rather than this validator's own database. ## What is published, and what is not Four rules, each enforced structurally rather than by convention. **Solver credit, and what was paid out, but not what the solver paid in.** Every result names its solver through `solver_display_name` and `solver_coldkey`, and `credited_name` resolves the one name to credit. A miner may also opt into `public_credit` with a name and optional HTTPS profile URL and ORCID. Those values are part of the signed request digest and are snapshotted on the submission; they are never looked up from a mutable account profile. Not published: the paying coldkey, payment reference, or funding extrinsic. [`../conjectures_subnet/db/public.py`](../conjectures_subnet/db/public.py) is the only query layer these endpoints use, and its row types have no column for those three payment values — a router cannot leak what it was never handed. The **outgoing** payout is published, by product decision: a rewarded result carries `payout`, with the amount, the chain time and a taostats link per finalized transfer, so "paid out" can be checked on chain. The explorer page shows the destination coldkey, which may be the account's payout coldkey; that is accepted. See [The payout behind a result](#the-payout-behind-a-result). > Publishing a solver identity weakens the activity pseudonyms below, and the two are no longer > independent. A verified result names its solver and carries `verified_at`; an activity event > carries the same transition, on the same conjecture, at hour resolution. Matching them names the > solver behind a pseudonym — and then that solver's failed attempts on that conjecture too. The > pseudonyms still protect solvers with no verified result, and nothing more than that. **Proof bytes only after approval.** `Main.lean` is served by `GET /v1/results/{id}/solution`, and only once review has approved the submission. An in-review result carries no artifact: the proof has passed the Lean kernel but not the reward decision, and publishing it before that decision would hand a pending result to anyone who wanted to resubmit it elsewhere. Approval *is* that decision, so the gate is approval rather than payout — a confirmed transfer is not a disclosure question. The check lives in `accepted_solution` in [`../conjectures_subnet/db/public.py`](../conjectures_subnet/db/public.py), i.e. in the query, so a handler cannot serve an unapproved proof by forgetting it. Both "not approved yet" and "not published at all" answer `404`, so the endpoint cannot be used to detect a pending submission. `PublicResult.solution_available` says which rows have one, so a client does not discover it by collecting `404`s. **Only the reviewed public rationale crosses the review boundary.** A certified `PublicResult.review` contains the binding outcome, reason code, policy version, decision time, and `notes_public`. The database's internal `notes`, reviewer identity, and raw advisory-agent `evidence` are not selected by the public query layer and therefore cannot be serialized by the router. An in-review result has no binding review and returns `review: null` on response shapes that include the field. **No verifier output.** The public report is built by *allowlisting* fields (`PUBLIC_REPORT_FIELDS` in [`../submission_api/routers/results.py`](../submission_api/routers/results.py)), not by removing the sensitive ones. What that buys is the default: a field added to `VerificationReport` later is withheld until someone deliberately adds it to the allowlist. | Withheld | Why | | --- | --- | | `stdout_tail`, `stderr_tail` | Lean's output quotes the submitted proof back verbatim | | `submission_sha256` | `submissions.proof_digest` is globally `UNIQUE`, so publishing it would let anyone test a candidate proof for prior submission and get a definitive answer | | `workspace_retained`, `comparator_exit_code` | Operator debugging detail; says nothing about the result | | `problem_id` | The per-revision identity of the conjecture. It moves on every pin rotation, so publishing it in a report would invite a client to key on it; the response's own `slug` is the stable identity, and `ConjectureDetail` publishes `problem_id` alongside it for anyone who needs the revision-specific name | `report_sha256` is the digest of the **full** report, not of the reduced projection, so it still matches the immutable bytes on the run and the copy the submitting miner can read. A submission that has not passed Lean is `404`, never `403`. Distinguishing "not published" from "does not exist" would turn `/v1/results/{id}` into a probe for the state of work that has not been published yet. That is unaffected by the dashboard feed listing every submission: the feed publishes each row's *state*, while the by-id read stays restricted to Lean-verified work, whatever manual review later decides — see [The dashboard feed is unfiltered](#the-dashboard-feed-is-unfiltered). ## Conjectures ### The slug is stable, and it is not the task id A slug appears in a website URL, so it gets bookmarked, cited and indexed. It has to outlive what produced it. `task_id` cannot do that job — it is seeded with the pinned source revision, twice: ``` fc-{repository_commit[:8]}-{task_slug(theorem)}-{digest}-{mode}-v{adapter_version} ``` where `digest` hashes the commit as well. Under the weekly drain-and-rotate pin policy, **every task id in the pool changes on every rotation**, even for a conjecture whose statement, docstring and Lean bytes are byte-identical. A URL built from one would break weekly. So the slug is derived from `reward_target_id` (`fc-target:`), which names the bounty rather than the build — see [`../submission_api/slugs.py`](../submission_api/slugs.py). That identity is not new: `verifier.task_pool` already mints it so a re-pin cannot pay the same theorem twice. This extends it to the URL space, where the durability requirement is the same. `Erdos11.erdos_11` → `erdos11-erdos-11`. The *whole* dotted path is used, unlike `task_generator.task_slug` which keeps two segments — safe inside a task id because a digest disambiguates there, unsafe here. Two consequences, both deliberate: * **A refined statement keeps its URL.** If upstream tightens a theorem's phrasing, the page updates and the link still works. A reader following a years-old link about Erdős 11 wants the current Erdős 11, not a 404 next to a new page. * **Stability rests on the upstream theorem name.** A rename upstream moves the slug. Far rarer than a weekly pin, but derivation gives no recourse; the durable fix is an explicit slug alias table, which is not built yet. Slug uniqueness is checked, not assumed. Slugification is lossy — `A.b_c` and `A.b.c` both reduce to `a-b-c` — so the grouping refuses to start on a collision. A startup failure during a rotation is bad; serving one conjecture at another's cited URL is worse. **Task-id URLs are redirected, not 404ed.** A `GET` on a task-id-shaped slug answers `301` to the stable slug, preserving the `/activity` suffix. Two callers need this: a link minted before slugs existed, and a solver who pasted an id out of a bundle or a report. It works for task ids from *past* rotations too, because the theorem fragment inside a task id does not depend on the commit. An ambiguous fragment answers `404` rather than guessing — a wrong redirect is worse than a dead link. ### One entry per conjecture, not per task Every theorem is issued as one task per production mode: `formalized` to prove it, `counterexample` to refute it. Listing tasks would show each conjecture twice, with two unrelated ids and near-identical statements, and would make `attempts` mean attempts in one direction. So both fold into one conjecture, and the per-task facts live under `tasks`: | Level | Fields | | --- | --- | | Conjecture | `slug`, `title`, `statement`, `summary`, `category`, `classification`, `tier`, `ams_subjects`, `is_open`, `problem_id`, `reward_target_id`, `task_modes`, `attempts`, `display_status`, `accepting_submissions`, `added_at`, `solved_at`, and on the detail endpoint `submissions_open`, `source_url` and `source_patched` | | Task (one per direction) | `task_id`, `task_mode`, `task_bundle_sha256`, `attempts`, and on the detail endpoint `challenge_lean`, `bundle_url` and `machine_contract` | `meta.conjectures` counts conjectures, so it is half what a task count would report. `attempts` at the conjecture level counts submissions in either direction, and it is keyed on `reward_target_id` — so it does not reset to zero at each rotation, which a task-keyed counter would. The per-task `attempts` keeps the breakdown a solver choosing a direction actually wants. ### One index entry per problem, not per conjecture `GET /v1/catalog/index` groups one level coarser than everything above. Upstream formalises a problem as a root theorem plus any number of `.variants.*` siblings — weaker forms, one-sided bounds, named special cases — and each of those is its own reward target, its own slug and its own bounty. Correct for a bounty list, wrong for a table of contents: Erdős 1 alone is eight rows. So the index reports one entry per *problem*, keyed on the root theorem the family shares: ```json { "total": 4, "repository_commit": "e923379e…", "items": [ { "slug": "erdos1-erdos-1", "display_title": "Erdős problem 1", "title_parts": { "collection": "erdos_problems", "collection_label": "Erdős problems", "reference": "1", "qualifier": null }, "source_theorem": "Erdos1.erdos_1", "erdos_problem_number": 1, "qualifier": null, "retired": false, "variants": [ {"slug": "erdos1-erdos-1-variants-lb", "task_mode": "formalized", "retired": false}, {"slug": "erdos1-erdos-1-variants-lb", "task_mode": "counterexample", "retired": false}, {"slug": "erdos1-erdos-1-variants-real", "task_mode": "formalized", "retired": false}, {"slug": "erdos1-erdos-1-variants-weaker", "task_mode": "formalized", "retired": true} ] } ] } ``` Five details, each forced by what the pinned catalog contains: * **`erdos_problem_number` is read from the module, never from the theorem name.** Upstream files each Erdős problem under `FormalConjectures.ErdosProblems.«N»`, and all 509 such modules match that shape. Twenty theorem *names* are mangled by Lean's private-declaration scheme into `_private.FormalConjectures.ErdosProblems.«1049».0.Erdos1049.lambert_convergent`, which a name parser reads wrong rather than not at all. It is null for every other collection — Wikipedia, OEIS, the Millennium problems — because "not an Erdős problem" is an ordinary thing for a conjecture to be, and null for an unrecognised module shape too: publishing no number is recoverable, publishing a wrong one is not. * **`erdos_problem_number` is not a key.** 934 problems carry one and only 509 are distinct, because upstream regularly formalises one problem as several independent root theorems in one module. `slug` is the identity. * **`title_parts.reference` is the same idea for the other fifteen collections.** Every collection identifies its problems and only one of them does it with an Erdős number, so `reference` carries `1`, `A228828`, `2303.01089`, `17th` or `Collatz Conjecture` as the collection requires, and is never null. `erdos_problem_number` stays exactly as it is — it is typed `int`, which `reference` cannot be. See [Display titles](#display-titles-and-why-title-is-not-one). * **`qualifier` says when a variant is standing in for its problem.** It is null when the root theorem is itself in the pool. 241 of the catalog's 942 variants have no root declaration at all, leaving 70 problems headed by a variant; there the best-precedence variant represents the problem — see below — and `qualifier` names it. Qualifiers are kept whole, dots included — upstream nests the qualifier, not the variant, so `…variants.monotone.parts.i` qualifies as `monotone.parts.i`. * **`variants` is one row per attack direction, and never contains `slug` itself.** A variant that can be both proved and refuted appears twice with the same slug and a different `task_mode`, because a slug alone does not say which direction has a task issued against it. A problem with no pooled variants reports `[]`. * **Retired conjectures are included, flagged at both levels.** This is the one catalog list that shows them, and the reason is that it is a table of contents rather than an offer: a problem that has left the pool is still part of what the pool has covered, its detail page is still readable, and the results earned against it are still citable. An index that omitted them would disagree with the pages it links to. `retired` is what keeps their presence from reading as an offer. ### `retired` describes one conjecture, never a family `retired` on an entry is about the conjecture at `slug` and nothing else. **Do not filter problems on it.** A problem whose root has been retired can still hold submittable variants: ```json { "slug": "erdos99-erdos-99", "source_theorem": "Erdos99.erdos_99", "erdos_problem_number": 99, "qualifier": null, "retired": true, "variants": [ {"slug": "erdos99-erdos-99-variants-weak", "task_mode": "formalized", "retired": false} ] } ``` Dropping that row loses a target that is still open. To list what can be attempted, read the members' own flags. A retired root still heads its family, which is the deliberate half of this. Handing the header to a live variant instead would move the entry's `slug` and `source_theorem`, so retiring one target would silently renumber a published table of contents — the opposite of what a stable slug is for. The header stays put and `retired` reports what happened to it. Precedence within a family is the root theorem first, then a live conjecture before a retired one, then slug; `variants` is ordered by slug alone, so retiring a variant does not reorder a list a reader has already seen. Nothing here widens admission. `TaskCatalog` is built from `allowlist.json` alone and never consults the retired index, so a retired slug published here resolves to nothing on the grouping the submission path uses — and a retired conjecture has no `MachineContract`, so there is not even a shape in which a submission for one could be assembled. See [`../submission_api/retired.py`](../submission_api/retired.py). The index is whole by default, and it is the one catalog endpoint that reads no database at all — not even the attempt counters. It is a grouping of the startup index into a few hundred rows of identifiers, with no statement, no Lean and no bounty quote, so the work is bounded by the pool rather than by the caller. `limit` and `offset` cut a window from it for a client that renders it a screen at a time; `total` always counts the whole pool. Follow a slug to `/v1/catalog/conjectures/{slug}` for any of those. ### Display titles, and why `title` is not one `title` is the fully-qualified source theorem — `Erdos1.erdos_1.variants.lb` — which is the right thing to cite and the wrong thing to put in a heading. **Render `display_title` instead.** It is published on every surface that publishes `title`: | Endpoint | Contract | | --- | --- | | `GET /v1/catalog/conjectures` | `ConjectureSummary` | | `GET /v1/catalog/conjectures/{slug}` | `ConjectureDetail`, retired targets included | | `GET /v1/catalog/index` | `ConjectureIndexEntry` | | `GET /v1/results/certified`, `/submissions`, `/{id}` | `PublicResult` | | `GET /v1/results/in-review` | `InReviewResult` | ```json { "display_title": "Erdős problem 1 - lb", "title_parts": { "collection": "erdos_problems", "collection_label": "Erdős problems", "reference": "1", "qualifier": "lb" }, "title": "Erdos1.erdos_1.variants.lb" } ``` **No client should need to parse `title`.** That is the guarantee, and it is checked rather than asserted: a test sweeps all 3267 declarations in the pinned catalog and fails if any `display_title` carries an underscore, a guillemet or a camel hump. A hand-rolled parser gets the common shapes and leaves `maximalLength_ge_of_isSquare` in the UI for the rest — including the twenty theorem names Lean mangles into `_private.FormalConjectures.ErdosProblems.«1049».0.Erdos1049.lambert_convergent`. **Derived, never invented.** Every character comes from the audited module path or theorem name; the derivation only inserts spaces and joins with a phrase naming the collection. `«17»` under `HilbertProblems` reads "Hilbert's 17th problem"; `CollatzConjecture` reads "Collatz Conjecture". Upstream publishes no human titles, so there is none to publish, and supplying one from outside the catalog would put a name on the website that appears in no audited artifact — which is the same reason `title` is not prose. See [`../submission_api/naming.py`](../submission_api/naming.py). | `title` | `display_title` | | --- | --- | | `Erdos1.erdos_1` | Erdős problem 1 | | `Erdos357.erdos_357.variants.monotone.parts.i` | Erdős problem 357 - monotone, part i | | `Hilbert17.hilbert_17th_problem` | Hilbert's 17th problem | | `OeisA228828.a_0` | OEIS sequence A228828 — a 0 | | `Arxiv.«0912.2382».curling_number_conjecture` | Curling Number Conjecture (arXiv:0912.2382) | | `CollatzConjecture.collatz` | Collatz Conjecture | | `ComplexityTheory.P_ne_NP` | P vs NP — P ne NP | **Not an identity.** `display_title` names the *problem*, and upstream files several root theorems for one problem, so a handful share a title — 12 collisions across 2467 pool-eligible declarations, each a pair distinguished only by a middle Lean namespace segment. Sort, group and link on `slug`. **`title_parts` is the same name unassembled**, for a client that wants its own wording: `collection` is a stable lower_snake_case key safe to switch on, `collection_label` is it in words, `reference` is how the collection identifies this problem, and `qualifier` is the text after the em dash. A collection added upstream is keyed by its own name and still reads as words rather than becoming an error or an identifier. Two things to know about nulls. On the problem index, `title_parts.qualifier` is *not* the entry's own `qualifier` — that one stays the raw `.variants.` fragment the index has always published, and this one is it in words. On a result feed, `title_parts` is null for the one class of row whose reward target names no conjecture in any pin, where `display_title` degrades to the slug — see [A result keeps its conjecture's name](#a-result-keeps-its-conjectures-name-after-the-target-is-withdrawn). ### The rest of a conjecture `ConjectureDetail` carries both halves. The human half is `summary` (the source docstring) and `statement` (Lean's pretty-printed type), with `display_title` above as the heading. `title` remains the fully-qualified source theorem: an identifier a mathematician can cite, and the string that matches a verifier report's `source_theorem`. Each task's `challenge_lean` is the exact `Challenge.lean` whose bytes are hashed into that task's published `task_bundle_sha256`. It is held in memory from startup, not re-read per request, so the published statement cannot drift from the audited one between boot and a request — and a reader can verify it against the commitment without trusting the response. ### References are split, not shipped as Markdown Each entry in `references` is a `{label, url}` pair, so a client renders a link without parsing Markdown. The upstream bibliography records a free-form citation that *may contain* a Markdown link rather than a string that is one, so the link is searched for wherever the citation puts it: | Upstream entry | `label` | `url` | | --- | --- | --- | | `[erdosproblems.com/11](https://www.erdosproblems.com/11)` | `erdosproblems.com/11` | `https://www.erdosproblems.com/11` | | `[Er46](https://doi.org/10.2307/2305092) Erdős, P. On sets. (1946)` | `Er46 Erdős, P. On sets. (1946)` | `https://doi.org/10.2307/2305092` | | `Leinster, Tom (2001). [arXiv:math/0104012](https://arxiv.org/abs/math/0104012)` | `Leinster, Tom (2001). arXiv:math/0104012` | `https://arxiv.org/abs/math/0104012` | | `Arora, Sanjeev, and Boaz Barak. Computational complexity. Cambridge, 2009.` | *(verbatim)* | `null` | `label` is the whole citation with every link flattened to its own text, so no words are lost and no Markdown link syntax reaches a client. `url` is the **first** link's target — a few entries cite both a paper and its arXiv mirror, and one field holds one address. `url` is `null` for the ~40% of entries with no link, including the handful whose parenthesised part is prose (`[Kanold](No references found)`) rather than an address; those keep their text verbatim rather than being handed a fabricated link. Emphasis markers (`*…*`) and inline TeX are left as the bibliography wrote them. `machine_contract` is the solver-facing contract: the identifiers the proof must define, the axioms it may depend on, the imports it may not use, the stable `reward_target_id`, and the limits it is checked against. The reward identifier belongs to one exact theorem target and is shared only by its proof/refutation pair and later source repins. Parents, parts, and variants have independent identifiers and independent rewards. A solver that satisfies the contract offline is checked against the same values on submission. Each conjecture carries a live `bounty` object. `amount_rao` is null when `available` is false; `amount_usd` is a TaoStats-backed decimal string rounded to cents, or null when the bounty or the external rate is unavailable. It is `(amount_rao / 1e9) * alpha_price_tao * tao_price_usd`; the Alpha amount remains authoritative when this display-only conversion is absent. `reason` distinguishes an open target from one already solved, and `locked` is false because catalog prices remain live until a submission is accepted. The pool-wide `/v1/catalog/meta` response publishes `bounty.balance_rao` and its display-only `bounty.balance_usd` conversion, plus the open-target count, rational starting share for newly opened targets (`constant_numerator` / `constant_denominator`), `ramp_seconds`, and rational maximum share. Under `linear-age-v3-locked`, each quote starts at the share its target opened with (1/40 for new targets, 1/20 for targets opened before V044; the quote's inputs carry it) and increases linearly to 1/8 after 1296000 elapsed seconds (15 days). `total_age_weight` and `max_age_weight` remain as legacy descriptive metadata; they do not affect this formula. Quotes use the target's original opening date and the minute-resolution `as_of`. Existing locked submissions retain their recorded amount, version, and inputs. Acceptance takes a serialized fresh quote, subtracting outstanding locks from the treasury balance, and fixes that amount for the submission. `bounty.reason` is one of `OPEN`, `CLAIM_HELD` (the caller's own submission holds it; only on a caller-specific quote, never in the catalog), `ALREADY_SOLVED`, `NOT_IN_BOUNTY_POOL`, `TREASURY_RESERVED` (the treasury is fully committed, so the amount is zero and intake refuses), `CHAT_LOG_REVIEW_UNAVAILABLE` (chat logs are required and their review is off, so intake refuses) and `WITHDRAWN` (retired; see `retirement`). The OpenAPI document publishes it as an enum, as it does every status on this surface. ### Status, dates and links Each list item and detail page carries the one status a client renders, so no client re-derives it from `is_open`, `bounty.reason` and the system switch: | `display_status` | Means | Where it comes from | | --- | --- | --- | | `open` | Accepting submissions with a funded bounty | `OPEN` (or `CLAIM_HELD`) | | `in_review` | A Lean-verified submission awaits the reward decision | the review queue, per target | | `solved` | Review approved a submission here, which now holds the target | `ALREADY_SOLVED`, or a retirement coded `SOLVED` | | `formalization_defect` | Review approved a proof or refutation that went through a defect in the formal statement: the target is closed, but the conjecture is not solved | `ALREADY_SOLVED` whose approval is `FORMALIZATION_DEFECT_AWARD` | | `solved_elsewhere` | Closed because the problem was resolved outside this platform | retirement codes `SOLVED_EXTERNALLY`, `OWNER_ACCEPTED_PUBLICATION_CLOSURE`, `PRIOR_PUBLIC_PROOF` | | `withdrawn` | Permanently left the pool for another reason | any other retirement | | `on_hold` | Admission suspended pending review; neither solved nor retired | `pool_status: held` | | `unfunded` | Open, but the treasury has nothing to offer, so intake refuses | `TREASURY_RESERVED` | | `submissions_paused` | Submissions are off, platform-wide or for this target | `SUBMISSIONS_PAUSED`, or `CHAT_LOG_REVIEW_UNAVAILABLE` | For a live target the first match wins, in the order solved / formalization_defect, in_review, submissions_paused, unfunded, open. The list carries live targets only, so `solved_elsewhere`, `withdrawn` and `on_hold` appear only on a retired or held detail page. The list response also carries top-level `submissions_open`, the same value as `/v1/system/status`, so the catalog needs no second request; the detail page carries it too. **Whether to offer a submit action is `accepting_submissions`, not `display_status`.** The status shows the strongest fact about a target, and `in_review` outranks the reasons intake refuses: a target can read `in_review` while its bounty is `CHAT_LOG_REVIEW_UNAVAILABLE`. A proof awaiting review does not close a target, so on an `in_review` target intake takes another submission when `accepting_submissions` is true; if the earlier proof is approved, the later one earns no bounty. `accepting_submissions` is `submissions_open` and `bounty.available` together, the checks intake makes before it looks at the caller. It leaves out what depends on the caller — credits, a linked coldkey and, when the bounty's `policy_version` is `linear-age-v3-chat-logs`, a chat-log deposit made beforehand — and is always false on a retired or held target. `added_at` is when this API first listed the target. It survives pin rotations and restarts and is the right key for "new"; it is not a pin date, because pins carry none. `solved_at` is when review approved the submission holding the target — **solved means approved, not paid**; the payout time is the result's `certified_at`. It is null unless `display_status` is `solved` or `formalization_defect`. A correction that rejects and later re-approves restarts it. The detail page also links what the server loaded, so no client assembles a URL: - `source_url` is the Lean file in the upstream repository at `pins[].base_commit`, the upstream commit the audit patch is applied to. Not at `repository_commit`: that commit is derived locally by applying the patch and does not exist upstream, so a link to it 404s. `source_patched` is true when the audit patch changes that file, i.e. the upstream statement can differ from the audited one served here; `source_url` is null for a file the patch creates. Both are null when the server could not verify the pinned patch against its digest. - Each task's `bundle_url` is the bundle's directory in the tasks repository at the pinned tasks commit (`pins[]` now includes `tasks`). It is taken from where the loader found the bundle — a bundle directory is not derivable from its task id, and versioned tasks live under `versions/` — and is null on a retired conjecture, whose bundle was deleted. ### Filters and facets `category`, `classification`, `task_mode`, `tier` and `ams_subject` are repeatable and ANDed across fields, ORed within one. A conjecture matches `task_mode` if any of its tasks does. `is_open` is its own boolean, and `q` is a case-folded substring test over the slug, **every task id**, the theorem, module, statement and docstring — so pasting an identifier from a report or an old URL into the search box finds its conjecture. A substring test and not a pattern, so a catastrophically backtracking regular expression is data rather than free CPU. `ams_subject` is an integer: the top-level MSC classification, `0`–`99` (the pinned pool uses 3 through 94). The four string filters accept values up to 64 characters. Every repeatable filter may appear at most 64 times per request; a value outside its range, an unparseable integer, or a 65th repetition is a `400 MALFORMED_REQUEST`. Facet counts follow the usual faceted-search rule: each facet is counted over the results matching every filter **except its own**. Without that, selecting `category=research open` would collapse the category facet to one row and a reader could filter in but never out. Paging is `limit` (capped at 500, so the whole pool fits one page) and `offset` (capped at 10000). Offset paging is safe here and only here: the catalog is a fixed list of a few hundred entries held in memory, so there is no scan to amortise and no insert to shift the window, and the database work per request does not grow with `limit`. ## Paging Every endpoint that returns a list pages, in one of three ways, chosen by what is underneath: | Scheme | Parameters | Used by | Why | | --- | --- | --- | --- | | Signed keyset cursor | `limit`, `cursor` → `next_cursor`, `total` | the result feeds; every account and admin feed | A database table that grows between reads. See [Result feeds](#result-feeds) | | Offset over a snapshot | `limit`, `offset` → `total` | the catalog listing, the index, `/v1/tasks`, the contribution mirror, the competitions list | Immutable and in memory, so a slice is free and nothing shifts between pages | | Bounded offset | `limit`, `offset` → `next_offset` | conjecture activity | See [Activity](#activity) | A snapshot list that has always been served whole — the index, `/v1/tasks`, one target's contributions, the competitions list — still is when `limit` is omitted, so a client that reads it in one request is never cut short. The listings that were already paginated (`/v1/catalog/conjectures` and the `OffsetPage` contribution routes) keep their default page size. ## Result feeds Cursor-paginated, newest first: ``` GET /v1/results/certified?limit=25 → { "items": [...], "next_cursor": "MS4xNzU0MjI…" } GET /v1/results/certified?limit=25&cursor=MS4xNzU0MjI… → { "items": [...], "next_cursor": null } ``` `next_cursor` is null exactly when the feed is exhausted — the handler reads `limit + 1` rows and discards the extra — so a client loops until null rather than making a wasted request to discover the end. `total` counts the whole feed under the same filters, as of the moment the page was read. It is for "page 3 of 12", not for deciding when to stop: a submission landing between two reads changes it, so loop on `next_cursor`. This was once left out on purpose, because a count on every page read is work an anonymous caller can ask for. It is affordable now because each feed counts over an index on a table of thousands of rows, and the public feeds are cached for half the catalog window. ### Filters All three feeds take `slug`, for one conjecture's results (live or retired; an unknown slug is a `404`, not an empty page), and `q`. `q` matches the conjecture the way `/v1/catalog/conjectures?q=` does, the solver's coldkey by prefix, or the solver's display name; `%` and `_` are literal. `/v1/results/submissions` also takes `verification_status`, `manual_review_status` and `reward_status`, in the vocabulary its items carry. Filters narrow the items and `total` together, and a cursor carries only a position, so a client repeats the filters with every cursor. ### Stats `GET /v1/results/stats` returns `submitted`, `verified`, `in_review`, `certified`, `paid_out_rao` and `paid_out_usd`, optionally for one `slug`. `in_review` and `certified` use the conditions of the feeds of the same name, so they equal those feeds' `total`. `paid_out_rao` sums the latest confirmed, chain-observed payout of each certified result, which is the amount each result reports. `paid_out_usd` is `"0.00"` when nothing has been paid, and null only when there is a payout but no Alpha price to convert it at. **Keyset, not `OFFSET`.** The predicate is a row-value comparison `(created_at, id) < (cursor)` over an index built for the feed — partial for the two narrow ones ([`../deploy/migrate/sql/V002__public_feeds.sql`](../deploy/migrate/sql/V002__public_feeds.sql)), full for the unfiltered dashboard feed ([`../deploy/migrate/sql/V010__dashboard_feed_index.sql`](../deploy/migrate/sql/V010__dashboard_feed_index.sql)) — so it reads one index range whatever page you are on. `OFFSET 50000` reads and discards fifty thousand rows. It is also correct under concurrent inserts, which an offset is not: a result certified between two page reads shifts every subsequent offset by one and silently hides a row. The pair rather than the timestamp alone because `created_at` is not unique — two submissions committed in one transaction share it. **Cursors are opaque and signed.** The contents are not secret; the HMAC is there so the handler never parses an attacker-chosen value into a query predicate, and so a tampered cursor is one clean `400 INVALID_CURSOR` rather than a database error. Every failure mode returns the same reason code: a client learns nothing about whether it was the shape or the signature that was wrong. `certified` means paid out — `reward_status = 'REWARDED'` with the review approved. The payout watcher is the only automatic path to `REWARDED`, and it writes that state atomically with a matching `StakeTransferred` event from a finalized block — or the retired `StakeAndHotkeyTransferred` for a payout made before V035, which the watcher still decodes so historical rows stay reconcilable. A prepared command or a best- chain event is not certified. The feed also requires the confirmed reward row's chain-observation provenance, so a legacy or manually edited paid flag cannot certify a result. `in-review` means Lean-verified and awaiting the reward decision. Every `PublicResult` carries the amount of record, `bounty_amount_rao`, and a current `bounty_amount_usd` display conversion using the same formula as catalog bounties. The USD value is null when TaoStats is unavailable and is not a historical fiat valuation of the payout; for that, read `payout`. `credited_name` is the one name to credit a result to: `public_credit.name` when the submitter signed one, otherwise `solver_display_name`, otherwise null. It is never the coldkey, which wants different rendering and stays its own field. Every result shape carries it. ### The payout behind a result A rewarded result carries what the treasury actually paid: ```json { "reward_status": "REWARDED", "bounty_amount_rao": 412000000000, "payout": { "amount_rao": 412000000000, "amount_usd_at_payout": "118.40", "paid_at": "2026-09-12T09:01:44Z", "extrinsic_url": "https://taostats.io/extrinsic/5891203-0012", "transfers": [ { "amount_rao": 412000000000, "paid_at": "2026-09-12T09:01:44Z", "extrinsic_url": "https://taostats.io/extrinsic/5891203-0012" } ] } } ``` `payout` is null unless `reward_status` is `REWARDED` with a finalized, chain-observed payout — the evidence `certified_at` rests on; never from a best-chain observation or an operator's paid flag. Amounts are Subnet 66 Alpha base units. `amount_rao` is what was paid, which can differ from `bounty_amount_rao` (a later payout instruction changes the amount of record, not the payment). `paid_at` and each transfer's time are the block's timestamp. A multisig payout links the final approval extrinsic that executed it. A payout split between co-solvers is several transfers: `transfers` lists each, `amount_rao` is their sum, and the top-level `extrinsic_url` is null because one link cannot name them all. A transfer recorded without a chain position (a legacy row with a free-text reference) has a null link rather than a guessed one. `amount_usd_at_payout` values each transfer at the Alpha/USD price the payout watcher recorded when it saw that transfer, which it does only while the transfer is at most ten minutes old. It is null for every payout recorded before this field existed, for one the watcher saw late, and for any deployment whose watcher has no `TAOSTATS_API_KEY`. No historical price is backfilled. For a reviewed result it also carries the latest binding decision: ```json { "review": { "decision": "APPROVED", "reason_code": "FORMALIZATION_DEFECT_AWARD", "notes_public": "Lean verified the published task, but the formal statement did not match the informal conjecture.", "policy_version": "v1", "decided_at": "2026-08-05T21:00:00Z" } } ``` `notes_public` is null for a historical or automatic decision that has no publishable rationale. It is never populated from the internal `notes` field. ### The dashboard feed is unfiltered `/v1/results/submissions` lists **every** submission, whatever state it reached: queued, running, rejected, in review, certified. It is not the union of the two feeds above. A dashboard reports the pipeline, and one that dropped an attempt on rejection would show a reader only the successes and read as the complete history. Three fields say where each row got to, using the same vocabulary as the miner-facing `GET /v1/submissions/{id}`: | Field | Values | | --- | --- | | `verification_status` | `UNVERIFIED` (queued or running), `VERIFIED`, `REJECTED` | | `manual_review_status` | `UNREVIEWED`, `APPROVED`, `REJECTED` — `APPROVED` covers both a human approval and the recorded automatic decision when manual review is disabled | | `reward_status` | `INELIGIBLE`, `ELIGIBLE` (owed, not yet paid), `REWARDED` (confirmed on chain), `FAILED` | One response model for every state, so a client reads one shape and branches on those fields and on the nullable timestamps rather than on which of several models it got back. `verified_at` is when the verifier finished, whatever the verdict — a rejected submission carries it too, since Lean did run and did reach one — and `certified_at` is null until a payout confirms. **Being listed is not being published.** Widening the feed publishes *that* an attempt exists and where it got to, and nothing else. The artifact gates are unchanged and are enforced in the query, not by this feed: `solution_available` is still false until review approves, and `report_available` is true after Lean verification, whatever manual review later decides. `GET /v1/results/{id}` and `/report` follow that same gate; `/solution` is stricter and additionally requires approval. All three still answer `404` for queued or Lean-rejected ids, while a review-rejected result has a record and report but no solution. So an id alone is still not a probe for the state of unpublished work. Payout is deliberately not part of this publication gate: an approved result stays readable while its reward is `ELIGIBLE`, and only enters the certified feed after the transfer is confirmed. `review` is the exception, and deliberately so: a review-rejected row on this feed carries its binding decision and `notes_public`, because a rejection whose published rationale is withheld is the one state a dashboard cannot explain. That discloses nothing extra — `ReviewRow` in the query layer is an allowlist, so the reviewer's identity, the internal `notes` and advisory `evidence` are not selected for any row, rejected or not. One side effect to know about: a failed attempt's existence and timing are now public, so the activity pseudonyms are weaker for any solver who appears on a feed. They were already correlatable through verified results — see the caveat under [Activity](#activity). A result carries both identities: `slug` names the conjecture, `task_id` names the task it was produced against. The slug is derived from the row's own `reward_target_id` rather than looked up in the catalog, so a result produced under an earlier pin still links to the live conjecture page instead of to a task id the current pool no longer carries. ### A result keeps its conjecture's name after the target is withdrawn `display_title`, `title` and `statement` on every result — `/certified`, `/in-review`, `/submissions` and `GET /v1/results/{id}` — are resolved by slug through the live catalog index and then the [retired](#retired-describes-one-conjecture-never-a-family) one, which is the same two-step `GET /v1/catalog/conjectures/{slug}` takes. So a result against a withdrawn target is named after the theorem it closed, and named identically to the conjecture's own page. Retiring a target deletes its bundles; it does not rename the conjecture, and it must not relabel work already earned against it. `title` is the fully-qualified source theorem, exactly as on the conjecture detail endpoint — an identifier to cite, not prose. See [Display titles](#display-titles-and-why-title-is-not-one) for what to render instead. One case degrades: a `reward_target_id` that resolves to no conjecture in either index. Those are pre-`V004` rows whose reward target was backfilled from the raw `problem_id` because the migration did not recognise it. They name nothing in any pin, so `display_title` and `title` fall back to the slug, `statement` is an empty string, and `title_parts` is null rather than invented — a public feed must not fail over one historical row, and there is no name being withheld. ## Activity `GET /v1/catalog/conjectures/{slug}/activity` answers "is anyone working on this" without answering "who" — but only for a solver who has no verified result on that conjecture. Since the results feed names the solver, the properties below hold against a reader who works only from this endpoint, not against one who joins it to `/v1/results` on `verified_at`. Read this section as the construction's design, not as a guarantee the surface as a whole still makes. `solver` is `HMAC(PUBLIC_ACTIVITY_SALT, len(reward_target_id) || reward_target_id || len(identity) || identity)`, where `identity` is the signing coldkey, or the account id for a session-authorised submission, or the historical hotkey for a row predating V035 — one definition, shared with the distinct solver count so the two cannot disagree, truncated to 12 hex characters. Two properties follow from where the conjecture's identity sits: * **Stable within a conjecture.** Repeat attempts read as the same solver, so `solvers` is a meaningful count of distinct participants. * **Unlinkable across conjectures.** The conjecture's identity is inside the MAC, so the same miner gets a different pseudonym on every conjecture and the pseudonyms cannot be joined across the catalog to rebuild one miner's history. Length-prefixed, so `(conjecture, key)` pairs cannot be chosen to collide by shifting the boundary between them. **Paged by offset, not by cursor.** The stream pages with `limit` and `offset`, newest first, and `next_offset` is null at the end. A keyset cursor would be the obvious choice, and it is ruled out by what a cursor carries: the signature stops tampering but hides nothing, so a cursor over `(created_at, id)` would publish each event's exact timestamp and submission id — the precision `occurred_at` is truncated to the hour to withhold. The offset reaches only the newest 500 events (`MAX_ACTIVITY_ROWS`), which keeps it from becoming a way to make the database skip an arbitrary number of rows; `attempts`, `solvers`, `verified` and `certified` always count the whole history. Keyed on `reward_target_id` rather than on a task id, matching the stream itself. A task-keyed MAC would give one miner two pseudonyms on a page that shows both attack directions — making one person look like two, and inflating `solvers` — and would rename every solver at each pin rotation. `occurred_at` is truncated to the hour. An attempt is funded by a transfer that is visible on chain with its sender at a known block time; a per-second timestamp would let anyone join the two and undo the pseudonym. An hour bucket makes that join ambiguous whenever more than one transfer landed in the hour, and costs a reader nothing. `PUBLIC_ACTIVITY_SALT` is therefore load-bearing, not decorative. An SS58 address is a 48-character address from a known alphabet, so an unsalted digest — or one salted with the constant published in `settings.py` — is reversible by enumeration for anyone holding a list of subnet addresses. Production refuses to start with either. `event` is the furthest state the submission has reached (`attempt`, `rejected`, `verified`, `certified`) rather than a per-transition stream, because the schema keeps current state and not transitions. Saying `attempt` for a submission that has since been certified would be wrong. ## System status `submissions_open` is authoritative, not descriptive. `SUBMISSIONS_PAUSED` is read by `POST /v1/submissions` too, which refuses with `503 SUBMISSIONS_PAUSED` while it is set. A status endpoint that reported a pause the intake path did not honour would be worse than no status endpoint, because a solver would trust it and spend a payment. `pin_rotation` is the weekly drain-and-rotate window from [../README.md](../README.md#pins-cache-and-reproducibility): operators pause submissions, wait for every accepted submission to reach a terminal state, then update the pin set atomically. The window is configured — only the operator knows when they take the system down — but `drained` is computed from the queues, because whether the window may actually start is a fact, not a setting. `status` is `paused` when submissions are closed, `degraded` when a rotation window is in progress while submissions are still open (the policy says those should not coincide, and an operator should see the disagreement rather than have it smoothed over), and `ok` otherwise. Never cached: this is the endpoint a client polls to learn whether what it was told is still true. ## Contributions A *contribution* is partial Lean that helps someone else finish a target — a lemma, a definition, an API, a special case. Contributions are not solutions: a solution is a paid submission to this validator, and appears in the result feeds above. Contributions live in a separate public repository, [`conjectures-io/conjectures-contribution`](https://github.com/conjectures-io/conjectures-contribution), which this API mirrors. ### It is a mirror, and it says so `/v1/contributions/meta` publishes the commit the served snapshot was read at, when it was fetched, its age, and whether that age has passed `CONTRIBUTIONS_STALE_SECONDS`. Read it before trusting a listing. Two failure modes are reported rather than hidden: * **`503 CONTRIBUTIONS_UNAVAILABLE`** — the corpus has never been read. Every endpoint refuses, rather than serving `items: []`. "Nothing has been contributed" is a claim about the repository; "we have not read the repository" is a claim about this process, and publishing the second as the first is the one mistake worth a status code. * **`meta.unreadable_targets`** — target indexes that failed to parse and are therefore missing from every listing. A non-zero value means the answer is incomplete, and an empty result for a target is not evidence that nothing is on it. A GitHub outage makes the listing *stale*, never slow and never empty: requests are answered from the last good snapshot, and a failed refresh leaves it in place. ### Two naming schemes, one join The contribution repository names targets with its own pool slug, `erdos-535`. This API names conjectures with a slug derived from the durable reward target, `erdos535-erdos-535`. **They are different strings for the same theorem and neither is derived from the other.** What joins them is `reward_target_id`, which every target index carries and which is the identity this validator prices, pays and retires against. So every contribution row carries both, plus the per-revision `problem_id`, and a target is reachable under all four: ``` GET /v1/contributions/targets/erdos-535 # the corpus's slug GET /v1/contributions/targets/erdos535-erdos-535 # this API's conjecture slug GET /v1/contributions/targets/fc-target:Erdos535.erdos_535 # the durable reward target GET /v1/contributions/targets/fc-379fc029-erdos535-…-problem # the per-revision problem id ``` `conjecture_slug` is `null` when the corpus names no reward target for a row — reported as absent rather than guessed from the target name. `in_pool` is answered by this validator's live catalog, never by the mirror. The contribution repository pins its own revision of the pool, so a rotation here moves `in_pool` days before that repository notices; `open` is the corpus's separate flag for whether a target accepts contributions, and the two are not substitutes. ### Merged work and open pull requests are different listings `/v1/contributions` lists work that was reviewed, merged and indexed. `/v1/contributions/pending` lists open pull requests — somebody's intent, carrying whatever labels CI has applied so far, which may be closed without ever becoming a contribution. They are kept apart deliberately: one list with a `state` field is how intent starts being counted as achievement. Nothing in either is a payout: `reviews/` and `payouts/` in that repository are empty, so no weight, share or payment is reported anywhere on this surface. `/v1/contributions/targets` covers targets with nothing on them as well, so `?empty=true` answers "which conjectures need somebody" — the question the corpus's own local tooling is built around. ### The poll fits inside GitHub's unauthenticated budget `CONTRIBUTIONS_REFRESH_SECONDS` defaults to 60 against a limit of 60 requests an hour, which works because a poll that finds nothing new costs nothing: every request is conditional, and a `304` does not count against the budget. When the head commit does move, the whole corpus is read from one `tarball` response rather than from one request per target directory. `CONTRIBUTIONS_GITHUB_TOKEN` raises the ceiling to 5000/hour and is never required. A rate-limit refusal backs off until the reset GitHub itself supplies rather than retrying into it. The refresh runs on its own task started during lifespan, so startup never waits on github.com and a GitHub outage cannot stop this process booting. ## Caching | Endpoint | `Cache-Control` | `ETag` | | --- | --- | --- | | `/v1/catalog/meta` | `public, max-age=PUBLIC_CACHE_SECONDS` (60 by default) | yes | | `/v1/catalog/index` | `public, max-age=PUBLIC_CACHE_SECONDS` | yes | | Other catalog reads | `public, max-age=PUBLIC_CACHE_SECONDS` | no | | Results | `public, max-age=PUBLIC_CACHE_SECONDS / 2` | no | | `/v1/system/status` | `no-store` | no | | Every `/v1/contributions` read | `public, max-age=PUBLIC_CACHE_SECONDS` | yes | `public` is deliberate: none of these endpoints varies by caller and none carries a credential, so a shared cache in front of the API may serve one copy to everyone. It is also the cheapest rate-limit relief available. Anything that ever becomes caller-dependent has to lose the header in the same change. `/v1/catalog/meta` carries a strong `ETag` and honours `If-None-Match` with a `304`. Its payload comes entirely from startup state — the catalog, the pin set and the settings, none of which move while the process runs — and a website hits it on every page load. The tag is hashed from the serialised payload rather than assembled from its inputs, so it cannot drift from the body. `/v1/catalog/index` carries one too, on a stronger version of the same argument. Its body holds no counter, no bounty quote and no price, so it is a pure function of the pinned pool: byte-identical on every request until a rotation replaces the pool. A table of contents is also the thing a site re-fetches most, and without a validator a client re-downloads the whole index each time `max-age` lapses only to be handed the same bytes. Every contribution read carries one as well, on the strongest version of the argument: those bodies are cut from an immutable snapshot and change only when a refresh lands, so between polls a revalidation is always a `304`. They all share one implementation, [`../submission_api/conditional.py`](../submission_api/conditional.py), so no two of them can disagree about what a tag means. It hashes the serialised payload, attaches the `ETag`, and returns a bodiless `304` — repeating the validator and the caching headers, per RFC 9110 — when `If-None-Match` names that body. Weak comparison prefixes are stripped and `*` matches anything. The list, detail and result endpoints carry no `ETag` on purpose: their payloads include live attempt counters, so any honest validator would have to be recomputed from the database on every request and would change constantly. A validator that has to be recomputed to be checked saves nothing. ## Browser access CORS applies to `/v1` and nowhere else, from an exact allowlist in `CORS_ALLOWED_ORIGINS`. No wildcard and no pattern matching: a subdomain wildcard turns one XSS on any subdomain into read access to this API, and there is no origin here that is not known at deploy time. An empty allowlist is valid and fail-closed — no browser may read the API, which is correct until a site exists. Production refuses `*` and refuses plaintext origins. `allow_credentials` is **false**. Stage 2 introduces a session cookie; the moment credentials are allowed, an allowlisted origin can read authenticated responses and the allowlist becomes the only thing between an XSS on any listed site and a reader's account. Until there is a session to send, sending none is free. Methods are `GET`, `HEAD` and `OPTIONS`. `POST /v1/submissions` is deliberately absent: miners call it from their own tooling and no browser ever calls it, so leaving it out means no page on any origin can spend a miner's payment even if that origin is compromised. A preflight for it fails with `400`. `ETag`, `RateLimit-*` and `Retry-After` are in `expose_headers`, so a page can actually read the budget it is subject to. ### Response hardening Every response from this process carries `X-Content-Type-Options: nosniff`, `Referrer-Policy: no-referrer`, `X-Frame-Options: DENY`, `Cross-Origin-Opener-Policy: same-origin`, `Cross-Origin-Resource-Policy: cross-origin`, a `Permissions-Policy`, and a `Content-Security-Policy` of `default-src 'none'` — right for a JSON API, since there is nothing to load and a response that somehow rendered as HTML could not fetch or execute anything. The CSP is not applied to `/docs`, which is development-only and needs its own script and stylesheet. `Strict-Transport-Security` is production-only. An HSTS header from a localhost development server pins the developer's browser to HTTPS for every other service on localhost too. `Alt-Svc` advertises an HTTP/3 authority for clients to retry over QUIC. HTTP/3 is a transport concern an ASGI application never sees, so this is an advertisement of what the deployment's edge terminates, not a claim about this process — set `ALT_SVC` to match the real edge, or leave it unset if it does not terminate QUIC. The stack order is load-bearing: ``` SecurityHeaders → ScopedCORS → RateLimit → routes ``` Two layers generate responses of their own, and a response only passes through the layers *outside* the one that made it. Security headers outermost so the `429` and the preflight are hardened too; CORS outside the limiter so a `429` still carries `Access-Control-Allow-Origin` — a browser that cannot read the body reports an opaque CORS failure instead of the rate limit. ## Rate limiting A sliding window per client over `/v1`, reported on every response: ``` RateLimit-Limit: 120 RateLimit-Remaining: 118 RateLimit-Reset: 47 ``` Emitted on admitted responses too, not only on `429`, so a client can back off before being refused. A refusal is RFC 9457 `application/problem+json` with `reason_code: RATE_LIMITED` and a `Retry-After`. Refused requests are not themselves counted — counting them would extend the penalty every time a client retried, turning a burst into an unbounded lockout. Sliding rather than fixed, because a fixed window lets a client spend the whole budget in the last second of one window and the whole budget again in the first second of the next, so the real short-term rate is twice the configured one. **It is in-process, and that is a real limitation.** There is no shared store, so N replicas admit N times `RATE_LIMIT_REQUESTS`. That is a deliberate trade against adding Redis to [`../requirements-service.lock`](../requirements-service.lock) and to the deployment: this is a read surface where the purpose is to stop one client from monopolising a process, not to meter a quota exactly. Set `RATE_LIMIT_REQUESTS` to the per-replica share, and put a shared limiter at the edge if an exact global rate is ever required. The key table is bounded by `RATE_LIMIT_MAX_CLIENTS`. Client keys are attacker-chosen — one per source address — so an unbounded dictionary would be a memory-exhaustion primitive. Eviction only ever reclaims entries whose windows have already expired, because dropping an active client would hand it back a full budget. `/healthz` and `/readyz` are exempt: a `429` to an orchestrator probe takes the replica out of service. ### Client identity `TRUSTED_PROXY_HOPS` is how many rightmost `X-Forwarded-For` entries this deployment's own proxies added. Each proxy appends the peer it received from, so with `n` trusted hops the originating client is the `n`-th entry from the right; anything further left was written by the client and is ignored. A chain shorter than the configured count means the request did not arrive through the expected proxies, and nothing in it is trusted. The default of `0` ignores the header entirely and uses the peer address. It is the only setting that cannot be spoofed, and it is correct for a directly exposed process. Getting this wrong breaks the limiter in both directions: trusting an untrusted header lets one client mint unlimited keys, and ignoring a real one collapses every visitor behind a CDN onto a single budget. ### The website's own server The website renders public pages (ISR) by calling this API from the host. A cached render has no visitor to forward, so those calls carry no `X-Forwarded-For` and all of them resolve to the one peer address nginx also connects from. In a visitor-sized bucket, a crawler walking uncached pages exhausts it for the whole site. nginx always appends `X-Forwarded-For`, so a request from a `TRUSTED_PROXY_PEERS` address that has none came from the host itself. Those requests go to a separate bucket of `RATE_LIMIT_INTERNAL_REQUESTS` per window. It is a larger ceiling, not an exemption: if anything else ever reaches the API from a trusted peer without the header, the worst it gets is that budget. The bucket applies only when both `TRUSTED_PROXY_HOPS` and `TRUSTED_PROXY_PEERS` are set; without peers any direct caller could qualify by leaving the header off. Every nginx `location` that proxies to the API must set `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`, or its visitors are counted as the website's server. ## Configuration See [`../.env.example`](../.env.example) for the annotated set. | Variable | Default | Notes | | --- | --- | --- | | `CORS_ALLOWED_ORIGINS` | — | Exact origins, comma-separated. `*` and plaintext refused in `PROD` | | `PUBLIC_CURSOR_SECRET` | development constant | **Required in `PROD`**, 32+ chars, refused if it is the published constant | | `PUBLIC_ACTIVITY_SALT` | development constant | **Required in `PROD`**, same rules | | `RATE_LIMIT_ENABLED` | `true` | Cannot be `false` in `PROD` | | `RATE_LIMIT_REQUESTS` | `120` | Per client, per window, **per replica** | | `RATE_LIMIT_WINDOW_SECONDS` | `60` | | | `RATE_LIMIT_MAX_CLIENTS` | `50000` | Bounds the limiter's own memory | | `RATE_LIMIT_INTERNAL_REQUESTS` | `5000` | Per window, for a trusted peer with no `X-Forwarded-For`; `0` shares the visitor bucket | | `TRUSTED_PROXY_HOPS` | `0` | `0` ignores `X-Forwarded-For` entirely | | `PUBLIC_CACHE_SECONDS` | `60` | `0` sends `no-store` | | `ALT_SVC` | `h3=":443"; ma=86400` in `PROD` | Describes the edge, not this process | | `HSTS_MAX_AGE` | `31536000` | Sent in `PROD` only; `0` disables | | `PINS_LOCK_PATH` | `./pins.lock.json` | Read once at startup | | `SUBMISSIONS_PAUSED` | `false` | Also refuses intake | | `STATUS_BANNER` | — | Max 500 characters | | `PIN_ROTATION_WEEKDAY` | `1` | Monday is 0, Sunday is 6 | | `PIN_ROTATION_START_UTC` | `02:00` | UTC `HH:MM` | | `PIN_ROTATION_DURATION_MINUTES` | `240` | | | `CONTRIBUTIONS_ENABLED` | `true` | `false` makes `/v1/contributions` answer `503` and starts no poll | | `CONTRIBUTIONS_REPOSITORY` | `conjectures-io/conjectures-contribution` | `owner/name` | | `CONTRIBUTIONS_BRANCH` | `main` | | | `CONTRIBUTIONS_REFRESH_SECONDS` | `60` | Minimum 15; see the rate-limit note below | | `CONTRIBUTIONS_STALE_SECONDS` | `300` | When `meta.stale` flips; must not be below the refresh interval | | `CONTRIBUTIONS_GITHUB_TOKEN` | — | Optional. Raises GitHub's ceiling from 60/hour to 5000/hour | | `CONTRIBUTIONS_GITHUB_API_URL` | `https://api.github.com` | https required in `PROD` | | `CONTRIBUTIONS_TIMEOUT_SECONDS` | `20` | | | `CONTRIBUTIONS_MAX_ARCHIVE_BYTES` | `67108864` | The archive is abandoned mid-stream past this | The pin lock and the audited allowlist are cross-checked at startup: a lock naming a different source revision than the allowlist would publish statements from one revision under the pins of another, so it stops the process rather than showing up as a mismatched detail page. ## Tests ```bash # database tests need a verified private fixture (tests/database_guard.py), or they skip FC_POSTGRES_DSN= FC_TEST_DATABASE_SYSTEM_IDENTIFIER= \ .venv/bin/pytest tests/test_api_catalog.py tests/test_api_results.py tests/test_api_public.py # no database needed: the reference and display-title parsers are pure functions .venv/bin/pytest tests/test_naming.py tests/test_references.py ``` [`../tests/test_naming.py`](../tests/test_naming.py) is the guard on display titles, and the important half of it is not the examples. Two tests sweep every declaration in [`../data/catalog.json`](../data/catalog.json) and fail if a title reads as a Lean identifier or a namespace resolves to nothing, because this is a parser over data nobody here wrote: the next pin rotation can introduce a module shape no hand-written case anticipated, and the failure mode is silent — a heading with `maximalLength_ge_of_isSquare` in it renders perfectly well. [`../tests/test_api_results.py`](../tests/test_api_results.py) is largely about absence — that no payout coldkey, payment reference or verifier output appears in any public payload, and that a field added to the verifier report is withheld by default. The proof and its digest are the one deliberate exception, and only for an approved submission: the tests assert that an unverified, rejected, or still-in-review submission publishes neither.