Skip to content

Votee - #1

Merged
icemc merged 16 commits into
masterfrom
votee
Jul 5, 2026
Merged

Votee#1
icemc merged 16 commits into
masterfrom
votee

Conversation

@icemc

@icemc icemc commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Implemented Java port of the Votee Scala library

Copilot AI review requested due to automatic review settings July 5, 2026 10:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread votee/src/main/java/com/ludovictemgoua/votee/model/TieResolvers.java Outdated
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));
}
}
Comment thread votee/src/main/java/com/ludovictemgoua/votee/model/Election.java Outdated
@icemc
icemc merged commit 7cb82fe into master Jul 5, 2026
2 checks passed
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.

2 participants