Skip to content

Add voting, truth predictions, and difficulty ratings to the website#3589

Open
zond wants to merge 24 commits intogoogle-deepmind:mainfrom
zond:discussions-voting-webtest
Open

Add voting, truth predictions, and difficulty ratings to the website#3589
zond wants to merge 24 commits intogoogle-deepmind:mainfrom
zond:discussions-voting-webtest

Conversation

@zond
Copy link
Contributor

@zond zond commented Mar 17, 2026

Summary

Adds a GitHub Discussions-backed voting system to the Formal Conjectures website:

  • Like theorems (HEART reactions)
  • Predict true/false (THUMBS_UP/DOWN reactions)
  • Rate difficulty 0-9 (discussion comments)
  • Consent modal on first use explaining that all activity is public on GitHub
  • Discussion links on theorem detail pages (created lazily)
  • Sort by most liked, difficulty, or prediction on the browse page

All data is stored as native GitHub Discussions features — no separate database.

Architecture

  • Reads: App Engine proxy (formal-conjectures-web-worker) fetches discussions using GitHub App installation tokens
  • Writes: browser talks directly to GitHub GraphQL using the user's OAuth token
  • OAuth: callback routed through the proxy so one registered URL works for all forks
  • Proxy validates that requested repos are google-deepmind/formal-conjectures or forks of it
  • CORS allows any *.github.io origin automatically

What changed

  • site/src/js/voting.js — complete rewrite: GitHub Discussions backend, consent modal, truth predictions
  • site/src/js/theorem.js, browse.js — enable voting integration, new sort options
  • site/src/css/style.css — truth widget, consent modal, discussion link styles
  • site/src/templates/ — uncomment voting.js, add sort options
  • site/appengine/ — new App Engine proxy (replaces site/worker/ Cloudflare Worker)
  • site/build.js — accept pre-processed JSON from the live site
  • .github/workflows/build-and-docs.yml-webtest branch support, voting config injection

How to try it

The branch is deployed at https://zond.github.io/formal-conjectures/. Click any theorem, then try voting, predicting, or rating difficulty.

Zero-config for forkers

Branches ending in -webtest skip the expensive Lean build, download the conjectures JSON from the live site, and deploy to GitHub Pages. To try on your own fork:

  1. Enable GitHub Pages (Settings > Pages > GitHub Actions)
  2. Enable Discussions (Settings > General > Features)
  3. Install the GitHub App: https://github.com/apps/formal-conjectures-voting/installations/new
  4. Push a branch ending in -webtest

No GCP project, secrets, or tokens needed. See site/docs/voting.md for full details.

Test plan

  • Like/unlike a theorem, verify heart reaction appears on the GitHub Discussion
  • Predict true/false, verify thumbs reaction on the Discussion
  • Rate difficulty, verify comment appears on the Discussion
  • Consent modal appears on first interaction, not again after
  • OAuth login works via proxy callback bounce
  • Browse page sort options (most liked, difficulty, predictions) work
  • Discussion link appears and lazily creates discussion
  • Proxy rejects non-fork repos (returns 403)
  • Full Lean build on main is unaffected (voting config still injected)
  • Verify on a second fork to confirm zero-config flow

🤖 Generated with Claude Code

zond added 15 commits March 17, 2026 10:47
Switch the voting/rating system from Cloudflare KV to GitHub Discussions.
Likes are HEART reactions, truth predictions are THUMBS_UP/DOWN reactions,
and difficulty ratings are discussion comments. Replace the Cloudflare Worker
with an App Engine proxy that loads secrets from Google Cloud Secret Manager.
Add a consent modal explaining that all activity is public on GitHub.
Enable voting, truth prediction, difficulty rating, and discussion links
on both the browse and theorem detail pages. Allow build.js to accept
pre-processed JSON from the live site.
The /discussions endpoint now accepts ?owner=X&repo=Y instead of
reading the repo from server config. This lets one shared App Engine
proxy serve discussions for any repo.
Document the default shared proxy setup (zero config for forkers),
local development, and how to run your own proxy. Update API docs
to reflect the owner/repo query parameters on /discussions.
Branches ending in -webtest skip the Lean build, docgen, and
extract_names. Instead they download the processed conjectures JSON
from the live site and inject repo-specific voting config (owner,
name, repo ID) automatically. The site is deployed to GitHub Pages.

On main, the full build runs unchanged.
Replace GH_READ_TOKEN (a fine-grained PAT scoped to specific repos) with
GH_APP_PRIVATE_KEY (the GitHub App's private key). The proxy now obtains
short-lived installation tokens automatically for any repo where the app
is installed. Forkers no longer need PAT updates — just install the app.
Allow any *.github.io origin automatically so forks don't need CORS
config. Fix the App Engine URL to .uc.r (us-central). Bump runtime
from Node 20 to Node 22 (current LTS).
…andling

- Add repo validation to /discussions endpoint: only serves
  google-deepmind/formal-conjectures and its forks
- Fix docs: replace "read-only PAT" with "installation token",
  clarify config table shows injected values not source defaults,
  document failure modes and discussion creation triggers
- Add error handling for node_id fetch in CI workflow
- Fix Node.js version reference in appengine README
…Storage

GitHub Apps require redirect_uri to exactly match a registered callback
URL. Use the site root (which is registered) and store the user's
current page in localStorage. After token exchange, redirect back to
the original page.
Register a single callback URL on the App Engine worker
(/oauth/callback) that bounces the OAuth code back to
whichever fork the user came from. This eliminates the need
for per-fork callback URL registration in the GitHub App.
The redirect target is validated to be *.github.io or localhost.
- Use Node 22 in CI workflow (matches App Engine runtime and package.json)
- Check for missing access_token in OAuth callback before proceeding
- Deduplicate voting.md and appengine/README.md: voting.md has the
  overview and forker quickstart, README.md has proxy-specific details
@google-cla
Copy link

google-cla bot commented Mar 17, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@zond zond force-pushed the discussions-voting-webtest branch from f972104 to 64a1850 Compare March 17, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant