rcv icon indicating copy to clipboard operation
rcv copied to clipboard

CVRs with rankings > configured Maximum Number of Candidates That Can Be Ranked should throw a halting exception

Open yezr opened this issue 1 year ago • 5 comments

CVR: CSV CVRs - more ranks than configured.csv Config: undefined_more-rankings-than-configured.json The CVR above has 4 rankings, but is configured for a maximum of 3. image

In the Winning Rules tab there is a setting for Maximum Number of Candidates That Can Be Ranked. If any CVR has a ranking that exceeds this limit it should fail validation as a halting exception.

This ticket is following up with the conversation here in #786.

yezr avatar Mar 05 '24 21:03 yezr

This doesn't work naturally for ES&S files, which look like:

Image

In these files, there are columns after the max ranking. "Max ranking" essentially means that "first vote column" + "max ranking" = "last vote column".

Image

Options:

  1. Add an explicit "last vote column" to the configuration GUI
  2. Read the header rows and validate them in some way
  3. Allow ES&S files to have unlimited columns and only read up to the allowed number

I have opted for (3), which has the downside of being excluded from this check entirely. Would appreciate thoughts on that decision.

artoonie avatar Mar 31 '24 23:03 artoonie

Is it possible for option 2 to do something like

  • Go to the first column that we would not expect any more rankings in (first vote column + max ranking)
  • Inspect the first row of that column to see if it is a ranking. I think we could use our current logic to parse it but basically it would do that by checking if the text is
    • a configured candidate name or alias
    • 'undervote'
    • whatever is configured in the CVR Tab as the overvote label
    • whatever is configured in the CVR Tab as the skipped rank label
  • If it is determined to be a ranking, throw the exception, if not continue on our merry way

yezr avatar Apr 12 '24 15:04 yezr

Yep! It'll be somewhat brittle though: if we just check the first row, what if that voter undervoted? Or, what if that column is something like "overvote text" or something else "valid" that gets tripped up by this?

I think another option is:

  1. Look at the header for column and try to determine if it includes "First" or "1" or "1st"
  2. If any of those three match, see if the remainder of the columns follow the expected pattern
  3. If they all do, check the maxRanking+1th column and see if it also follows the pattern
  4. If it does, fail

This is a little less brittle, but still has failure cases (e.g. wouldn't support Choice A, Choice B, etc, or "Column One", "Column Two", etc).

artoonie avatar Apr 12 '24 16:04 artoonie

Can we piggyback off of the current validation logic in BaseCvrReader.GatherUnknownCandidates() somehow?

I can also try to confirm the format of the column headers with ES&S. If we can be confident in those that would be even easier.

yezr avatar Apr 17 '24 13:04 yezr

I'm pretty sure GatherUnknownCandidates just uses the range FirstColumn to FirstColumn+MaxNumCandidates, so whatever logic we choose here will likely apply to GatherUnknownCandidates too

artoonie avatar Apr 17 '24 15:04 artoonie