Repository navigation
fix(election-config): keep synthetic ERT voters' generated identity (meta#15635) (ovcs) - #4709
Merged
Merged
Conversation
…meta#15635) (ovcs) The historical Voters sheet refused the first_name, middleName, last_name and dateOfBirth headers outright, so the ERT census could not carry what the enrollment lookup compares. - Accept the four headers; only an explicit ert = TRUE row may give them a value. Names must be text; dateOfBirth must be a real date written strictly YYYY-MM-DD. Blank values are accepted and carry nothing. - A synthetic row with an identity gets the embassy of its area's configured Post (the area description, formatted as the official census's is); it is never read from the row or parsed from area_name, and an area without a Post is refused. Identity-less rows are emitted exactly as before. - An official (non-ERT) row stating any of them is refused: an official voter's identity still comes from SQL. Other identity-like headers (embassy, country, suffix, ...) stay refused, as do ID-card values on ERT rows, official usernames, duplicate usernames and non-reserved emails. Tests use generated fictional identities only, including a release-shaped roster of eight ERT accounts of which two carry an identity, checked in the emitted ert_census member and absent from the official census. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
…shed identities (meta#15635) - A synthetic ERT row that furnishes an identity now states middleName, blank when not given, and the ERT census keeps that column even when every such row leaves it blank: the enrollment lookup (Beyond #1538's ert-census-identity check) reads the column. Identity-less ERT rows, rosters without any identity and the official census are unchanged; no identity is required of any ERT row. - Apply the rustfmt output CI reported for historical.rs and historical_tests.rs. - Fictional test: two furnished identities with an explicitly blank middle name plus six identity-less rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
edulix
added a commit
that referenced
this pull request
Dec 4, 2026
…llments rejected (meta#15626) (ovcs) (#4720) Backend part of sequentech/meta#15626 (sub-issue of sequentech/meta#15576). Per COMELEC Bid Bulletin 1, Annex B row 3, an enrollment that matches no voter is **disapproved with a notice**. It is never sent to manual review. ## Changes ### 1. Reject an enrollment that matches no voter - #4700 has since merged `REJECT` into the janitor COMELEC `keycloak.hbs`, with sequent-core's `every_shipped_realm_source_rejects_an_unmatched_enrollment`. This branch is rebased on it and doesn't repeat it. - A repo-wide grep finds no other COMELEC/OVCS source with `PENDING_APPROVAL`. - New windmill test `ovcs_realm_sources_tests.rs`. It covers the janitor COMELEC template, `default_profile.json` and every sequent-core preset, and pins the `unset-attributes` change in item 3. - New test `no_registry_voter_is_rejected_under_the_reject_policy`. ### 2. Rejection notice and voter-facing page (checked; no code change needed) - When windmill answers `REJECTED`/`NO_VOTER`, `LookupAndUpdateUser` renders `registration-rejected-finish.ftl`: the "Application Disapproved" page showing the `NO_VOTER` reason text. It also calls `Utils.sendRejectCommunication`, which sends the reject email/SMS. The SMS carries `reasonText(NO_VOTER)` ("The data provided for enrollment does not match any existing user in the registry.") and the email template gets `rejectReasonKey`. - "Manual Verification required" (`registration-manual-finish.ftl`) shows only for `PENDING`, which a no-match enrollment no longer gets under `REJECT`. ### 3. "Already enrolled" comes from real enrollment state - Before: `already_enrolled` was true when any `unset-attributes` value was non-empty (`email`, `sequent.read-only.mobile-number`, ...). An admin typing a phone number on a voter therefore marked them as enrolled. - Now (`decide_enrollment` in `windmill/src/services/application.rs`), a registry voter is already enrolled only when one of these holds: - they have an **ACCEPTED application** in the election event (new query `get_voters_with_accepted_application`), or - `sequent.read-only.id-card-number-validated` is set (`VERIFIED`, or a historical `true`). Scanovate/manual verification sets it, and the lookup copies it to the voter. `false`/`no`/`0`/blank don't count. - Matrix rule 1 (already enrolled with at most 1 differing detail → REJECT `ALREADY_APPROVED`) still applies to genuinely enrolled voters. `application_matrix_tests.rs` covers the marker, an accepted application, typed email/mobile, "no" marker values, another voter's application, and a voter with more than one differing detail. - Keycloak's `LookupAndUpdateUser.checkUnsetAttributes` refuses an accepted enrollment when an unset-attribute is set. If only windmill changed, a voter with an admin-typed email or mobile would be ACCEPTED and then fail with an internal error. So the COMELEC template, the biometric preset and `default_profile.json` now set `unset-attributes` to `sequent.read-only.id-card-number-validated` only. - Docs: the Approvals reference now says what "Already enrolled" means. ### 4. The admin-created voter got username `user` - I read the code path. No code generates a username: admin-portal `EditUserForm` (create mode) sends `user.username` exactly as typed. harvest `create_user` passes it unchanged to Keycloak `POST /users`, which refuses a missing username. Windmill stores `""` (not `user`) as the applicant `username` for pending applications, and the Approvals screens never create voters. - In create mode the form has an editable **Username** text field next to **Password** / **Repeat password**. That is the shape browsers autofill with a saved login for the site. So `user` was either typed or autofilled by the browser. I could not confirm which, because I have no access to the rc.48 logs on ovcs-server. - Hardening: in the create form, the username field now has `autoComplete="off"` and the password fields have `autoComplete="new-password"`. ### 5. Passport middle name (meta#15505): not changed, notes - The Scanovate extractor can already store `/middle_name_english` (`AttributeRules` stores `""` when the field is absent). Windmill's `GivenNames` handles both cases: a blank middle name keeps the machine-readable comparison, and a present one is compared separately. - I did **not** add the mapping to the passport `attributes-to-store`, for two reasons. We have no evidence that Scanovate returns the visual-zone middle name for Philippine passports: the machine-readable zone has none, and the only fixture shows it blank. Also, the Scanovate step runs after the registration form, so storing `""` would overwrite a middle name the voter typed. - The mapping can be added once Scanovate confirms it returns the field, together with an extractor change that skips empty values. Reading it from the visual zone ourselves would need OCR, which is out of scope. step#4687 already keeps the registry voter's middle name. ### 6. ERT census identity columns (beyond#1538) Already on `ovcs` through #4709 (meta#15635), so this PR doesn't change it. ERT rows (`ert` = TRUE) may carry `first_name`, `middleName`, `last_name` and `dateOfBirth`. An official row stating an identity is refused, and rows without identity are built byte-identically. One difference from the request: `embassy` isn't read from the row. It is set from the area's configured Post, so it can't contradict the area. ### WASM package `presets.rs`/`default_profile.json` change sequent-core, so the committed `sequent-core-0.1.0.tgz` needs the usual follow-up sync (as #4716 did after #4714). ## Tests run (docker, arm64, targeted) - `cargo test -p windmill --lib -- services::application`: **104 passed**, 0 failed. Includes `matrix_tests::*` (new already-enrolled and reject-policy cases) and `ovcs_realm_sources_tests::*`. - sequent-core `cargo test --lib --features election_config_xlsx,election_config_archive,election_config_templates -- preset_doc_tests::default_profile_json presets::tests every_shipped_realm_source`: **32 passed**. Includes `default_profile_json_matches_the_shipped_presets`, `an_unmatched_biometric_enrollment_is_rejected` and #4700's `every_shipped_realm_source_rejects_an_unmatched_enrollment`. - Not run: the admin-portal typecheck. The `EditUserForm.tsx` change only adds `autoComplete` props. ## ovcs-server data (NOT run, needs Eduardo's approval) These change only the Keycloak config. Existing applications are untouched; the pending ones from the issue still need a decision in Approvals. ```sh # kcadm runs in the Keycloak pod; jq runs on the host. For example: # KC="kubectl -n <ns> exec -i deploy/keycloak -- /opt/keycloak/bin/kcadm.sh" # Admin credentials: secret keycloak-credentials (KC_BOOTSTRAP_ADMIN_USERNAME / _PASSWORD). $KC config credentials --server http://localhost:8090 --realm master \ --user "$KC_BOOTSTRAP_ADMIN_USERNAME" --password "$KC_BOOTSTRAP_ADMIN_PASSWORD" # 1. List each event realm's lookup-register config: realm, config id, policy, unset-attributes for realm in $($KC get realms --fields realm --format csv --noquotes | grep -- '-event-'); do $KC create "realms/$realm/partial-export" -o \ | jq -r --arg r "$realm" '.authenticatorConfig[]? | select(.alias=="lookup-register") | [$r, .id, .config["no-matching-voter-policy"] // "(unset=REJECT)", .config["unset-attributes"]] | @TSV' done # Rows with PENDING_APPROVAL, or unset-attributes that still list email/mobile, need step 2. # 2. For each such REALM / ID $KC get "authentication/config/$ID" -r "$REALM" \ | jq '.config["no-matching-voter-policy"]="REJECT" | .config["unset-attributes"]="sequent.read-only.id-card-number-validated"' > lookup.json $KC update "authentication/config/$ID" -r "$REALM" -f - < lookup.json # 3. Verify $KC get "authentication/config/$ID" -r "$REALM" | jq '.config | {"no-matching-voter-policy", "unset-attributes"}' ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parent issue: https://github.com/sequentech/meta/issues/15635
Problem
The historical workbook importer refused the
first_name,middleName,last_nameanddateOfBirthheaders on the Voters tab, so the ERT census could not carry the fields the enrollment lookup compares.Change (
sequent-coreelection_config::historical)ert = TRUErow may give them a value: names must be text (no control characters),dateOfBirthmust be a real date written strictlyYYYY-MM-DD. Blank values are accepted and carry nothing.embassy= its area's configured Post (the areadescription, formatted withformat_embassylike the official census). It is never read from the row and never parsed fromarea_name; an area with no Post is refused instead of guessed. Rows without identity are emitted exactly as before, so a roster where only some accounts have identity keeps the other accounts unchanged.ConflictingColumns); official identity still comes from SQL. Other identity-like headers (embassy,country,suffix,firstName, ...) stay refused.ert.roster-*checks.Tests (fictional generated identities only)
a_flagged_row_may_carry_a_generated_identity_with_its_posts_embassy: values are kept, embassy comes from the Post, and blank-identity or identity-less rows match the rows produced before this change.a_flagged_rows_identity_is_refused_rather_than_guessed: rejects non-ISO and impossible dates, datetime strings, numbers, non-text names, control characters, row-statedembassy/country, an ID card together with an identity, and an identity in an area that has no Post.an_official_row_may_not_state_an_identity_but_may_leave_it_blank: tests header acceptance, refusal on official rows, and that blank cells change nothing.a_release_shaped_ert_roster_keeps_its_generated_identities_in_the_ert_census_alone: runs a release-shaped workbook (all identity headers, eight ERT accounts, two with identity) through xlsx →adapt(COMELEC default decisions) →build→archive::layout. It parses the actualert_census-<id>.csvmember and checks that the official census member is unchanged and contains none of the ERT accounts or identities.blank_identity_headers_leave_the_ert_census_as_it_was: with identity headers present but every value blank, the ERT census is byte-for-byte the same as with no identity headers.Not verified locally
The authoring session had no Rust toolchain available, so nothing was compiled or tested locally, including
cargo fmt/clippyand the WASM rebuild. CI is the first compile and test run. The real release workbook was not used. If itsdateOfBirthcells are spreadsheet date cells rather than text, they will be refused visibly by the strictYYYY-MM-DDrule.🤖 Generated with Claude Code