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

🐞 Historical import ignores template SampleData preview tabs (meta#15637) (ovcs) - #4714

Merged
Findeton merged 8 commits into
ovcsfrom
rc51-meta15637-historical-sampledata
Dec 3, 2026
Merged

Findeton merged 8 commits into
ovcsfrom
rc51-meta15637-historical-sampledata

Conversation

@Findeton

@Findeton Findeton commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Fixes the Historical Delivery Review SQL + workbook conversion refusing template preview tabs with unrecognized supplemental sheet (sequentech/meta#15637).

Rule (historical.rs, is_template_sample_tab): a tab named exactly SampleData or SampleData-<non-empty suffix> (trimmed, any case) is the template editor's preview data (Beyond #1536, isSampleTab). It is skipped as metadata: not refused, and not imported or passed through. Every other unknown tab still gets InvalidValue / unrecognized supplemental sheet, including near misses such as SampleDatas, SampleData-, Sample-Data and Samples.

Note: Beyond's /^sampledata/i also matches an unhyphenated suffix (SampleDataBallot). This PR deliberately keeps that form refused so a typo can't be silently dropped. If we want it accepted, widening the rule is a one-line change.

Tests (synthetic only, no real workbook or SQL): template_sample_data_tabs_are_ignored_not_imported, unknown_or_misspelled_tabs_are_still_refused, template_sample_tab_names_match_the_editor_plain_and_suffixed_forms.

No local cargo in this session, so CI covers rustfmt, clippy and tests.

🤖 Generated with Claude Code

…abs (meta#15637)

The Historical Delivery Review conversion refused a workbook carrying the
template editor's preview tabs (Beyond #1536) as an unrecognized
supplemental sheet. Skip exactly SampleData and SampleData-<suffix>
(trimmed, any case) as metadata: never imported, and every other unknown
or near-miss tab is still refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

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

🗂️ Base branches to auto review: 2

  • release/10.0
  • feat/meta-12767/.*

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

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

Findeton and others added 7 commits December 3, 2026 21:32
…ot alias (meta#15637)

Beyond #1536 regression-tests the template editor's compact
SampleDataBallot tab name, so accept exactly that alias alongside
SampleData and SampleData-<suffix> (trimmed, any case). SampleDatas,
SampleDataBallots and any other SampleData<word> or unknown tab is still
refused. The positive test now also asserts the converted workbook is
identical with and without the preview tabs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…15637)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts only in generated mirrors: the four sequent-core-0.1.0.tgz
archives and packages/yarn.lock take origin/ovcs (25b2808) exactly as
temporary placeholders; they need a fresh canonical WASM rebuild that
includes historical.rs. Source/test changes merged cleanly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(meta#15637)

template_sample_data_tabs_are_ignored_not_imported failed in CI (run
47210149889): adapt() records the input workbook's SHA-256 in
import:provenance, and adding the preview tabs changes those bytes, so the
two workbooks could never be equal. Check that digest against each input
explicitly, blank only it, and compare every other sheet, header and cell;
the preview-value check now inspects serialized rows rather than a Debug
string that elides them. Production code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Findeton
Findeton merged commit 56de072 into ovcs Dec 3, 2026
37 checks passed
@Findeton
Findeton deleted the rc51-meta15637-historical-sampledata branch December 3, 2026 23:11
Findeton added a commit that referenced this pull request Dec 3, 2026
Refresh the four generated sequent-core archives and their matching Yarn
lock hashes after #4714 landed. No source changes. Canonical package
freshness passed on the identical source tree before the squash merge.
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>
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