Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

🐞 Eligible voters: count each election's voters once, and only enabled voters on its dashboard (9.0) - #3924

Merged
Findeton merged 4 commits into
release/9.0from
fix/meta-14272/release/9.0
Oct 20, 2026
Merged

Findeton merged 4 commits into
release/9.0from
fix/meta-14272/release/9.0

Conversation

@Findeton

@Findeton Findeton commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Parent issue: https://github.com/sequentech/meta/issues/14272

Two fixes to an election's Eligible Voters.

1. Election dashboard: disabled voters were counted.

  • Cause: Eligible voters came from count_users with no enabled argument.
  • Fix: the query now sends enabled: true, as release/10.0 and release/10.1 already do. The generated gql.ts / graphql.ts documents are updated to match.

2. Tally results: the election's eligible voters (results_election.elegible_census, and the reports' election census and turnout).

  • Cause: it was the sum of the census of the election's contest areas. That sum gets two things wrong:
    • a voter counted once per area: a voter whose account has more than one area-id value among the election's areas is counted once for each of those areas;
    • ID-authorized voters left out: an election without an alias is named by an empty alias when its voters are listed. So voters whose authorized elections name it by its ID, as Keycloak's authorized-elections mapper does (AuthorizedElectionsUserAttributeMapper: key = alias, or the ID without one), are left out.
  • Fix: when the session first dumps its ballots, it counts each election's enabled voters once each, across the areas of the election's tally rows, naming the election as Keycloak does. It records that on the session (election_electorates, a JSON string, as this branch's transmission-package readers expect), and the election census is that figure.

Unchanged:

  • Area set: every area-contest association already has a tally row on this branch (tally_ceremony.rs:204), and is_acclaimed is only a stored column here. So the areas are the same as before, and the areas-with-nothing-to-tally defect of the other branches does not occur.
  • Contest and area-contest figures are unchanged.
  • Ballots and totals: vote totals, cast-ballot counts and which ballots are tallied are untouched. insert_ballots.rs is not changed.
  • Historical sessions: no stored result is rewritten. Electorates are recorded only on a session's first dump, so a session dumped before this change keeps its old sum.

Known limitation. Voters authorized by the election's ID are now in the election census, but their ballots stay out of the tally, as before. Their area census is also unchanged. So the election total can be larger than its areas' sum. Including their ballots changes which ballots are tallied; that is out of scope here (ovcs 0ef8fa2).

Imported sessions: import_tally replaces the recorded electorates' election IDs through the import's ID map, as it does for the session's own elections and areas, so an imported session keeps its recorded census. An unknown ID fails the import, and a recorded map naming elections other than the session's is an error rather than being dropped. A session only records maps for its own elections, and nothing edits a session's elections afterwards, so that error means corrupted data. It surfaces as a tally session error on every run until the annotation is corrected, rather than silently changing the census.

Validation (synthetic data only; no environment accessed)

  • Dashboard query: GetElectionStats, as written and as generated, was schema-validated and executed with a count_users resolver over three synthetic voters, one of them disabled. Before: 3 eligible, no enabled argument. After: 2, with enabled: true. A Jest test was added; this branch's CI has no Admin Portal Jest job, so CI doesn't run it.
  • Unit tests: cargo test -p windmill --lib, filtered to election_electorates, execute_tally_session and users. They cover:
    • the areas of an election from its tally rows;
    • the Keycloak name of an election;
    • first dump vs retry vs a pre-change dump;
    • census = electorate with cast votes unchanged, and the old sum kept without one;
    • the transmission packages read through ValidateAnnotations on a session carrying the electorates;
    • reading the annotation back.
  • Synthetic PostgreSQL test the_voters_of_areas_are_the_enabled_ones_each_counted_once, run against a throwaway PostgreSQL with temporary Keycloak tables. It covers enabled vs disabled, an area whose voters are all disabled, service account, other realm, other election, a voter in two areas, and a voter authorized by election ID (counted under the ID, not under an empty alias).
  • Formatting: rustfmt --check and prettier --check pass.
  • Review: an independent review was done; its points were applied.
  • Not executed: the wiring in map_plaintext_data end to end, and a full tally on a running stack.

No Beyond gitlink on this branch; no submodule change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PkzuNwsArCPLjD5zVvWYc7

… dashboard

The election dashboard's Eligible voters came from count_users without an
enabled filter, so disabled voters were counted. Send enabled: true, as
release/10.0 and release/10.1 already do.

Parent issue: sequentech/meta#14272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkzuNwsArCPLjD5zVvWYc7
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: bd35d01e-dfed-462b-84ee-0fee2e31bb1c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@Findeton

Findeton commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Status of the meta#14272 fix family. FELIX4-DIRECT-20261016 acknowledged. This comment is edited in place; last update: final, CI terminal.

Meta issue: https://github.com/sequentech/meta/issues/14272. Assigned to Findeton, type Bug. The project iteration is not set because the token has no project scope. The meta body carries the full decisions and the coverage matrix.

What is fixed. Every fix is census-only. Ballot selection, cast votes, vote totals, country/session scope and historical snapshots are unchanged.

Defect Branches Fix
Election dashboard counted disabled voters ovcs, 9.0 (10.x already fixed by #3888) count_users with enabled: true
Election total left out areas with nothing to tally (acclaimed-only) ovcs, 10.1, 10.0 Per-election electorate recorded at the first ballot extraction
A voter counted once per area of the election all four Distinct count across the election's areas
Voters authorized by election ID left out (election without external ID / alias) 10.1, 10.0, 9.0 Electorate names the election as Keycloak does; ballot extraction unchanged
Acclaimed-only area unlinked after publication left out; publication races ovcs, 10.1, 10.0 Areas recorded at session creation (election_areas); older sessions fall back to created_at
Imported sessions would lose recorded census all four import_tally remaps recorded IDs; unknown ID fails the import; a mismatched recorded map is an error

Final heads and executed tests. Synthetic data only; all compiled, ran and passed.

Branch PR Head windmill lib (focused) PostgreSQL synthetic Other
ovcs #3925 3672bf6 160 passed (incl. tally_ceremony, import_tally) 2 passed dashboard query 3 → 2 eligible
release/10.1 #3926 89f720b 36 passed 1 passed
release/10.0 #3927 1105c70 36 passed 1 passed same windmill diff as 10.1
release/9.0 #3924 06860e6 16 passed* 1 passed dashboard query 3 → 2 eligible

* 9.0's tests ran on 2ace9f0. 06860e6 changes one test comment only.

Every branch passes its import test: an exported row goes through process_tally_session_record, then the recount aggregation gives census 4 and cast 3, not the sum of 5.

Independent review. Every round was rechecked on the committed heads, and no blocking issue remains. Its last points are applied: the 9.0 wording, and documentation of the fail-loud and deleted-area import edges.

CI on final heads: terminal, all PR checks green.

harvest coverage — no decrease on #3925: failed on attempt 1, passed on its single re-run.

  • Attempt 1 (job, artifact 12077499344): base vs head functions 1869 → 1868, lines 12755 → 12751, regions 14765 → 14759.
    • Base and head harvest had identical source_sha256 (d53d7fbe…), config and lockfile hashes, and the same 560 tests passed.
    • Only harvest/src/services/service_auth.rs differed: ServiceTokenRefusal::reason, called only as a warn! argument (l.408), and the warn! argument at l.347. The refusal paths stayed covered.
  • Re-run, attempt 2 on the same head (job): passed, with base 1868 vs head 1869 functions, i.e. the same difference reversed.
  • Conclusion: coverage that depends on logging, varying between runs in harvest code this PR doesn't change. tracing evaluates warn! arguments only when the callsite is enabled, and the test binary's only filtered Dispatch is scoped to one test, so this depends on parallel test interleaving. That mechanism is inferred. No code or workflow change was made for it.

Pre-existing, not repaired: the release/9.0 push workflow Java Test fails on the final head (run 38971050964). java_test.yml has the identical blob 71777f82 at base and head, and its Install Maven step uses an invalid command: key. Release/9.0's own pushes fail it too (de2ea97, f42d9e6, 819d18a). It is not a PR check.

Unresolved limitations, documented:

  • ovcs sealed areas: a voter in two sealed areas counts twice, because seals record no voter identities. A signed seal redesign is out of scope.
  • Older sessions: sessions created before this change keep the created_at area fallback and its publication-race and import-after-session edges.
  • ID-authorized voters (release branches): they are in the census, but their ballots stay untallied, as before. Including them would change ballot selection.
  • Mismatched recorded map: errors loudly; it can only arise from corrupted data.

Beyond gitlinks are unchanged (ovcs 4ba21394, 10.x b441a07c, none on 9.0). No production access, merges or deployments.

…ults

An election's eligible voters was the sum of its areas' census, which counts a
voter in more than one of its areas once per area and leaves out voters
authorized by the election's id when it has no alias. When the session first
dumps its ballots, count each election's enabled voters once each across its
tally rows' areas, naming it as Keycloak's mapper does, and record them on the
session. Contest and area figures, cast votes and the ballots tallied are
unchanged, and sessions dumped before keep their census.

Parent issue: sequentech/meta#14272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkzuNwsArCPLjD5zVvWYc7
@Findeton Findeton changed the title 🐞 Admin Portal: Count only enabled voters as eligible on the election dashboard (9.0) 🐞 Eligible voters: count each election's voters once, and only enabled voters on its dashboard (9.0) Oct 16, 2026
Findeton and others added 2 commits October 16, 2026 21:39
Importing a tally session replaces its election and area ids but copied its
annotations as they were, so its recorded census would name the exporting
event's elections. Replace the election ids of the recorded electorates through the import's id map, refusing an id it does not have as for
the session's own. A recorded map that names elections other than the
session's is now an error rather than being counted or dropped.

Parent issue: sequentech/meta#14272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PkzuNwsArCPLjD5zVvWYc7
@Findeton
Findeton merged commit 7299717 into release/9.0 Oct 20, 2026
22 checks passed
@Findeton
Findeton deleted the fix/meta-14272/release/9.0 branch October 20, 2026 20:37
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.

1 participant