Conversation
There was a problem hiding this comment.
Pull request overview
Introduces a new votee/ Java 21 Maven module that ports the votee-scala vote-counting library: core domain model (Candidate, Ballot, Rational, tie-resolution) plus 9 election algorithms, backed by JUnit/AssertJ tests and ported JSON fixtures, with documentation and CI.
Changes:
- Added core immutable domain model types (
Rational,Winner,PreferentialCandidate/PreferentialBallot) and election/tie-resolution contracts. - Implemented 9 voting algorithms (Majority/SuperMajority/Approval/Veto/Borda/Baldwin/Contingent/Coombs/ExhaustiveBallot) with fixture-driven parity tests.
- Added module documentation (README, PDD/LLD), Maven build config, and a GitHub Actions workflow for running tests.
Reviewed changes
Copilot reviewed 42 out of 43 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| votee/src/test/resources/fixtures/01-candidates.json | Candidate fixture data for parity tests. |
| votee/src/test/resources/fixtures/01-ballots.json | Ballot fixture data for parity tests. |
| votee/src/test/resources/fixtures/02-ballots.json | Additional ballot fixture data. |
| votee/src/test/resources/fixtures/03-ballots.json | Ballot fixture data used across multiple algorithm parity tests. |
| votee/src/test/java/com/ludovictemgoua/votee/support/FixtureLoader.java | Test-scope JSON fixture loader with Jackson + Rational deserialization. |
| votee/src/test/java/com/ludovictemgoua/votee/model/TieResolversTest.java | Unit tests for tie resolver strategies. |
| votee/src/test/java/com/ludovictemgoua/votee/model/RationalTest.java | Unit tests for rational arithmetic/normalization. |
| votee/src/test/java/com/ludovictemgoua/votee/model/PreferentialBallotTest.java | Unit tests for ballot filtering and immutability behavior. |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/ApprovalTest.java | Approval algorithm tests (fixture + edge case). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/BaldwinTest.java | Baldwin algorithm tests (fixture + elimination behavior). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/BordaCountTest.java | Borda Count tests including eligible-candidate subset behavior. |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/ContingentTest.java | Contingent vote tests (fixture + immediate-majority path). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/CoombsTest.java | Coombs’ method tests (fixture + elimination behavior). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/ExhaustiveBallotTest.java | Exhaustive ballot tests (fixture + tie-resolver sensitivity). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/MajorityTest.java | Majority algorithm tests (fixture + boundary cases). |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/SuperMajorityTest.java | SuperMajority tests including threshold validation. |
| votee/src/test/java/com/ludovictemgoua/votee/algorithms/VetoTest.java | Veto algorithm tests (fixture + edge cases). |
| votee/src/main/java/com/ludovictemgoua/votee/model/Winner.java | Winner value type (candidate + score). |
| votee/src/main/java/com/ludovictemgoua/votee/model/TieResolvers.java | Built-in tie resolver strategies. |
| votee/src/main/java/com/ludovictemgoua/votee/model/TieResolver.java | Tie resolver strategy interface. |
| votee/src/main/java/com/ludovictemgoua/votee/model/Rational.java | Exact rational arithmetic type used for weights/scores. |
| votee/src/main/java/com/ludovictemgoua/votee/model/PreferentialCandidate.java | Default candidate implementation (id/name/optional party). |
| votee/src/main/java/com/ludovictemgoua/votee/model/PreferentialBallot.java | Default ballot implementation with include/exclude filtering. |
| votee/src/main/java/com/ludovictemgoua/votee/model/Election.java | Election contract interface with default tie resolver wiring. |
| votee/src/main/java/com/ludovictemgoua/votee/model/Candidate.java | Candidate contract. |
| votee/src/main/java/com/ludovictemgoua/votee/model/Ballot.java | Ballot contract with CRGP-style SELF type. |
| votee/src/main/java/com/ludovictemgoua/votee/model/AbstractPreferentialElection.java | Shared helpers for preference counting and tie resolution. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Approval.java | Approval voting implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Baldwin.java | Baldwin method implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/BordaCount.java | Borda count implementation (also reused by Baldwin). |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Contingent.java | Contingent vote implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Coombs.java | Coombs’ method implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/ExhaustiveBallot.java | Exhaustive ballot implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Majority.java | Majority rule implementation. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/SuperMajority.java | Supermajority implementation with configurable threshold. |
| votee/src/main/java/com/ludovictemgoua/votee/algorithms/Veto.java | Veto voting implementation. |
| votee/README.md | Module-level documentation, usage examples, and design notes. |
| votee/pom.xml | Maven configuration (Java 21, test deps, plugins, distributionManagement). |
| votee/LICENSE | Apache-2.0 license text for the module. |
| votee/docs/product-design.md | Product Design Document describing goals/scope and key decisions. |
| votee/docs/low-level-design.md | Low Level Design Document describing implementation and test plan. |
| .gitignore | Repository ignore rules updated for module/tooling outputs. |
| .github/workflows/votee-ci.yml | CI workflow running mvn test for the votee module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+24
to
+34
| for (B ballot : ballots) { | ||
| List<C> preferences = ballot.preferences(); | ||
| for (int i = 0; i < preferences.size(); i++) { | ||
| // Every preference scores a point except a ballot's last choice, its veto - unless | ||
| // the ballot only lists one candidate, in which case that candidate isn't vetoed. | ||
| boolean isVetoed = i == preferences.size() - 1 && preferences.size() > 1; | ||
| if (!isVetoed) { | ||
| scores.merge(preferences.get(i), Rational.ONE, Rational::add); | ||
| } | ||
| } | ||
| } |
Comment on lines
+24
to
+26
| Map<C, Rational> scores = new LinkedHashMap<>(countFirstVotes(ballots, candidates)); | ||
| List<Map.Entry<C, Rational>> sorted = resolveTies(descending(scores), tieResolver); | ||
|
|
Comment on lines
+35
to
+42
| for (B ballot : ballots) { | ||
| if (!topTwo.contains(ballot.preferences().getFirst())) { | ||
| ballot.preferences().stream() | ||
| .filter(topTwo::contains) | ||
| .findFirst() | ||
| .ifPresent(candidate -> scores.merge(candidate, ballot.weight(), Rational::add)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented Java port of the Votee Scala library