Skip to content

Drawing lots for absolute majority#3460

Merged
oliver3 merged 4 commits into
mainfrom
drawing-lots-absolute-majority
Jun 24, 2026
Merged

Drawing lots for absolute majority#3460
oliver3 merged 4 commits into
mainfrom
drawing-lots-absolute-majority

Conversation

@oliver3

@oliver3 oliver3 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What & why

Implementation details:

  • Update reassign_residual_seat_for_absolute_majority() to try and use a list from lists_drawn when drawing lots is needed
  • Split ListDrawingLotsVariant::AbsoluteMajority into two variants, corresponding to a seat that is reassigned from a previous largest remainder or highest average seat change
  • Add assign_to field to the AbsoluteMajorityDrawingLots variant details to be used in the frontend
  • Add ApportionmentError::InvalidState variant and use it when a previous seat change is not one of the expected variants
  • Helper functions and traits to keep the line count of reassign_residual_seat_for_absolute_majority() within acceptable limits

How to test

Unit tests are adjusted accordingly, frontend will be built in later issues from #788

Reviewer notes

Start in backend/apportionment/src/seat_assignment/mod.rs to see the core change in reassign_residual_seat_for_absolute_majority() and what the results are in the tests below. Then check what other changes were needed to make this happen.

@oliver3 oliver3 self-assigned this Jun 23, 2026
@oliver3 oliver3 added the backend Issues or pull requests that relate to the backend label Jun 23, 2026
@oliver3 oliver3 requested a review from a team as a code owner June 23, 2026 17:59
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.66102% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (42350ea) to head (be1f322).
⚠️ Report is 1 commits behind head on main.

@oliver3

oliver3 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Patch coverage is pretty low, I will add some tests to cover helpers and conversion of apportionment from/to abacus crate structs.

Comment thread backend/apportionment/src/seat_assignment/mod.rs Outdated
@oliver3 oliver3 enabled auto-merge June 24, 2026 14:20
@oliver3 oliver3 added this pull request to the merge queue Jun 24, 2026
Merged via the queue into main with commit b7e92ba Jun 24, 2026
22 checks passed
@oliver3 oliver3 deleted the drawing-lots-absolute-majority branch June 24, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Issues or pull requests that relate to the backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backend: process drawing lots for absolute majority reassignment (P9)

3 participants