feat(elections): STV tabulation engine with test fixtures

Offen
#1,944 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Ruhig

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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
Vorherrschende Sprache
HTML
Sterne
33
Forks
107
Ø Merge
14 Std. 6 Min.
Gemergte PRs (30 T.)
19

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus USRSE/usrse.github.io

Alle Issues in USRSE/usrse.github.io

Ähnliche Issues

Weitere Issues zu Backend & API Design

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.