feat(elections): STV tabulation engine with test fixtures

Aperta
#1,944 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla

Direzione di ricerca

Start in the packages/tabulation/ package and read the IRV sibling issue and the schema issue first. Define the server-side STV API, then add hand-calculated golden fixtures and compare at least three cases with OpenSTV. Done means deterministic quota, transfers, eliminations, exhaustion, auto-election, and documented WIG behavior in code and docs/elections/tabulation.md.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

Implement a Single Transferable Vote tabulation engine that elects multiple winners using the Droop quota and surplus transfer.

Part of #1933.

Requirements

  • Pure function: `tabulateSTV(ballots, candidates, seats) → { rounds[], winners[], exhaustedBallots }`
  • Compute Droop quota: `floor(validBallots / (seats + 1)) + 1`
  • Elect any candidate reaching quota; transfer surplus using a documented method (Meek, Gregory, or Weighted Inclusive Gregory — pick and document one)
  • When no candidate reaches quota, eliminate lowest and redistribute
  • Handle tie-breaks deterministically (same rule as IRV)
  • Handle exhausted ballots explicitly
  • Stop when all seats filled, or when remaining candidates ≤ remaining seats (auto-elect)
  • Document the chosen surplus-transfer method in code comments AND in `docs/elections/tabulation.md`
  • Golden fixture tests with hand-calculated multi-seat elections
  • Tabulation runs server-side only

Context

  • Epic: #1933
  • Depends on schema issue
  • STV handles multi-seat races (board elections)
  • IRV issue: see sibling issue

Implementation notes

  • Start with Weighted Inclusive Gregory (WIG) — simpler to explain publicly than Meek, widely used (e.g., Scottish local elections)
  • Same `packages/tabulation/` package as IRV
  • Compare against a reference (e.g., OpenSTV) for at least 3 test cases
Lingua principale
HTML
Stelle
33
Fork
107
Merge medio
14h 6m
PR unite (30g)
19

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di USRSE/usrse.github.io

Tutte le issue di USRSE/usrse.github.io

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.