From d2a73cde3861a54b85d5f3bdd64af81e7611c9df Mon Sep 17 00:00:00 2001 From: "@gavetaio" Date: Thu, 15 Sep 2022 16:06:27 -0300 Subject: [PATCH] add codex; refactor MDs --- README.md | 103 +- README_PT.md | 98 ++ docs/g2v6.md | 62 + package.json | 1 + packages/codex/package.json | 56 + packages/codex/src/integrity/README.md | 68 + .../src/integrity/__tests__/interpretation.ts | 34 + .../integrity/data/brazilian-election-2018.ts | 1089 +++++++++++++++++ .../codex/src/integrity/helpers/events.ts | 3 + packages/codex/src/integrity/helpers/types.ts | 27 + .../brazilian-electoral-code.ts | 39 + .../brazilian-electoral-court.ts | 51 + .../western-electoral-heritage.ts | 27 + packages/codex/tsconfig.json | 18 + 14 files changed, 1595 insertions(+), 81 deletions(-) create mode 100644 README_PT.md create mode 100644 docs/g2v6.md create mode 100644 packages/codex/package.json create mode 100644 packages/codex/src/integrity/README.md create mode 100644 packages/codex/src/integrity/__tests__/interpretation.ts create mode 100644 packages/codex/src/integrity/data/brazilian-election-2018.ts create mode 100644 packages/codex/src/integrity/helpers/events.ts create mode 100644 packages/codex/src/integrity/helpers/types.ts create mode 100644 packages/codex/src/integrity/interpretation/brazilian-electoral-code.ts create mode 100644 packages/codex/src/integrity/interpretation/brazilian-electoral-court.ts create mode 100644 packages/codex/src/integrity/interpretation/western-electoral-heritage.ts create mode 100644 packages/codex/tsconfig.json diff --git a/README.md b/README.md index fdca327..cc58497 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,39 @@ -## Feramenta para investigação das recorrentes falhas eleitorais brasileiras +# Electoral Tools — @gavetaio -Este projeto tem origem na abertura da gaveta das eleições através do `@gavetaio/liber`, com ela, surgiu a necessidade de análise e investigação dos dados eleitorais — disponíveis oficialmente via dadosabertos.tse.jus.br. +The purpose of this repository is to share all parallel code strategies produced while crafting the word sets of the Election Drawer from the @gavetaio/liber artistic-scientific project; allowing for anyone to question and properly attempt to falsify its conclusions. - +- Read the full document at gaveta.io/G2V6 -Começamos com um script rodado via `command line`, que fazia uma rápida investigação das falhas expostas; porém, dada a complexidade e seriedade dos problemas encontrados, aliada à **ausência de padronização** e **obscurecimento** dos dados disponibilizados, esta análise acabou requerindo uma disposição visual dos elementos. Utilizamos então o electron-react-boilerplate como base para o projeto, juntamente com o lernajs para gerenciar a separação dos pacotes, organizando-o da seguinte forma: +## Falseability — To coders -- `packages/ui/base` — componentes para a base da interface -- `packages/ui/dre` — releitura da urna eletrônica -- `packages/elections` — aplicativo via electron-react-boilerplate -- `packages/engine` — engine que faz o parse e investigações nos dados eleitorais oficiais disponíveis -- `packages/core` — utils, helpers e transformers +Way too many words were crafted into this project, but, on its pluriversal sum, it all converges to one singularity: `the quantitative electoral integrity natural language interpretation breakdown through algorithmic code`. The main goal of this coding exercise is to question how easily we, humans, have been playing loose with natural language interpretation. -## Da carta aberta aos desenvolvedores de software +The Brazilian `Superior Electoral Court`’s understanding of its own `Electoral Code` is so problematic that it opens an opportunity for this algorithmic analysis since it can be easily expressed, compared, and tested, in the face of its clear conflicts with cemented international principles and human rights guarantees. -
- Disponibilizamos neste repositório o código que analisa os dados oficiais do repositório eleitoral, nele, demonstramos as recorrentes falhas na urna eletrônica e no processo eleitoral brasileiro; estas falhas, comprovadamente, alteraram o resultado final de inúmeras eleições nacionais. Entenda que, este projeto, não é sobre os extremos da curva, não é sobre partidos e tão pouco sobre ideologias; este projeto é sobre programadores, pedindo aos demais programadores, para que revisem seu código, e, provem que estamos errados. A República está tomada por afirmações inscientes e totalitárias; palavras são relativizadas, o pensamento humano é relativizado, porém, a lógica de programação, ainda é booleana. Portanto, por favor, provem que estamos errados: provem que os 185 mil votos anulados de forma arbitrária entre 1998 e 2020 — «não existiram»; provem que a explosão de votos perdidos por falhas em urnas eletrônicas entre 1998 e 2002 (TSE: RESOLUÇÃO Nº 21.076/2002), «não existiu»; provem que este facto não se repetiu nas eleições de 2020 em Irupi/ES (RE060056186) e Várzea Paulista/SP; provem que os 4.232 votos válidos com o sigilo quebrado nas eleições de 2018 — «não ocorreram»; provem que a urna eletrônica não contraria todo princípio fundamental de controle de erro do usuário, e que esta insciência não foi responsável pela explosão de votos nulos, afetando — até hoje — a integridade de toda eleição brasileira. Em um século onde a realidade colocada em palavras é facilmente descartada, a lógica de programação é ferramenta singular para cercear toda e qualquer manifestação sofista; dito isso, programador, a resolução deste problema resta — literalmente — em suas mãos, honre sua posição, e, por favor, prove que estamos errados. -
+- Access the integrity challenge `README.md` with instructions on how to run the tests at packages/codex/integrity/README.md +- More details on gaveta.io/G2V6/velum/election-integrity -Para maiores informações técnicas a respeito do processo eleitoral brasileiro, sua estrutura em comparação aos princípios democráticos ocidentais e o impacto das recorrentes falhas apresentadas, acesse a trilha de conhecimento #G2T1 diretamente no `@gavetaio/liber`. +## Falseability — To non-coders and fact-checking organizations -## Da validação das falhas encontradas +Given the fact that we, as sentient human beings, seem unable to grasp a multidisciplinary abstraction without fancifully imagining the existence of a multitude of infinite solutions, we have deliberately pushed the falsifiable paths to be done through international comparison; but, you can still abstractly argue about them, which will also be formally reviewed. -Os dados gerados através desta ferramenta estão exportados, aqui mesmo no repositório, dentro da pasta `/docs`, visando a conferência e validação de toda sociedade. Em caso de inconsistências, **qualquer cidadão pode enviar um pedido de atualização** através da criação de uma `PR`, direcionando-a para a branch `civitas`. As tabelas exportadas estão organizadas da seguinte forma: +- View the 11 boolean falsifiable statements at docs/g2v6.md +- Extra details at gaveta.io/G2V6 -- `2018` — [Votos com o **sigilo quebrado** de forma direta](docs/expostos.md) -- `1994` — `2020` — [**Seções eleitorais anuladas** por completo](docs/anuladas.md) — sem justificativas nos dados oficiais -- `2018` — [Votos válidos excluídos pela presença de **candidatos irregulares**](docs/candidatos.md) -- `1994` — `2020` — [Votos válidos excluídos pela presença de **candidatos irregulares**](docs/excluidos.md) -- `2018` — [Porcentagem de candidatos votados em eleições proporcionais por seção eleitoral](docs/votados.md) -- `1994` — `2020` — [Resumo dos dados eleitorais capturados](docs/dados.md) +## Brazilian DRE black-box — Refactored prototype -Seguindo as garantias estabelecidas pela **Lei de Transparência Pública** `Nº 12.527`, qualquer pessoa brasileira nascida pode requerer e **confirmar a validade estes dados** — basta questionar oficialmente os órgãos responsáveis. Cada um dos arquivos listados, além da tabela de dados, conta com uma descrição para a requisição dos mesmos. +The DRE prototype was crafted as a personal challenge to understand if it would be possible to properly close the user experience on the same grounds as the current legacy UI; but, instead of ignoring, following every electoral norm from the Brazilian Electoral Code that acts in the protection of its voter intent. -## Do conceito de plataforma de pesquisa +- For accessing the DRE emulator/prototype, run the ElectronJS app and access the `Simulador` tabs. +- Extra information and online simulation on gaveta.io/G2V6/velum/brazilian-dre-blackbox -Este projeto é uma **plataforma de pesquisa**, não um aplicativo. Pela flexibilidade necessária, não foi desenvolvida documentação, restando a evolução do projeto, agora, nas mãos da comunidade. Em caso de dúvidas, tirem-nas diretamente na leitura do código e seus links relacionados. Para melhor compreensão dos objetivos, analisem os seguites documentos, apresentados na gaveta das eleições do `@gavetaio/liber`: + -- `G2V1` — Da **constitucionalidade** do processo eleitoral brasileiro -- `G2V2` — Da **quebra de sigilo** do voto nas eleições brasileiras -- `G2V3` — Da **anulação de votos em massa** na urna eletrônica brasileira -- `G2V4` — Da ruptura da **intenção de voto** do eleitor brasileiro -- `G2V5` — Da desproporcionalidade do **direito político** brasileiro +## Brazilian Electoral Database — ElectronJS application -## Da releitura da interface da Urna Eletrônica brasileira +The official **Brazilian Electoral Database** available at dadosabertos.tse.jus.br lacks completeness and a unified structure. For properly interrogating its contents, it was initially developed as a cmd-line NodeJS tool, but ended up evolving into a full ElectronJS application due to the increased complexity of its investigations. The app isn't intended for non-coding users though; as it was built with a focus on being a flexible research tool. -Para fazer a correção da interface da urna eletrônica, seguimos as indicações dispostas pela Venice Commission, ACE/IDEA, European Commission, ODIHR/OSCE, e pelo Código Eleitoral brasileiro em seu `A146.XIII` no que tange o cuidado com a correção de erros inadvertidos e possibilidade de confirmação do voto por parte do eleitor. +- For installing it, just run `yarn install && yarn post && yarn start`. +- All the app's text is in its original **Portuguese** natural language. -Tanto a versão corrigida, como a versão legada da urna eletrônica, podem ser exportados para arquivos `.html` e rodados em qualquer dispositivo — com ou sem o auxílio de mini-teclado numérico físico —, para que assim, sejam devidamente estudados e tenham seus resultados analisados pela comunidade científica. - - - -Para maiores informações sobre a reconstrução da urna e a comprovação de suas falhas de usabilidade, acesse o documento G2V4 — Da ruptura da intenção de voto do eleitor brasileiro. - -## Dos dados oficiais incompletos e a análise de votos válidos - -Para que possamos finalizar nosso último estudo, que analisa o impacto da utilização da urna eletrônica nos **votos válidos** de eleições brasileiras, é crucial o acesso aos dados que estão **indisponíveis no repositório eleitoral** do órgão oficial (dadosabertos.tse.jus.br); somente após esta disponibilização, poderá ser encerrada a análise desta efetividade. Atualmente, os dados de `1994` estão parcialmente disponíveis `49%`, e, apenas `2%` dos dados das eleições de `1996` estão disponibilizados → veja a tabela com o [resumo dos dados capturados](docs/dados.md). - -## Das formas de participação da comunidade científica - -No momento, não temos a intenção de evoluir as investigações aqui propostas, consideramos que as mesmas já atingiram o objetivo embarcado na criação do `@gavetaio/liber`. A partir de agora, o projeto está aberto, e, sua atualização, sob a responsabilidade de membros da comunidade. - -- Para colaborar, envie sua `PR` para a branch civitas. -- Caso deseje tornar-se um membro da comunidade, com permissões de aprovação, faça o pedido juntamente com o envio de sua `PR`; no processo de aprovação de novos membros avaliamos apenas o nível de atividade de seu perfil aqui no Github, evitando a participação de contas inativas. -- Caso você represente uma instituição, pedimos que, se possível, faça suas colaborações através de **perfis oficiais**. - -## Da escolha da linguagem e framework de programação - -Optamos por cosntruir este projeto em `javascript`, com `nodejs` e `reactjs`, por sua flexibilidade e agilidade, mas, principalmente, por ser esta a maior comunidade de desenvolvedores existente no Brasil. Desta forma, visamos facilitar o engajamento na **validação dos dados** aqui expostos, e também na **evolução das investigações** propostas. - -## Da instalação deste projeto - -Utilize os comandos abaixo para clonar, instalar e rodar o projeto. Você pode utilizar tanto `yarn` quanto `npm`. - -``` -git clone git@github.com:gavetaio/electio.git -cd electio -yarn install && yarn post -yarn start -``` - -## Dos links relacionados - -- `gaveta.io/g2`Gaveta das Eleições -- `TSE`Repositório de dados eleitorais -- `Legislação ordinária brasileira`Código Eleitoral -- `Electoral Knowledge Netrwork`ACE -- `Code of good practice in electoral matters`Venice Commission -- `2014`, `2016`, `2018`, `2020`Estatísticas e resultados eleitorais -- `2018`, `Pesquisa UX`Pardal eleitoral -- `2012`Boletim de urna -- `2014`Boletim de urna -- `2016`Boletim de urna -- `2018`Boletim de urna -- `2020`Boletim de urna -- `2002`Relatório oficial das eleições -- `RESOLUÇÃO TSE Nº 21.076/2002`relatório oficial do `GESTOT` que confirma falhas na urna eletrônica no início do século (Página. 364) + diff --git a/README_PT.md b/README_PT.md new file mode 100644 index 0000000..fdca327 --- /dev/null +++ b/README_PT.md @@ -0,0 +1,98 @@ +## Feramenta para investigação das recorrentes falhas eleitorais brasileiras + +Este projeto tem origem na abertura da gaveta das eleições através do `@gavetaio/liber`, com ela, surgiu a necessidade de análise e investigação dos dados eleitorais — disponíveis oficialmente via dadosabertos.tse.jus.br. + + + +Começamos com um script rodado via `command line`, que fazia uma rápida investigação das falhas expostas; porém, dada a complexidade e seriedade dos problemas encontrados, aliada à **ausência de padronização** e **obscurecimento** dos dados disponibilizados, esta análise acabou requerindo uma disposição visual dos elementos. Utilizamos então o electron-react-boilerplate como base para o projeto, juntamente com o lernajs para gerenciar a separação dos pacotes, organizando-o da seguinte forma: + +- `packages/ui/base` — componentes para a base da interface +- `packages/ui/dre` — releitura da urna eletrônica +- `packages/elections` — aplicativo via electron-react-boilerplate +- `packages/engine` — engine que faz o parse e investigações nos dados eleitorais oficiais disponíveis +- `packages/core` — utils, helpers e transformers + +## Da carta aberta aos desenvolvedores de software + +
+ Disponibilizamos neste repositório o código que analisa os dados oficiais do repositório eleitoral, nele, demonstramos as recorrentes falhas na urna eletrônica e no processo eleitoral brasileiro; estas falhas, comprovadamente, alteraram o resultado final de inúmeras eleições nacionais. Entenda que, este projeto, não é sobre os extremos da curva, não é sobre partidos e tão pouco sobre ideologias; este projeto é sobre programadores, pedindo aos demais programadores, para que revisem seu código, e, provem que estamos errados. A República está tomada por afirmações inscientes e totalitárias; palavras são relativizadas, o pensamento humano é relativizado, porém, a lógica de programação, ainda é booleana. Portanto, por favor, provem que estamos errados: provem que os 185 mil votos anulados de forma arbitrária entre 1998 e 2020 — «não existiram»; provem que a explosão de votos perdidos por falhas em urnas eletrônicas entre 1998 e 2002 (TSE: RESOLUÇÃO Nº 21.076/2002), «não existiu»; provem que este facto não se repetiu nas eleições de 2020 em Irupi/ES (RE060056186) e Várzea Paulista/SP; provem que os 4.232 votos válidos com o sigilo quebrado nas eleições de 2018 — «não ocorreram»; provem que a urna eletrônica não contraria todo princípio fundamental de controle de erro do usuário, e que esta insciência não foi responsável pela explosão de votos nulos, afetando — até hoje — a integridade de toda eleição brasileira. Em um século onde a realidade colocada em palavras é facilmente descartada, a lógica de programação é ferramenta singular para cercear toda e qualquer manifestação sofista; dito isso, programador, a resolução deste problema resta — literalmente — em suas mãos, honre sua posição, e, por favor, prove que estamos errados. +
+ +Para maiores informações técnicas a respeito do processo eleitoral brasileiro, sua estrutura em comparação aos princípios democráticos ocidentais e o impacto das recorrentes falhas apresentadas, acesse a trilha de conhecimento #G2T1 diretamente no `@gavetaio/liber`. + +## Da validação das falhas encontradas + +Os dados gerados através desta ferramenta estão exportados, aqui mesmo no repositório, dentro da pasta `/docs`, visando a conferência e validação de toda sociedade. Em caso de inconsistências, **qualquer cidadão pode enviar um pedido de atualização** através da criação de uma `PR`, direcionando-a para a branch `civitas`. As tabelas exportadas estão organizadas da seguinte forma: + +- `2018` — [Votos com o **sigilo quebrado** de forma direta](docs/expostos.md) +- `1994` — `2020` — [**Seções eleitorais anuladas** por completo](docs/anuladas.md) — sem justificativas nos dados oficiais +- `2018` — [Votos válidos excluídos pela presença de **candidatos irregulares**](docs/candidatos.md) +- `1994` — `2020` — [Votos válidos excluídos pela presença de **candidatos irregulares**](docs/excluidos.md) +- `2018` — [Porcentagem de candidatos votados em eleições proporcionais por seção eleitoral](docs/votados.md) +- `1994` — `2020` — [Resumo dos dados eleitorais capturados](docs/dados.md) + +Seguindo as garantias estabelecidas pela **Lei de Transparência Pública** `Nº 12.527`, qualquer pessoa brasileira nascida pode requerer e **confirmar a validade estes dados** — basta questionar oficialmente os órgãos responsáveis. Cada um dos arquivos listados, além da tabela de dados, conta com uma descrição para a requisição dos mesmos. + +## Do conceito de plataforma de pesquisa + +Este projeto é uma **plataforma de pesquisa**, não um aplicativo. Pela flexibilidade necessária, não foi desenvolvida documentação, restando a evolução do projeto, agora, nas mãos da comunidade. Em caso de dúvidas, tirem-nas diretamente na leitura do código e seus links relacionados. Para melhor compreensão dos objetivos, analisem os seguites documentos, apresentados na gaveta das eleições do `@gavetaio/liber`: + +- `G2V1` — Da **constitucionalidade** do processo eleitoral brasileiro +- `G2V2` — Da **quebra de sigilo** do voto nas eleições brasileiras +- `G2V3` — Da **anulação de votos em massa** na urna eletrônica brasileira +- `G2V4` — Da ruptura da **intenção de voto** do eleitor brasileiro +- `G2V5` — Da desproporcionalidade do **direito político** brasileiro + +## Da releitura da interface da Urna Eletrônica brasileira + +Para fazer a correção da interface da urna eletrônica, seguimos as indicações dispostas pela Venice Commission, ACE/IDEA, European Commission, ODIHR/OSCE, e pelo Código Eleitoral brasileiro em seu `A146.XIII` no que tange o cuidado com a correção de erros inadvertidos e possibilidade de confirmação do voto por parte do eleitor. + +Tanto a versão corrigida, como a versão legada da urna eletrônica, podem ser exportados para arquivos `.html` e rodados em qualquer dispositivo — com ou sem o auxílio de mini-teclado numérico físico —, para que assim, sejam devidamente estudados e tenham seus resultados analisados pela comunidade científica. + + + +Para maiores informações sobre a reconstrução da urna e a comprovação de suas falhas de usabilidade, acesse o documento G2V4 — Da ruptura da intenção de voto do eleitor brasileiro. + +## Dos dados oficiais incompletos e a análise de votos válidos + +Para que possamos finalizar nosso último estudo, que analisa o impacto da utilização da urna eletrônica nos **votos válidos** de eleições brasileiras, é crucial o acesso aos dados que estão **indisponíveis no repositório eleitoral** do órgão oficial (dadosabertos.tse.jus.br); somente após esta disponibilização, poderá ser encerrada a análise desta efetividade. Atualmente, os dados de `1994` estão parcialmente disponíveis `49%`, e, apenas `2%` dos dados das eleições de `1996` estão disponibilizados → veja a tabela com o [resumo dos dados capturados](docs/dados.md). + +## Das formas de participação da comunidade científica + +No momento, não temos a intenção de evoluir as investigações aqui propostas, consideramos que as mesmas já atingiram o objetivo embarcado na criação do `@gavetaio/liber`. A partir de agora, o projeto está aberto, e, sua atualização, sob a responsabilidade de membros da comunidade. + +- Para colaborar, envie sua `PR` para a branch civitas. +- Caso deseje tornar-se um membro da comunidade, com permissões de aprovação, faça o pedido juntamente com o envio de sua `PR`; no processo de aprovação de novos membros avaliamos apenas o nível de atividade de seu perfil aqui no Github, evitando a participação de contas inativas. +- Caso você represente uma instituição, pedimos que, se possível, faça suas colaborações através de **perfis oficiais**. + +## Da escolha da linguagem e framework de programação + +Optamos por cosntruir este projeto em `javascript`, com `nodejs` e `reactjs`, por sua flexibilidade e agilidade, mas, principalmente, por ser esta a maior comunidade de desenvolvedores existente no Brasil. Desta forma, visamos facilitar o engajamento na **validação dos dados** aqui expostos, e também na **evolução das investigações** propostas. + +## Da instalação deste projeto + +Utilize os comandos abaixo para clonar, instalar e rodar o projeto. Você pode utilizar tanto `yarn` quanto `npm`. + +``` +git clone git@github.com:gavetaio/electio.git +cd electio +yarn install && yarn post +yarn start +``` + +## Dos links relacionados + +- `gaveta.io/g2`Gaveta das Eleições +- `TSE`Repositório de dados eleitorais +- `Legislação ordinária brasileira`Código Eleitoral +- `Electoral Knowledge Netrwork`ACE +- `Code of good practice in electoral matters`Venice Commission +- `2014`, `2016`, `2018`, `2020`Estatísticas e resultados eleitorais +- `2018`, `Pesquisa UX`Pardal eleitoral +- `2012`Boletim de urna +- `2014`Boletim de urna +- `2016`Boletim de urna +- `2018`Boletim de urna +- `2020`Boletim de urna +- `2002`Relatório oficial das eleições +- `RESOLUÇÃO TSE Nº 21.076/2002`relatório oficial do `GESTOT` que confirma falhas na urna eletrônica no início do século (Página. 364) diff --git a/docs/g2v6.md b/docs/g2v6.md new file mode 100644 index 0000000..5c3935d --- /dev/null +++ b/docs/g2v6.md @@ -0,0 +1,62 @@ +## On the G2V6 document boolean falsifiable statements + +For helping those who wish to go through the path of falsifying @gavetaio/liber's G2V6 document, we've organized here a list of verifiable boolean statements; you can officially invalidate them by opening an argumentative `pull request` on this repository proposing a change on its content. + +For more information access the main document at: gaveta.io/g2v6 — Another Failed Brazilian Republic. + +Given the fact that we, as sentient human beings, seem unable to grasp a multidisciplinary abstraction without fancifully imagining the existence of a multitude of infinite solutions, we have deliberately pushed the falsifiable paths to be done through international comparison; but, you can still abstractly argue about them, which will also be formally reviewed. + +1. > No other country in Western Civilization history has ever fully annulled more than one million valid votes on a general election's party-list proportional representation due to the presence of invalid candidates on its official ballot on election day. + + - Brazil has achieved it for three consecutive elections: 2010 (1,829,844 excluded valid votes), 2014 (1,271,412 excluded valid votes) and 2018 (1,555,105 excluded valid votes). + - For falsifying this, you'll need to find another country that, due to failure on its registration process, not only has allowed a high number of invalid candidates to campaign and be normally present on the ballot but also chooses to nullify its valid casted votes even on proportional representation elections by not attributing them to the candidate's party. + +2. > No other country in Western Civilization history has ever allowed, on a full-scale general election, for more than 3% of invalid candidates to be normally present on its official ballots on election day. + + - Brazil has achieved it for three consecutive election cycles: 2010 (5.8%, 1,106 invalid candidates), 2014 (3.2%, 731 invalid candidates) and 2018 (4.0%, 1,060 invalid candidates). + - For falsifying this, you'll need to find another country that, due to mishandling of its registration process, has allowed invalid candidates to campaign and to be normally present on the official ballots, on election day, on numbers above 3% of its total available candidates. + +3. > No other country in Western Civilization history has ever allowed its judicial system the power to change a party-list proportional representation election result by fully nullifying valid casted votes given to a regularly registered and elected candidate — triggering a full rearrangement of its proportional party-seat distribution, with no election repeat. + + - In 2021, Brazil's Superior Electoral Court decided that this is a right on its power belt, having arbitrarily changed an election result by fully nullifying all valid votes casted to an election's most voted candidate, and, also removing them from its party; consequently triggering a complete rearrangement of its proportional party-seat distribution — with no election repeat. + - For falsifying this you'll need to find another western country that uses a paty-list proportional representation and gives its judiciary system the power to nullify all valid casted votes given to a regularly registered candidate and its party, rearranging the proportionally distributed party seats at any time during the whole extent of the electoral cycle — with no election repeat. + +4. > No other country in Western Civilization history has ever trusted 100% of its general elections on a DRE black-box machine without an independent physical auditory trail. + + - Since 2002, Brazil have trusted on a 1st-generation DRE black-box fully software dependant machine for 100% of its general elections. + - For falsifying this, you'll need to prove that there is or was another western country that has used a DRE black-box machine for 100% of it's general elections — without production of an independent physical auditory trail. + +5. > No other electronic voting machine in Western Civilization history has ever affected the quantitative electoral integrity of 3 elections in a single electoral cycle due to full polling station nullification of valid votes — with no election repeat. + + - In 2020, due to multiple electronic failures, the elections of Irupi/ES (S64/Z19), Várzea Paulista/SP (S172/Z242) and Presidente Vargas/MA (S108/S143) had its quantitative electoral integrity mathematically broken due to the nullification of all valid votes deposited on entire polling stations — none of these elections were partially nor fully recalled. + - For falsifying this, you'll need to find another western country that widely uses electronic voting machines without paper audit trail that due to its electronic failure have ripped the integrity of 3 or more elections in a single voting cycle, and — going against its own legislature — refused to recall its voters, weighting on the failed machine the full responsibility for the unfair election result. + +6. > No other country in Western Civilization history has ever presented an Election Result Granularity Ratio below 0.5, while using a voter-fixed polling station strategy and constitutionally guaranteeing the protection of the secrecy of the vote. + + - Brazil has achieved it in its 2010, 2014, and 2018 general elections. + - For falsifying this you'll need to find another western country that have an overall ERGR bellow 0.5 while using a voter-fixed polling station strategy, and also guaraneeing the secrecy of the vote through its constitutional text. + +7. > No other country in Western Civilization history has ever allowed for more than 4000 valid votes to have its secrecy exposed through unanimous voting on a single electoral cycle. + + - Brazil has achieved it in its 2018 General Elections exposing the secrecy of 4232 valid votes due to unanimous polling station voting. + - For falsifying this you'll need to find another western country that have exposed more than 4000 valid votes due to unanimous voting on a single electoral cycle, while using a pre-election voter-fixed polling station stragegy. + +8. > No other country in Western Civilization history has ever used an electronic voting machine for 100% of its general elections, that in a 3+ vote steps, doesn't allow the voter to review and change its full vote before commiting it into the system. + + - Since it's inception in 1996, the Brazilian DRE black-box interface, going against the country's own legislature (123), even being used in a 6 voting steps election, doesn't implement error-warning actions and mistake-prevention strategies; critically afecting its law-protected voter intent. + - For falsifying this you'll need to find another western country that have used an EVM for the entirity of its general elections, with a 3+ voting steps, that didn't allow its voter to review and change its full vote before commiting to it. + +9. > No other Supreme Court in Western Civilization history has ever ruled on a 2nd and 3rd generation voting machine, which increases vote security by allowing fraud-detection through a physical auditory trail, to be unconstitutional. + + - The Brazilian court have done it twice: in 2014 and 2020 on the basis of protection of the secrecy of the vote, its high cost of implementation, and for it being considered an unecessary regression from its failless 1st-generation fully software dependant machine. + - For falsifying this you'll need to find another western country that constitutionally protects the equal value of the vote and its Supreme Court has ruled that the addition of a paper audit trail to a DRE black-box to be unconstitutional. + +10. > No other country in Western Civilization history has ever given its EMB the power to choose to ignore an ex officio legislative responsibility of redoing a partial election due to nullification of votes that would affect its quantitative electoral integrity and final results. + + - The Brazilian legislature (EC65 A187, A201, A212), which alings with the European electoral heritage, openly protects its quantitative electoral integrity by requiring an ex officio remedy to be taken in the event of a polling station nullification affecting its final results; but, this is fully ignored by the country's EMB which has never repeated a partial election and refuses to act on it ex officio, even with multiple nullifications events occurring on every electoral cycle. + - For falsifying this, you'll need to find another country that specifically requires an election to be repeated as a remedy for every quantitative integrity breach, ex officio, in its own electoral laws, and allows its EMB the right to fully ignore the legislative text. + +11. > While the Brazilian EMB, going against its own Electoral Code (A146, L9504/A87, A177), arbitrarily insists on keeping its DRE Black-box everlasting punitive human interface: every time its election integrity can be affected by the total amount of nulled/slip votes, it is impossible to determine if its final result wasn't affected by the machine's critical usability issues. + + - This scenario can be verified on the Brazilian Presidential elections of 1998/I, 2002/I, 2006/I and 2014/II. + - For falsifying this, you'll need to create a real-world UX randomized study for comparing the current Brazilian DRE Black-box interface with a control group using manual vote, and, an experiment group using a refactored human interface that aligns with the country's Electoral Code respect for the voter intent by implementing error-prevention and allowing for mistake-recovery. diff --git a/package.json b/package.json index ad04464..fbf474d 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ ], "scripts": { "start": "lerna run --parallel start", + "codex:integrity-test": "lerna run --parallel --scope @gavetaio/codex test", "build": "lerna run --parallel --scope @gavetaio/election-app build", "post": "lerna run --parallel --scope @gavetaio/election-app neverpostinstall" }, diff --git a/packages/codex/package.json b/packages/codex/package.json new file mode 100644 index 0000000..8851024 --- /dev/null +++ b/packages/codex/package.json @@ -0,0 +1,56 @@ +{ + "name": "@gavetaio/codex", + "version": "1.0.0", + "description": "", + "type": "module", + "scripts": { + "start": "ts-node ./src/index.ts", + "test": "jest --noStackTrace", + "lint": "eslint src public" + }, + "author": "@gavetaio", + "license": "ISC", + "devDependencies": { + "@types/jest": "^29.0.2", + "@types/node": "^18.7.16", + "@typescript-eslint/eslint-plugin": "^5.36.2", + "@typescript-eslint/parser": "^5.36.2", + "eslint": "^8.23.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-node": "^11.1.0", + "jest": "^29.0.3", + "prettier": "^2.7.1", + "ts-node": "^10.9.1", + "tslib": "^2.4.0", + "typescript": "^4.8.2" + }, + "jest": { + "transform": { + ".(ts|tsx)": "ts-jest" + }, + "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", + "moduleFileExtensions": [ + "ts", + "tsx", + "js", + "json" + ] + }, + "prettier": { + "overrides": [ + { + "files": [ + ".prettierrc", + ".eslintrc" + ], + "options": { + "parser": "json" + } + } + ], + "singleQuote": true + }, + "dependencies": { + "ts-jest": "^29.0.1" + } +} diff --git a/packages/codex/src/integrity/README.md b/packages/codex/src/integrity/README.md new file mode 100644 index 0000000..c83609d --- /dev/null +++ b/packages/codex/src/integrity/README.md @@ -0,0 +1,68 @@ +# Using Algorithmic Code to break a Natural Language argument + +This challenge was crafted as an extension to the experimental code produced on Document G2V6 from the `@gavetaio/liber` artistic-scientific project. It aims to shed a light on the usage of algorithmic code as a tool to investigate the source of a natural language word set misinterpretation. + +Due to the excruciating amount of nullified valid votes in its elections, the **Brazilian Superior Electoral Court of Justice** seems to present a deep misunderstanding of the principle of **vote equality** and the protection of **quantitative electoral integrity**; which lead to the misinterpretation of the logic behind the articles `A187`, `A201`, `A212`, and the conditional added by `A224` of its own **Electoral Code**. + +## On the general principle + +Every time a forced nullification of valid votes rightfully cast by regularly registered voters occurs **in numbers sufficiently large to affect an election's final result**, a remedy must be taken to ensure that the quantitative integrity of the electorate's political voice is kept intact. If this nullification isn't enough to affect the final result, no action needs to be taken. + +This remedy, by definition, won't necessarily be perfect, as in the case of a partial election repeat, but, no **Republican State** would risk to arbitrarily remove the truthful will of its people from a **democratic election**; which speaks for the critical importance of avoiding the unnecessary invalidation of rightfully casted votes. + +## On the high stakes + +- `if`: the `javascript` algorithmic code was correctly outlined; +- `if`: the `json` data was correctly extracted from the country's public database; +- `if`: the `jestjs` tests were correctly setup; +- `then`: the **Brazilian Judicial System** is ignorant towards the protection of **vote equality** and **electoral integrity**, and, has judicially destroyed the quantitative integrity of **90% of its 2018 general elections proportional representation**. + +For more information, read the verifiable and falsifiable document: G2V6. + +## On the algorithmic code strategy breakdown + +- `interpretation/western-electoral-heritage.ts` - holds the general principle in the light of the **western electoral heritage** as outlined by the Venice Commission's 2002 Code of Good Practices in Electoral Matters, and the Portuguese, Spanish, and Argentinian electoral laws. +- `interpretation/brazilian-electoral-code.ts` - holds the logic interpretation outlined by the **Brazilian Electoral Code**, which extends western-electoral-heritage.ts. +- `interpretation/brazilian-electoral-court.ts` - holds the problematic interpretation of the **Brazilian Electoral Court**, which alters brazilian-electoral-code.ts. +- `data/brazilian-election-2018.ts` - holds the transformed data from the **2018 Brazilian General Election**, extracted from the official Brazilian Electoral Database. +- `__tests__/interpretation.ts` - runs a set of basic tests to compare the **Brazilian Electoral Code** logic against the country's **Brazilian Electoral Court** interpretation on top of the country's 2018 general elections. + +The tests have a really simple setup using JestJS For installing the packages and running the tests just do a `yarn install && yarn post`, `yarn codex:integrity-test`. + +## On the western electoral heritage + +Extracted from Venice Commission's historic 2002 **CGPEM**, as its text is inherited from the same source material - Roman Law -, and protected unanimously throughout all western countries, its five principles are actually at the core of Wester Democracy itself. + +> I. The five principles underlying Europe's electoral heritage are universal, equal, free, secret and direct suffrage. Furthermore, elections must be held at regular intervals. + +## On the Brazilian constitutional and supra-legal norms + +The Brazilian legislature follow the same western principles on its constitution and supra-legal norms: + +> 1988 Brazilian Federal Constitution, A14 - The people sovereignty will be exercised by universal suffrage and by direct and secret vote, with equal value for all, and, under the terms of the law [...] + +> American Convention on Human Rights, A23.1.b - Every citizen shall enjoy the right to vote and to be elected in genuine periodic elections, which shall be by universal and equal suffrage and by secret ballot that guarantees the free expression of the will of the voters. + +## On the Brazilian superior and supreme court's wrongfull interpretation + +The **Brazilian Superior Electoral Court** and **Supreme Court of Justice**, both, choose to ignore the core logic of this protection, dismissing the logic behind articles `A187`, `A201`, and `A212` of its **Electoral Code**, and, applying only the conditional set by its article `A224` where: + +> An election is repeated if, and only if, more than 50% of its valid votes are wrongfully nullified; or an elected candidate gets excluded and its valid votes invalidated on a majoritarian election. + +This logic is far from being a valid strategy for protecting its **quantitative electoral integrity**. According to the court's unique interpretation, articles `A187`, `A201` and `A212` should only be used for rulling on the full nullification of polling stations; on that regard, recently, the court has also arbitrarily decided that: + +> The nullification of only one Polling Station doesn't justifies calling the remedy set on article `A187`. + +Furthermore, analyzing its 21st-century more than _180.000 votes_ that were nullified judicially due to full polling station nullifications, affecting the integrity of multiple electoral cycles, there is no account of any of these articles ever being triggered or respected. + +## On the Brazilian Electoral Code related articles + +Articles `A187`, `A201`, and `A212`, are actually used to apply the same logic, only on different spheres of responsibility. A187 deals with the integrity of local elections (Mayor, City Councils) giving an _ex-officio_ responsibility to the counting center (**Junta Apuradora**), `A201` extends it to the **Regional Court** on state-wide elections (State Deputy, Federal Deputy, Senator, Governor), and `A212` to the **Superior Court** on Presidential elections. `A224` sets a reasonable condition for limiting the set-up remedy, requiring a full-election redo in cases where more than 50% of valid votes were affected by a wrongful nullification of valid votes. + +> `EC65, Article 187` - If the **Counting Center** verifies that the votes of the annulled polling stations and of those whose voters were prevented from voting, may **change the representation of any party or candidate classification elected by the majority principle**, in municipal elections, it will immediately communicate the fact to the **Regional Court**, which will schedule, if confirmed, a day for the renewal of voting in those stations. + +> `EC65, Article 201` - Once the report referred to in the previous article is in its possession, the **Regional Court** will meet in the following days in order to analyze the total number of counted votes, and then, if it verifies that the votes of the nullified polling stations and of those whose voters were prevented from voting, may **change the representation of any party or classification of candidates elected by the majority principle**, will order the holding of new elections. + +> `EC65, Article 212` - Noting that the votes of the annulled sections and of those whose voters were prevented from voting, throughout the country, may **change the candidate's classification**, the **Superior Court** will order the holding of new elections. + +> `EC65, Article 224` - If the nullification reaches more than half of the votes of the country in the presidential elections, of the State in the federal and state elections, or of the municipality in the municipal elections, the remaining stations will be judged to be prejudiced and the Court will set a date for a new election within a deadline of 20 (twenty) to 40 (forty) days. diff --git a/packages/codex/src/integrity/__tests__/interpretation.ts b/packages/codex/src/integrity/__tests__/interpretation.ts new file mode 100644 index 0000000..0690735 --- /dev/null +++ b/packages/codex/src/integrity/__tests__/interpretation.ts @@ -0,0 +1,34 @@ +import BrazilianElectoralCode from '../interpretation/brazilian-electoral-code'; +import BrazilianElectoralCourt from '../interpretation/brazilian-electoral-court'; +import WesternElectoralHeritage from '../interpretation/western-electoral-heritage'; +import data from '../data/brazilian-election-2018'; + +const brazilianElectoralCode = new BrazilianElectoralCode(); +const brazilianElectoralCourt = new BrazilianElectoralCourt(); +const westernElectoralHeritage = new WesternElectoralHeritage(); + +describe('Brazilian Electoral CODE interpretation', () => { + data.forEach((election, index) => { + const brazilianCodeEvent = + brazilianElectoralCode.shouldRepeatElection(election); + const westernHeritageEvent = + westernElectoralHeritage.shouldRepeatElection(election); + + test(`T${index}: repeat event should match WesternElectoralHeritage`, () => { + expect(brazilianCodeEvent).toBe(westernHeritageEvent); + }); + }); +}); + +describe('Brazilian Electoral COURT interpretation', () => { + data.forEach((election, index) => { + const brazilianCourtEvent = + brazilianElectoralCourt.shouldRepeatElection(election); + const westernHeritageEvent = + westernElectoralHeritage.shouldRepeatElection(election); + + test(`T${index}: ${election.name}: repeat event should match WesternElectoralHeritage`, () => { + expect(brazilianCourtEvent).toBe(westernHeritageEvent); + }); + }); +}); diff --git a/packages/codex/src/integrity/data/brazilian-election-2018.ts b/packages/codex/src/integrity/data/brazilian-election-2018.ts new file mode 100644 index 0000000..123c966 --- /dev/null +++ b/packages/codex/src/integrity/data/brazilian-election-2018.ts @@ -0,0 +1,1089 @@ +import { ElectoralIntegrityData } from '../helpers/types'; + +const data: ElectoralIntegrityData[] = [ + { + name: 'AC-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 443634, + votes: { + blank: 7429, + anulled: 7465, + invalidated: 4524, + valid: 411609, + nominal: 382394, + party: 29215, + total: 443429, + }, + repeatEvent: 'no-action', + pollingStations: 1924, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 122, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'AL-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1693503, + votes: { + blank: 75150, + anulled: 115939, + invalidated: 4850, + valid: 1495861, + nominal: 1359360, + party: 136501, + total: 1692875, + }, + repeatEvent: 'no-action', + pollingStations: 6387, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2590, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'AM-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1958878, + votes: { + blank: 82920, + anulled: 95163, + invalidated: 16137, + valid: 1763198, + nominal: 1669666, + party: 93532, + total: 1957418, + }, + repeatEvent: 'no-action', + pollingStations: 7017, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1386, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'AM-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1958878, + votes: { + blank: 67505, + anulled: 81053, + invalidated: 13799, + valid: 1789077, + nominal: 1684920, + party: 104157, + total: 1957418, + }, + repeatEvent: 'no-action', + pollingStations: 7017, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 361, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'AP-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 426620, + votes: { + blank: 11089, + anulled: 11273, + invalidated: 16470, + valid: 366518, + nominal: 348978, + party: 17540, + total: 426382, + }, + repeatEvent: 'no-action', + pollingStations: 1632, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2701, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'AP-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 426620, + votes: { + blank: 7100, + anulled: 8432, + invalidated: 2343, + valid: 403371, + nominal: 384882, + party: 18489, + total: 426382, + }, + repeatEvent: 'no-action', + pollingStations: 1632, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 81, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'BA-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 8236847, + votes: { + blank: 373150, + anulled: 854819, + invalidated: 136866, + valid: 6868013, + nominal: 6188207, + party: 679806, + total: 8235310, + }, + repeatEvent: 'no-action', + pollingStations: 31192, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 183, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'BA-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 8236847, + votes: { + blank: 379434, + anulled: 859130, + invalidated: 24445, + valid: 6764664, + nominal: 6030255, + party: 734409, + total: 8235310, + }, + repeatEvent: 'no-action', + pollingStations: 31192, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2041, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'CE-2018-1-SENADOR', + type: 'majoritarian', + voters: 5244712, + votes: { + blank: 853822, + anulled: 1849607, + invalidated: 25690, + valid: 7757861, + nominal: 7757861, + party: 0, + total: 10486980, + }, + repeatEvent: 'no-action', + pollingStations: 21449, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 11993, + canPartialElectionRepeatRemedyElectionResult: false, + wasMajoritarianElectedCandidateInvalidated: false, + }, + { + name: 'CE-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 5244712, + votes: { + blank: 263172, + anulled: 374928, + invalidated: 8814, + valid: 4596080, + nominal: 4300972, + party: 295108, + total: 5243490, + }, + repeatEvent: 'no-action', + pollingStations: 21449, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 8079, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'CE-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 5244712, + votes: { + blank: 260044, + anulled: 373372, + invalidated: 28032, + valid: 4579947, + nominal: 4213497, + party: 366450, + total: 5243490, + }, + repeatEvent: 'no-action', + pollingStations: 21449, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1948, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'DF-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1695724, + votes: { + blank: 122858, + anulled: 102916, + invalidated: 25682, + valid: 1439876, + nominal: 1353183, + party: 86693, + total: 1691392, + }, + repeatEvent: 'no-action', + pollingStations: 6732, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 3694, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'DF-2018-1-DEPUTADO_DISTRITAL', + type: 'proportional', + voters: 1695724, + votes: { + blank: 87589, + anulled: 78624, + invalidated: 11304, + valid: 1497236, + nominal: 1416104, + party: 81132, + total: 1691392, + }, + repeatEvent: 'no-action', + pollingStations: 6732, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1376, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'ES-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 2224259, + votes: { + blank: 144366, + anulled: 142393, + invalidated: 3314, + valid: 1933018, + nominal: 1810909, + party: 122109, + total: 2223207, + }, + repeatEvent: 'no-action', + pollingStations: 8725, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1728, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'ES-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 2224259, + votes: { + blank: 129964, + anulled: 127807, + invalidated: 4691, + valid: 1950673, + nominal: 1824614, + party: 126059, + total: 2223207, + }, + repeatEvent: 'no-action', + pollingStations: 8725, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1131, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'GO-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 3554934, + votes: { + blank: 222192, + anulled: 293661, + invalidated: 4030, + valid: 3031931, + nominal: 2830308, + party: 201623, + total: 3553706, + }, + repeatEvent: 'no-action', + pollingStations: 13995, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 627, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'GO-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 3554934, + votes: { + blank: 196040, + anulled: 267095, + invalidated: 4293, + valid: 3085597, + nominal: 2865007, + party: 220590, + total: 3553706, + }, + repeatEvent: 'no-action', + pollingStations: 13995, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 480, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MA-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 3605223, + votes: { + blank: 157935, + anulled: 145472, + invalidated: 29971, + valid: 3270590, + nominal: 3020490, + party: 250100, + total: 3604580, + }, + repeatEvent: 'no-action', + pollingStations: 15830, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2734, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MA-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 3605223, + votes: { + blank: 139440, + anulled: 134832, + invalidated: 35454, + valid: 3262463, + nominal: 2957145, + party: 305318, + total: 3604580, + }, + repeatEvent: 'no-action', + pollingStations: 15830, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 286, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MG-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 12214681, + votes: { + blank: 848282, + anulled: 1249027, + invalidated: 22301, + valid: 10087571, + nominal: 9430155, + party: 657416, + total: 12211254, + }, + repeatEvent: 'no-action', + pollingStations: 48166, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2125, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MG-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 12214681, + votes: { + blank: 822231, + anulled: 1207933, + invalidated: 51953, + valid: 10127871, + nominal: 9192328, + party: 935543, + total: 12211254, + }, + repeatEvent: 'no-action', + pollingStations: 48166, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 659, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MS-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1479308, + votes: { + blank: 95339, + anulled: 85097, + invalidated: 10987, + valid: 1240027, + nominal: 1143347, + party: 96680, + total: 1478642, + }, + repeatEvent: 'no-action', + pollingStations: 6529, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 6171, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MS-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1479308, + votes: { + blank: 86401, + anulled: 80274, + invalidated: 28413, + valid: 1283007, + nominal: 1180209, + party: 102798, + total: 1478642, + }, + repeatEvent: 'no-action', + pollingStations: 6529, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2535, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MT-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1757938, + votes: { + blank: 115183, + anulled: 125792, + invalidated: 35131, + valid: 1481262, + nominal: 1371080, + party: 110182, + total: 1757368, + }, + repeatEvent: 'no-action', + pollingStations: 7247, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 334, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'MT-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1757938, + votes: { + blank: 93543, + anulled: 106522, + invalidated: 18894, + valid: 1515319, + nominal: 1397024, + party: 118295, + total: 1757368, + }, + repeatEvent: 'no-action', + pollingStations: 7247, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 163, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PA-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 4401798, + votes: { + blank: 185924, + anulled: 249704, + invalidated: 8526, + valid: 3956457, + nominal: 3690184, + party: 266273, + total: 4400611, + }, + repeatEvent: 'no-action', + pollingStations: 17286, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 13, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PA-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 4401798, + votes: { + blank: 147491, + anulled: 202935, + invalidated: 31089, + valid: 4019096, + nominal: 3687051, + party: 332045, + total: 4400611, + }, + repeatEvent: 'no-action', + pollingStations: 17286, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 4651, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PB-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 2436874, + votes: { + blank: 164626, + anulled: 270937, + invalidated: 8927, + valid: 1978257, + nominal: 1847457, + party: 130800, + total: 2435477, + }, + repeatEvent: 'no-action', + pollingStations: 9955, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 478, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PB-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 2436874, + votes: { + blank: 136764, + anulled: 225134, + invalidated: 21697, + valid: 2051415, + nominal: 1891169, + party: 160246, + total: 2435477, + }, + repeatEvent: 'no-action', + pollingStations: 9955, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1029, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PE-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 5393186, + votes: { + blank: 301226, + anulled: 562895, + invalidated: 15682, + valid: 4511453, + nominal: 4178083, + party: 333370, + total: 5391639, + }, + repeatEvent: 'no-action', + pollingStations: 19797, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2921, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PI-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1997932, + votes: { + blank: 78267, + anulled: 123988, + invalidated: 7530, + valid: 1787802, + nominal: 1647120, + party: 140682, + total: 1997587, + }, + repeatEvent: 'no-action', + pollingStations: 8930, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1463, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PI-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1997932, + votes: { + blank: 67747, + anulled: 108596, + invalidated: 3814, + valid: 1816803, + nominal: 1648383, + party: 168420, + total: 1997587, + }, + repeatEvent: 'no-action', + pollingStations: 8930, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1729, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PR-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 6620465, + votes: { + blank: 433691, + anulled: 435007, + invalidated: 3771, + valid: 5709044, + nominal: 5390730, + party: 318314, + total: 6616901, + }, + repeatEvent: 'no-action', + pollingStations: 26137, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 379, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'PR-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 6620465, + votes: { + blank: 448289, + anulled: 456832, + invalidated: 5813, + valid: 5260710, + nominal: 4852937, + party: 407773, + total: 6616901, + }, + repeatEvent: 'no-action', + pollingStations: 26137, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 801, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RJ-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 9479580, + votes: { + blank: 633446, + anulled: 955817, + invalidated: 145240, + valid: 7733626, + nominal: 7254297, + party: 479329, + total: 9474441, + }, + repeatEvent: 'no-action', + pollingStations: 33901, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 159, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RJ-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 9479580, + votes: { + blank: 628772, + anulled: 929182, + invalidated: 149602, + valid: 7754881, + nominal: 7066593, + party: 688288, + total: 9474441, + }, + repeatEvent: 'no-action', + pollingStations: 33901, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 152, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RN-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1967735, + votes: { + blank: 109541, + anulled: 230692, + invalidated: 6893, + valid: 1618823, + nominal: 1509763, + party: 109060, + total: 1966450, + }, + repeatEvent: 'no-action', + pollingStations: 7389, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1355, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RN-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1967735, + votes: { + blank: 88645, + anulled: 184168, + invalidated: 2949, + valid: 1667434, + nominal: 1545808, + party: 121626, + total: 1966450, + }, + repeatEvent: 'no-action', + pollingStations: 7389, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 15, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RO-2018-1-SENADOR', + type: 'majoritarian', + voters: 913340, + votes: { + blank: 125915, + anulled: 228105, + invalidated: 121244, + valid: 1350564, + nominal: 1350564, + party: 0, + total: 1825828, + }, + repeatEvent: 'no-action', + pollingStations: 4181, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 18284, + canPartialElectionRepeatRemedyElectionResult: false, + wasMajoritarianElectedCandidateInvalidated: false, + }, + { + name: 'RO-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 913340, + votes: { + blank: 43183, + anulled: 50894, + invalidated: 35532, + valid: 783305, + nominal: 734338, + party: 48967, + total: 912914, + }, + repeatEvent: 'no-action', + pollingStations: 4181, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1502, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RO-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 913340, + votes: { + blank: 34493, + anulled: 42634, + invalidated: 15690, + valid: 798726, + nominal: 744107, + party: 54619, + total: 912914, + }, + repeatEvent: 'no-action', + pollingStations: 4181, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 162, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RR-2018-1-SENADOR', + type: 'majoritarian', + voters: 287150, + votes: { + blank: 21366, + anulled: 46066, + invalidated: 10501, + valid: 495575, + nominal: 495575, + party: 0, + total: 573508, + }, + repeatEvent: 'no-action', + pollingStations: 1172, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 426, + canPartialElectionRepeatRemedyElectionResult: false, + wasMajoritarianElectedCandidateInvalidated: false, + }, + { + name: 'RR-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 287150, + votes: { + blank: 6160, + anulled: 7306, + invalidated: 2580, + valid: 270708, + nominal: 260220, + party: 10488, + total: 286754, + }, + repeatEvent: 'no-action', + pollingStations: 1172, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2479, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RR-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 287150, + votes: { + blank: 3900, + anulled: 5712, + invalidated: 9651, + valid: 267491, + nominal: 255590, + party: 11901, + total: 286754, + }, + repeatEvent: 'no-action', + pollingStations: 1172, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 89, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RS-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 6838548, + votes: { + blank: 596391, + anulled: 377423, + invalidated: 16771, + valid: 5845077, + nominal: 5497531, + party: 347546, + total: 6835866, + }, + repeatEvent: 'no-action', + pollingStations: 27274, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 7878, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'RS-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 6838548, + votes: { + blank: 581380, + anulled: 368241, + invalidated: 79084, + valid: 5806757, + nominal: 5363246, + party: 443511, + total: 6835866, + }, + repeatEvent: 'no-action', + pollingStations: 27274, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 697, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SC-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 4246278, + votes: { + blank: 301690, + anulled: 319534, + invalidated: 68637, + valid: 3548458, + nominal: 3332745, + party: 215713, + total: 4241667, + }, + repeatEvent: 'no-action', + pollingStations: 15562, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SC-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 4246278, + votes: { + blank: 268999, + anulled: 289759, + invalidated: 19155, + valid: 3663271, + nominal: 3429667, + party: 233604, + total: 4241667, + }, + repeatEvent: 'no-action', + pollingStations: 15562, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1668, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SE-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 1280300, + votes: { + blank: 72049, + anulled: 153377, + invalidated: 54715, + valid: 999441, + nominal: 932252, + party: 67189, + total: 1279582, + }, + repeatEvent: 'no-action', + pollingStations: 5137, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 6092, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SE-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 1280300, + votes: { + blank: 60607, + anulled: 127446, + invalidated: 4713, + valid: 1066624, + nominal: 988716, + party: 77908, + total: 1279582, + }, + repeatEvent: 'no-action', + pollingStations: 5137, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1160, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SP-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 25930749, + votes: { + blank: 1952806, + anulled: 2670041, + invalidated: 152780, + valid: 21131103, + nominal: 19537230, + party: 1593873, + total: 25921320, + }, + repeatEvent: 'no-action', + pollingStations: 96328, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 2677, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'SP-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 25930749, + votes: { + blank: 2137781, + anulled: 2782946, + invalidated: 146832, + valid: 20852812, + nominal: 18633409, + party: 2219403, + total: 25921320, + }, + repeatEvent: 'no-action', + pollingStations: 96328, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 1213, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'TO-2018-1-DEPUTADO_FEDERAL', + type: 'proportional', + voters: 831599, + votes: { + blank: 27259, + anulled: 86487, + invalidated: 1418, + valid: 715942, + nominal: 659286, + party: 56656, + total: 831214, + }, + repeatEvent: 'no-action', + pollingStations: 3832, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 998, + canPartialElectionRepeatRemedyElectionResult: false, + }, + { + name: 'TO-2018-1-DEPUTADO_ESTADUAL', + type: 'proportional', + voters: 831599, + votes: { + blank: 19634, + anulled: 62862, + invalidated: 1975, + valid: 746638, + nominal: 686764, + party: 59874, + total: 831214, + }, + repeatEvent: 'no-action', + pollingStations: 3832, + invalidatedPollingStations: 0, + canInvalidatedVotesChangeElectionResult: true, + minimalVoteLossToChangeElectoralResult: 410, + canPartialElectionRepeatRemedyElectionResult: false, + }, +]; + +export default data; diff --git a/packages/codex/src/integrity/helpers/events.ts b/packages/codex/src/integrity/helpers/events.ts new file mode 100644 index 0000000..29b85be --- /dev/null +++ b/packages/codex/src/integrity/helpers/events.ts @@ -0,0 +1,3 @@ +export const NO_ACTION = 'no-action'; +export const PARTIAL_ELECTION_REPEAT = 'partial-election-repeat'; +export const FULL_ELECTION_REPEAT = 'full-election-repeat'; diff --git a/packages/codex/src/integrity/helpers/types.ts b/packages/codex/src/integrity/helpers/types.ts new file mode 100644 index 0000000..a668290 --- /dev/null +++ b/packages/codex/src/integrity/helpers/types.ts @@ -0,0 +1,27 @@ +export type ElectoralIntegrityVotes = { + blank: number; + anulled: number; + invalidated: number; + valid: number; + nominal: number; + party: number; + total: number; +}; + +export type ElectoralIntegrityData = { + name: string; + type: 'majoritarian' | 'proportional'; + voters: number; + votes: ElectoralIntegrityVotes; + repeatEvent: 'partial-election-repeat' | 'full-election-repeat' | 'no-action'; + pollingStations: number; + invalidatedPollingStations: number; + canInvalidatedVotesChangeElectionResult: boolean; + canPartialElectionRepeatRemedyElectionResult: boolean; + minimalVoteLossToChangeElectoralResult: null | number; + wasMajoritarianElectedCandidateInvalidated?: undefined | boolean; +}; + +export interface ElectoralIntegrityClass { + shouldRepeatElection: (electionData: ElectoralIntegrityData) => string; +} diff --git a/packages/codex/src/integrity/interpretation/brazilian-electoral-code.ts b/packages/codex/src/integrity/interpretation/brazilian-electoral-code.ts new file mode 100644 index 0000000..77213a4 --- /dev/null +++ b/packages/codex/src/integrity/interpretation/brazilian-electoral-code.ts @@ -0,0 +1,39 @@ +import { ElectoralIntegrityData } from '../helpers/types'; +import { + NO_ACTION, + PARTIAL_ELECTION_REPEAT, + FULL_ELECTION_REPEAT, +} from '../helpers/events'; + +class BrazilianElectoralCode { + static invalidatedVotesThreshold = 50; + + shouldRepeatElection(electionData: ElectoralIntegrityData) { + const { + votes, + canInvalidatedVotesChangeElectionResult, + canPartialElectionRepeatRemedyElectionResult, + } = electionData; + + if (!canInvalidatedVotesChangeElectionResult) { + return NO_ACTION; + } + + const invalidatedVotesPercentage = (100 * votes.invalidated) / votes.valid; + + if ( + invalidatedVotesPercentage > + BrazilianElectoralCode.invalidatedVotesThreshold + ) { + return FULL_ELECTION_REPEAT; + } + + if (canPartialElectionRepeatRemedyElectionResult) { + return PARTIAL_ELECTION_REPEAT; + } + + return FULL_ELECTION_REPEAT; + } +} + +export default BrazilianElectoralCode; diff --git a/packages/codex/src/integrity/interpretation/brazilian-electoral-court.ts b/packages/codex/src/integrity/interpretation/brazilian-electoral-court.ts new file mode 100644 index 0000000..b2fa852 --- /dev/null +++ b/packages/codex/src/integrity/interpretation/brazilian-electoral-court.ts @@ -0,0 +1,51 @@ +import { ElectoralIntegrityData } from '../helpers/types'; +import { + NO_ACTION, + // PARTIAL_ELECTION_REPEAT, + FULL_ELECTION_REPEAT, +} from '../helpers/events'; + +class BrazilianElectoralCodeCourtInterpretation { + static INVALIDATED_VOTES_THRESHOLD = 50; + + shouldRepeatElection(electionData: ElectoralIntegrityData) { + const { + votes, + // canInvalidatedVotesChangeElectionResult, + canPartialElectionRepeatRemedyElectionResult, + invalidatedPollingStations, + wasMajoritarianElectedCandidateInvalidated = null, + } = electionData; + + // if (!canInvalidatedVotesChangeElectionResult) { + // return NO_ACTION; + // } + + const invalidatedVotesPercentage = (100 * votes.invalidated) / votes.valid; + + if ( + invalidatedVotesPercentage > + BrazilianElectoralCodeCourtInterpretation.INVALIDATED_VOTES_THRESHOLD + ) { + return FULL_ELECTION_REPEAT; + } + + if (wasMajoritarianElectedCandidateInvalidated === true) { + return FULL_ELECTION_REPEAT; + } + + if (canPartialElectionRepeatRemedyElectionResult) { + // return PARTIAL_ELECTION_REPEAT; + if (invalidatedPollingStations === 1) { + return NO_ACTION; + } + + return NO_ACTION; + } + + // return FULL_ELECTION_REPEAT; + return NO_ACTION; + } +} + +export default BrazilianElectoralCodeCourtInterpretation; diff --git a/packages/codex/src/integrity/interpretation/western-electoral-heritage.ts b/packages/codex/src/integrity/interpretation/western-electoral-heritage.ts new file mode 100644 index 0000000..1e21a61 --- /dev/null +++ b/packages/codex/src/integrity/interpretation/western-electoral-heritage.ts @@ -0,0 +1,27 @@ +import { ElectoralIntegrityData } from '../helpers/types'; +import { + NO_ACTION, + PARTIAL_ELECTION_REPEAT, + FULL_ELECTION_REPEAT, +} from '../helpers/events'; + +class WesternElectoralHeritage { + shouldRepeatElection(electionData: ElectoralIntegrityData) { + const { + canInvalidatedVotesChangeElectionResult, + canPartialElectionRepeatRemedyElectionResult, + } = electionData; + + if (canInvalidatedVotesChangeElectionResult === false) { + return NO_ACTION; + } + + if (canPartialElectionRepeatRemedyElectionResult) { + return PARTIAL_ELECTION_REPEAT; + } + + return FULL_ELECTION_REPEAT; + } +} + +export default WesternElectoralHeritage; diff --git a/packages/codex/tsconfig.json b/packages/codex/tsconfig.json new file mode 100644 index 0000000..e2dfc44 --- /dev/null +++ b/packages/codex/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "outDir": "./lib", + "baseUrl": ".", + "target": "es2021", + "module": "commonjs", + "lib": ["dom", "esnext"], + "declaration": true, + "declarationMap": true, + "pretty": true, + "sourceMap": true, + "noImplicitAny": false, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "allowJs": true, + }, +}